Commits

ZyX_I committed de6d737

@aurum/drivers/git: Now it is git who determines what is proper abbreviation for commit hash
Added repo.hasrevisions=False
@aurum/log: $rev word is skipped by default if repo.hasrevisions is false

  • Participants
  • Parent commits fa198bc

Comments (0)

Files changed (4)

File doc/aurum.txt

            template strings).
 synreg     Pass this regular expression to “syn match”. Useful if you override 
            output of the {word} using “expr” keyword.
-pref, suf  For some single-line statements (currently: parents, children, 
+pref, suf  For some single-line statements (currently: rev, parents, children, 
            tags, bookmarks and branch): if result of evaluating {word} is 
            non-empty (for branch: is not equal to "default") add value of the 
            argument before (pref) or after (suf) the {word}.
              determines whether “default” branch should be shown. Any value 
              other then "keep" will tell template engine not to show the 
              branch name in this case. Default value: "keep".
-hex, user, rev
-             String with value equal to the value of corresponding changeset 
+hex, user    String with value equal to the value of corresponding changeset 
              property.
+rev          Like above, but also accepts additional argument which determines 
+             whether revision should be shown if |aurum-repo.hasrevisions| is 
+             false. Any value of this additional argument that is not equal to 
+             "keep" designates that it should be ignored in this case.
+             Default value: "ignore".
 time         String representation of the date. Accepts one positional 
              parameter: string that will be passed to |strftime()| to format 
              the time. Default value: "%d %b %Y %H:%M".
     Determines whether repository has merges containing more then two parents. 
     In this case slower, but more universal algorithm will be used.
     This key is optional, default value: true.
+hasrevisions :: Bool                                 *aurum-repo.hasrevisions*
+    Determines whether |aurum-cs.rev| contains something different from 
+    abbreviated hash. If this option is false, then in log produced by 
+    |aurum://log| revisions will be ignored.
+    This key is optional, default value: true.
 functions :: {String : FRef}                            *aurum-repo.functions*
     Dictionary that contains all driver-specific functions. All functions 
     except |aurum-rf-repo|, |aurum-rf-checkdir| and |aurum-rf-checkremote| 

File plugin/aurum/drivers/git.vim

 " author name
 " author email
 " 1-indented commit message
-let s:logformat='%H-%P-%at%n%an%n%ae%n%d%n%w(0,1,1)%B'
+let s:logformat='%h-%H-%P-%at%n%an%n%ae%n%d%n%w(0,1,1)%B'
 let s:logkwargs={'format': s:logformat, 'encoding': 'utf-8'}
 function s:F.parsecs(csdata, lstart)
     let line=a:lstart
     let cs={'branch': 'default'}
-    let [hex, parents, time]=split(a:csdata[line], '-', 1) | let line+=1
+    let [rev, hex, parents, time]=split(a:csdata[line], '-', 1) | let line+=1
     let cs.hex=hex
     let cs.parents=split(parents)
     let cs.time=+time
-    let aname=a:csdata[line]                               | let line+=1
-    let aemail=a:csdata[line]                              | let line+=1
+    let cs.rev=rev
+    let aname=a:csdata[line]                                    | let line+=1
+    let aemail=a:csdata[line]                                   | let line+=1
     let cs.user=aname.' <'.aemail.'>'
-    let cs.tags=split(a:csdata[line][2:-2], ', ')          | let line+=1
+    let cs.tags=split(a:csdata[line][2:-2], ', ')               | let line+=1
     let cs.bookmarks=[]
-    let cs.rev=cs.hex[:5]
     "▶2 get description
     let description=[]
     while a:csdata[line][0] is# ' '
 function s:git.repo(path)
     let repo={'path': a:path, 'changesets': {}, 'cslist': [],
                 \'local': (stridx(a:path, '://')==-1),
-                \'labeltypes': ['tag', 'branch'],}
+                \'labeltypes': ['tag', 'branch'],
+                \'hasrevisions': 0}
     return repo
 endfunction
 "▶1 git.checkdir :: dir → Bool

