ZyX_I avatar ZyX_I committed 52b46bd

@%aurum/log/templates: Added $tags_, $bookmarks_, $parents_ and $children_ template words
Fixed $files and $changes in case they are not the only template words on the line

Comments (0)

Files changed (5)

autoload/aurum/log/templates.vim

             \           "$empty",
             \'hgdef':   "changeset:   $rev#suf:\:#$hex\n".
             \           "branch:      $branch\n".
-            \           "tags:        $tags\n".
-            \           "bookmarks:   $bookmarks\n".
+            \           "tag:         $tags_\n".
+            \           "bookmark:    $bookmarks_\n".
             \           "user:        $user\n".
             \           "date:        $time#%a %b %d %H:%M:%S %Y#\n".
             \           "files:       $changes# #\n".
             \           "$empty",
             \'hgdescr': "changeset:   $rev#suf:\:#$hex\n".
             \           "branch:      $branch\n".
-            \           "tags:        $tags\n".
-            \           "bookmarks:   $bookmarks\n".
+            \           "tag:         $tags_\n".
+            \           "bookmark:    $bookmarks_\n".
             \           "user:        $user\n".
             \           "date:        $time#%a %b %d %H:%M:%S %Y#\n".
             \           "files:       $changes# #\n".
 " TODO Add tab expansion
 let s:kwexpr.description = [1, 'split(@@@, "\n")']
 let s:kwexpr.patch       = [1, '@@@']
+let s:kwexpr.parents_    = [1, '@@@']
+let s:kwexpr.children_   = [1, '@@@']
+let s:kwexpr.tags_       = [1, '@@@']
+let s:kwexpr.bookmarks_  = [1, '@@@']
 let s:kwexpr.stat        = [2, 's:F.stat(@@@, @.@.files, @<@)']
 let s:kwexpr.files       = [2, 's:F.multlfmt(@@@, @.@.files, '.
             \                                    '@<@, @0@, '.
             \                                   '@<@, @0@)', ' to ']
 let s:kwmarg={}
 let s:kwmarg.summary='matchstr(@.@.description, "\\\\v^[^\\n]*")'
-let s:kwmarg.stat='a:repo.functions.getstats(a:repo, diff, a:opts)'
+let s:kwmarg.stat='@:@.functions.getstats(@:@, diff, @o@)'
 let s:kwmarg.patch='diff'
 let s:kwmarg.empty=''''''
 let s:kwpempt=['parents', 'children', 'tags', 'bookmarks']
+let s:kwpemptml=['parents_', 'children_', 'tags_', 'bookmarks_',
+            \    'files', 'changes']
 let s:kwreg={
             \'phase': '\v(public|draft|secret)',
         \}
 let s:kwreqseqkw=['hex', 'branch', 'user', 'rev', 'time', 'parents', 'children',
             \     'tags', 'bookmarks', 'description', 'files', 'changes',
-            \     'phase']
+            \     'phase', 'parents_', 'children_', 'tags_', 'bookmarks_']
 let s:kwreqs = {'stat': {'files': 1},
             \'renames': {'files': 1, 'renames': 1},
             \ 'copies': {'files': 1, 'copies': 1},
             \}