File plugin/aurum/log.vim

 endfunction
 "▶2 glog.graphlog
 function s:F.glog.graphlog(repo, opts, css)
-    let a:opts.repo=a:repo
     if get(a:repo, 'requires_sort', 1)
         let css=s:F.glog.sort_in_topological_order(a:repo, a:css)
     else
 "▶1 temp
 "▶2 s:templates
 let s:templates={
-            \'default': "Changeset $rev:$hex$branch#hide,pref: (branch ,suf:)#\n".
+            \'default': "Changeset $rev#suf:\:#$hex$branch#hide,pref: (branch ,suf:)#\n".
             \           "Commited $time by $user\n".
             \           "Tags: $tags\n".
             \           "Bookmarks: $bookmarks\n".
             \           "$hide#$#$stat\n".
             \           "$hide#:#$patch\n".
             \           "$empty",
-            \'hgdef':   "changeset:   $rev:$hex\n".
+            \'hgdef':   "changeset:   $rev#suf:\:#$hex\n".
             \           "branch:      $branch\n".
             \           "tags:        $tags\n".
             \           "bookmarks:   $bookmarks\n".
             \           "$hide#$#$stat\n".
             \           "$hide#:#$patch\n".
             \           "$empty",
-            \'hgdescr': "changeset:   $rev:$hex\n".
+            \'hgdescr': "changeset:   $rev#suf:\:#$hex\n".
             \           "branch:      $branch\n".
             \           "tags:        $tags\n".
             \           "bookmarks:   $bookmarks\n".
 let s:kwexpr.hex         = [0, '@@@']
 let s:kwexpr.branch      = [0, '@@@', 'keep']
 let s:kwexpr.user        = [0, '@@@']
-let s:kwexpr.rev         = [0, 'string(@@@)']
+let s:kwexpr.rev         = [0, '@@@', 'ignore']
 let s:kwexpr.time        = [0, 'strftime(@0@, @@@)', '%d %b %Y %H:%M']
 let s:kwexpr.parents     = [0, 'join(@@@)']
 let s:kwexpr.children    = [0, 'join(@@@)']
     if hasfiles
         let func+=['let files=a:opts.csfiles[a:cs.hex]']
     endif
+    let hasrevisions=get(a:opts.repo, 'hasrevisions', 1)
     if get(a:opts, 'patch', 0) || get(a:opts, 'stat', 0)
         let filesarg=((hasfiles && !has_key(a:opts.ignorefiles, 'patch'))?
                     \   ('files'):
             elseif kw is# 'branch'
                 let addedif=1
                 let func+=['if a:cs.branch isnot# "default"']
+            elseif kw is# 'rev' && !hasrevisions
+                continue
             endif
             let func+=['let special.'.meta[0][0].'_l=[len(text), 0]']
         elseif !lmeta
         endif
         "▲3
         let func+=['let text+=[""]']
-        let i=0
+        let i=-1
         for str in lit
+            let i+=1
             if !empty(str)
                 let func+=['let text[-1].='.string(str)]
             endif
             if lmeta>i
+                "▶3 Define variables
                 let [kw, arg]=meta[i]
                 let ke=s:kwexpr[kw]
+                "▶3 Get expression
                 if has_key(arg, 'expr')
                     let expr=arg.expr
                 else
                     let expr=ke[1]
                 endif
-                "▶3 Determine what should be used as {word} argument
+                "▶4 Determine what should be used as {word} argument
                 if has_key(s:kwmarg, kw)
                     let marg=s:kwmarg[kw]
                 elseif hasfiles && (kw is# 'files' || kw is# 'changes') &&
                 else
                     let marg='a:cs.'.kw
                 endif
-                "▲3
+                "▲4
                 let expr=substitute(expr, '@@@', marg, 'g')
                 "▶3 Get positional parameters if required
                 let j=0
                                 \       escape(string(s), '&~\'), 'g')
                     let j+=1
                 endfor
+                "▶3 Skip meta if required
+                " XXX When adding more rules do not forget about addedif
+                if kw is# 'rev' && !hasrevisions && arg.0 isnot# 'keep'
+                    continue
+                endif
                 "▶3 Add complex multiline statement
                 if ke[0]==2
                     let expr=substitute(expr, '@<@', 'lstr', 'g')
                         let condition='!empty(estr)'
                     elseif kw is# 'branch'
                         let condition='estr isnot# "default"'
+                    elseif kw is# 'rev'
+                        let condition=0
                     endif
                     if exists('condition')
-                        let addif=(has_key(arg, 'pref') || has_key(arg, 'suf'))
+                        let addif=(condition isnot 0) &&
+                                    \(has_key(arg, 'pref') ||
+                                    \ has_key(arg, 'suf'))
                         if addif
                             let func+=['if '.condition]
                         endif
                 endif
                 "▲3
             endif
-            let i+=1
         endfor
         if addedif
             let func+=['endif']
     "▶3 Define variables
     let r=[]
     let topgroups=[]
+    let hasrevisions=get(a:opts.repo, 'hasrevisions', 1)
     "▲3
     let r+=['syn match auLogFirstLineStart =\v^[^ ]*[@o][^ ]* = '.
                 \'skipwhite nextgroup=']
                 if s:kwexpr[kw][0]
                     let hasmult=1
                 endif
-                if kw is# 'empty'
+                if kw is# 'empty' || (kw is# 'rev' && !hasrevisions &&
+                            \         arg.0 isnot# 'keep')
                     let r[-1]=substitute(r[-1], '\v\w+$', '', '')
                 elseif has_key(arg, 'synreg')
                     call s:F.temp.addgroup(r, nlgroups, 'auLog_'.kw)
                     let r+=['hi def link '.sname.' Ignore']
                     let r+=['syn match '.sname.' /\V'.escape(arg[0], '\/').'/ '.
                                 \'contained nextgroup=']
-                elseif (index(s:kwpempt, kw)!=-1 || kw is# 'branch') &&
+                elseif (index(s:kwpempt, kw)!=-1 || kw is# 'branch' ||
+                            \                       kw is# 'rev') &&
                             \(has_key(arg, 'pref') || has_key(arg, 'suf'))
                     if has_key(arg, 'pref')
-                        call s:F.temp.addgroup(r, nlgroups, 'auLog_'.kw.'_pref,')
+                        call s:F.temp.addgroup(r,nlgroups,'auLog_'.kw.'_pref,')
                         let r+=['syn match auLog_'.kw.'_pref '.
                                     \'/\V'.escape(arg.pref, '\/').'/ '.
                                     \'contained nextgroup=auLog_'.kw]
     else
         let template=s:templates.default
     endif
+    let opts.repo=a:repo
     let bvar.templatelist=s:F.temp.parse(template)
-    let opts.templatefunc=s:F.temp.compile(bvar.templatelist,
-                \                               opts)
+    let opts.templatefunc=s:F.temp.compile(bvar.templatelist, opts)
     "▲2
     let css=a:repo.functions.revrange(a:repo, opts.revs[0], opts.revs[1])
     let text=s:F.glog.graphlog(a:repo, opts, css)

File syntax/aurumlog.vim

 endtry
 
 hi def link auLogSkipBefore_hex    Comment
+hi def link auLog_rev_suf          Comment
 hi def link auLogHexEnd            Comment
 
 hi def link auLogPatchFile         diffFile
     hi auLogSkipBefore_rev ctermfg=DarkYellow  guifg=DarkYellow
     hi auLogHexStart       ctermfg=DarkYellow  guifg=DarkYellow
 endif
-" hi
 
 let b:current_syntax=expand('<sfile>:t:r')