-call map(s:kwreqseqkw, 'extend(s:kwreqs, {v:val : {v:val : 1}})')
+call map(s:kwreqseqkw, 'extend(s:kwreqs, {v:val : {substitute(v:val, "_$", "", "") : 1}})')
 unlet s:kwreqseqkw
 "▶1 beatycode       :: function::[String] → function::[String]
 let s:indents={
         let func+=['if exists("diff")']
     endif
     "▲3
-    let func+=['let ntext='.a:expr,
+    let func+=['let ntext=copy('.a:expr.')',
                 \'call map(ntext, "lstr.v:val")']+
                 \   (has_key(a:arg, 'flbeg')?
                 \       ['let ntext[0]='.string(a:arg.flbeg).
         elseif lkw is# 'patch' || lkw is# 'stat'
             let addedif=1
             let func+=['if exists("diff")']
-        elseif lkw is# 'files' || lkw is# 'changes'
+        elseif index(s:kwpemptml, lkw)!=-1
             let addedif=1
-            let func+=['if !empty(a:cs.'.kw.')']
+            let func+=['if !empty(a:cs.'.substitute(lkw, '_$', '', '').')']
         elseif lkw is# 'renames' || lkw is# 'copies'
             let addedif=1
             let func+=['if !empty(filter(values(a:cs.'.lkw.'), '.
                     let marg='filter(copy(a:cs.'.kw.'), '.
                                 \   '"index(files, v:val)!=-1")'
                 else
-                    let marg='a:cs.'.kw
+                    let marg='a:cs.'.substitute(kw, '_$', '', '')
                 endif
                 "▲3
-                let expr=substitute(substitute(substitute(expr,
+                let expr=substitute(substitute(substitute(substitute(
+                            \substitute(expr,
                             \'\V@@@', marg,      'g'),
                             \'\V@.@', 'a:cs',    'g'),
+                            \'\V@:@', 'a:repo',  'g'),
+                            \'\V@o@', 'a:opts',  'g'),
                             \'\V@-@', 'a:width', 'g')
                 "▶2 Process positional parameters
                 for j in range(len(ke)-2)
 flbeg      For multiline template strings: determine what string should be 
            prepended to the first line.
 expr       Use this expression instead of default to get resulting string. 
-           Inside an expression “@@@” refers to original data, “@N@” - to Nth 
-           positional parameter (count starts from zero), “@-@” - to number of 
-           leading columns taken by graph lines, “@.@” - to current 
-           |aurum-changeset| object, “@<@” - to string that should be 
-           prepended to every line (valid for complex multiline template 
-           strings).
+           Inside an expression
+           String  What it refers to ~
+           @@@     original data
+           @N@     Nth positional parameter (count starts from zero)
+           @-@     number of leading colums taken by graph lines
+           @.@     current |aurum-changeset| object
+           @:@     current |aurum-repository| object
+           @o@     current options dictionary
+           @<@     (for complex multiline statement only) string that should 
+                   be prepended to every line
 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: rev, parents, children, 
 parents, children
              List of space-separated hashes designating parents or children of 
              current changeset.
+parents_, children_
+             List of hashes designating parents or children of current 
+             changeset, each on its own line.
 tags, bookmarks
              List of tags or bookmarks separated by the first positional 
              parameter (default value: ", ").
+tags_, bookmarks_
+             List of tags or bookmarks, each on its own line.
 summary      First line of description.
 description  (multiline) Description of a changeset.
 patch        (multiline) Differences introduced by processed changeset. Not 
     Style that mimics default “hg log” style: >
       changeset:   1:454ae580ce74
       branch:      A
-      tags:        tip
+      tag:         tip
       user:        Bob <bob@example.com>
       date:        Sun Jan 01 00:00:00 2011
       files:       foo/bar.txt foo/barbaz.txt foo/baz.txt
     controlled by other |:AuLog| options): >
       changeset:   1:454ae580ce74
       branch:      A
-      tags:        tip
+      tag:         tip
       user:        Bob <bob@example.com>
       date:        Sun Jan 01 00:00:00 2011
       files:       foo/bar.txt foo/barbaz.txt foo/baz.txt

test/cmd-log-styles.ok

 |  
 {{{1 hgdef
 @  changeset:   26:504f74154456dbb0e9441326514e42ce66279e62
-|  tags:        tip
+|  tag:         tip
 |  user:        A <a@example.com>
 |  date:        Mon Feb 11 05:43:00 2002
 |  files:       .hgignore directory/file
 | | | | |    
 | +-----o  changeset:   12:023aa55bd8062179ce36adbdd78363e9b88718c1
 | | | |    branch:      C
-| | | |    tags:        clines, oldtag
+| | | |    tag:         clines
+| | | |    tag:         oldtag
 | | | |    user:        B <b@example.org>
 | | | |    date:        Thu Feb 01 14:56:00 2001
 | | | |    files:       clines.lst
 | | | |    
 | o | |  changeset:   10:c4110a066208167dae46b08f4e0d8d2b37e842f3
 | | | |  branch:      C
-| | | |  tags:        blines
+| | | |  tag:         blines
 | | | |  user:        A <a@example.com>
 | | | |  date:        Thu Feb 01 05:18:00 2001
 | | | |  files:       blines.lst
 | | | |    
 | o---+  changeset:   7:c06107b7bcbe751d2dd40faf4179ee7d6aac44ac
 |   | |  branch:      C
-|  / /   tags:        ablines
+|  / /   tag:         ablines
 | | |    user:        B <b@example.org>
 | | |    date:        Thu Nov 02 14:13:00 2000
 | | |    files:       ablines.lst
 |  
 {{{1 hgdescr
 @  changeset:   26:504f74154456dbb0e9441326514e42ce66279e62
-|  tags:        tip
+|  tag:         tip
 |  user:        A <a@example.com>
 |  date:        Mon Feb 11 05:43:00 2002
 |  files:       .hgignore directory/file
 | | | | |    
 | +-----o  changeset:   12:023aa55bd8062179ce36adbdd78363e9b88718c1
 | | | |    branch:      C
-| | | |    tags:        clines, oldtag
+| | | |    tag:         clines
+| | | |    tag:         oldtag
 | | | |    user:        B <b@example.org>
 | | | |    date:        Thu Feb 01 14:56:00 2001
 | | | |    files:       clines.lst
 | | | |    
 | o | |  changeset:   10:c4110a066208167dae46b08f4e0d8d2b37e842f3
 | | | |  branch:      C
-| | | |  tags:        blines
+| | | |  tag:         blines
 | | | |  user:        A <a@example.com>
 | | | |  date:        Thu Feb 01 05:18:00 2001
 | | | |  files:       blines.lst
 | | | |    
 | o---+  changeset:   7:c06107b7bcbe751d2dd40faf4179ee7d6aac44ac
 |   | |  branch:      C
-|  / /   tags:        ablines
+|  / /   tag:         ablines
 | | |    user:        B <b@example.org>
 | | |    date:        Thu Nov 02 14:13:00 2000
 | | |    files:       ablines.lst

test/cmd-log-templates.in

 :ST $summary
 :ST $rev: $description-
 :ST $patch
+:ST parent: $parents_
+:ST child: $children_
+:ST tag: $tags_
 :ST $rev: $stat
 :ST $files
 :ST $files#;;#

test/cmd-log-templates.ok

 |  +)
 |  +tar cJf testrepo.tar.xz testrepo
 |  
+{{{1 parent: $parents_
+@  parent: d8140c0b7b0b670bafe0891bcf0c4582092de884
+|  
+o    parent: e021c634413b240b8c834a85200acc28d645f1f1
+|\   parent: e1eaeea486e48634588c778fd36a81ac5c8869a6
+o |  parent: 5afd628b0861f6447ed813895d5ced58a1c42a72
+| |  
+| o  parent: 5afd628b0861f6447ed813895d5ced58a1c42a72
+|/   
+o  parent: e85aa09aab1621b59b8be37f723410b219c8599c
+|  
+o  parent: 67cf252de26b12da6769114cc89b793357f5a46a
+|  
+o  parent: 456e0b05b81af4f332405336f11df4769ec9f250
+|  
+o  parent: f44a21859e57e4abc6155da804d08dd5069e798e
+|  
+o  parent: e5648a3eea574f3fc03709b4fdd799a38f649edd
+|  
+o    parent: 462a1e95be86f96aaf6d7360f6f770826c3eb641
+|\   parent: be92227e3e43f4e7402408afe110098d209d2568
+o \    parent: 269399222040415b3928a316f5d28792cc0be4dd
+|\ \   parent: c4110a066208167dae46b08f4e0d8d2b37e842f3
+| | o    parent: 5e2f73d0c01dfb8ee0d3577e03d016a5f6df58b1
+| | |\   parent: 023aa55bd8062179ce36adbdd78363e9b88718c1
+| | o \    parent: d760b0fe4fe45adf585f5030181b8081899e26a9
+| | |\ \   parent: 9fe0c28c3e1dd175e8372b742f13cbb7bd6799fe
+| | | | | o  parent: 023aa55bd8062179ce36adbdd78363e9b88718c1
+| | | | |/   
+| +-----o  parent: c4110a066208167dae46b08f4e0d8d2b37e842f3
+| | | |    
+| +-----o  parent: c4110a066208167dae46b08f4e0d8d2b37e842f3
+| | | |    
+| o | |  parent: 250ba7cd831ee91c3ba5bef1faebc38c5dbca5f8
+| | | |  
+o | | |    parent: 7e16e7cbaf9ec5b0e65832bc6f057ba825c38cac
+|\ \ \ \   parent: c06107b7bcbe751d2dd40faf4179ee7d6aac44ac
+| | o | |  parent: c06107b7bcbe751d2dd40faf4179ee7d6aac44ac
+| |/ / /   
+| o---+  parent: 9fe0c28c3e1dd175e8372b742f13cbb7bd6799fe
+|  / /   
+| | o  parent: d760b0fe4fe45adf585f5030181b8081899e26a9
+| |/   
+| o  parent: 7e16e7cbaf9ec5b0e65832bc6f057ba825c38cac
+|/   
+o  parent: a16a47a8d7aafc115651bfee6f1202093765365d
+|  
+o  parent: 5a6a1bf999fad1f4547eeb887af54f31d11833f2
+|  
+o  parent: dfe39aa48c6ddde158e42217548b531a45ff66e9
+|  
+o  parent: 99ea42d70fbe32af955de907352999b1d94bef5f
+|  
+o  parent: 0000000000000000000000000000000000000000
+|  
+{{{1 child: $children_
+@  
+|  
+o    child: 504f74154456dbb0e9441326514e42ce66279e62
+|\   
+o |  child: d8140c0b7b0b670bafe0891bcf0c4582092de884
+| |  
+| o  child: d8140c0b7b0b670bafe0891bcf0c4582092de884
+|/   
+o  child: e1eaeea486e48634588c778fd36a81ac5c8869a6
+|  child: e021c634413b240b8c834a85200acc28d645f1f1
+o  child: 5afd628b0861f6447ed813895d5ced58a1c42a72
+|  
+o  child: e85aa09aab1621b59b8be37f723410b219c8599c
+|  
+o  child: 67cf252de26b12da6769114cc89b793357f5a46a
+|  
+o  child: 456e0b05b81af4f332405336f11df4769ec9f250
+|  
+o    child: f44a21859e57e4abc6155da804d08dd5069e798e
+|\   
+o \    child: e5648a3eea574f3fc03709b4fdd799a38f649edd
+|\ \   
+| | o    child: e5648a3eea574f3fc03709b4fdd799a38f649edd
+| | |\   
+| | o \    child: be92227e3e43f4e7402408afe110098d209d2568
+| | |\ \   
+| | | | | o  
+| | | | |/   
+| +-----o  child: 14b19ea42f824c8597f8358149c5ba994299a410
+| | | |    child: be92227e3e43f4e7402408afe110098d209d2568
+| +-----o  
+| | | |    
+| o | |  child: 0e6e0adf281b423193f9dce097ab1df4f91215f7
+| | | |  child: 023aa55bd8062179ce36adbdd78363e9b88718c1
+| | | |  child: 462a1e95be86f96aaf6d7360f6f770826c3eb641
+o | | |    child: 462a1e95be86f96aaf6d7360f6f770826c3eb641
+|\ \ \ \   
+| | o | |  child: c4110a066208167dae46b08f4e0d8d2b37e842f3
+| |/ / /   
+| o---+  child: 250ba7cd831ee91c3ba5bef1faebc38c5dbca5f8
+|  / /   child: 269399222040415b3928a316f5d28792cc0be4dd
+| | o  child: c06107b7bcbe751d2dd40faf4179ee7d6aac44ac
+| |/   child: 5e2f73d0c01dfb8ee0d3577e03d016a5f6df58b1
+| o  child: 9fe0c28c3e1dd175e8372b742f13cbb7bd6799fe
+|/   child: 5e2f73d0c01dfb8ee0d3577e03d016a5f6df58b1
+o  child: d760b0fe4fe45adf585f5030181b8081899e26a9
+|  child: 269399222040415b3928a316f5d28792cc0be4dd
+o  child: 7e16e7cbaf9ec5b0e65832bc6f057ba825c38cac
+|  
+o  child: a16a47a8d7aafc115651bfee6f1202093765365d
+|  
+o  child: 5a6a1bf999fad1f4547eeb887af54f31d11833f2
+|  
+o  child: dfe39aa48c6ddde158e42217548b531a45ff66e9
+|  
+{{{1 tag: $tags_
+@  tag: tip
+|  
+o    
+|\   
+o |  
+| |  
+| o  
+|/   
+o  
+|  
+o  
+|  
+o  
+|  
+o  
+|  
+o  
+|  
+o    
+|\   
+o \    
+|\ \   
+| | o    
+| | |\   
+| | o \    
+| | |\ \   
+| | | | | o  
+| | | | |/   
+| +-----o  tag: clines
+| | | |    tag: oldtag
+| +-----o  
+| | | |    
+| o | |  tag: blines
+| | | |  
+o | | |    
+|\ \ \ \   
+| | o | |  
+| |/ / /   
+| o---+  tag: ablines
+|  / /   
+| | o  
+| |/   
+| o  
+|/   
+o  
+|  
+o  
+|  
+o  
+|  
+o  
+|  
+o  
+|  
 {{{1 $rev: $stat
 @  26:   .hgignore      | 2 0
 |  26:   directory/file | 1 0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.