Commits

ZyX_I  committed 2e59f51

Fixed log tests for non-python driver
Added cs.copies
Added :AuLog showcopies
Added $copies template key (has known bugs with syntax)

  • Participants
  • Parent commits 8401a42

Comments (0)

Files changed (7)

File doc/aurum.txt

                 modified are shown. It also tracks renames of a file. May be 
                 specified more then once.
                 Note: This option also affects files shown when `stat', 
-                      `patch', `showfiles' and `showrenames' options are 
-                      specified (unless `ignfiles' is also present).
+                      `patch', `showfiles', `showrenames' and `showcopies' 
+                      options are specified (unless `ignfiles' is also 
+                      present).
     date        String of a form y-m-d_H:M where all components except first 
                 are optional. Each of y, m, d, H, M may be either a number, 
                 a dot (meaning put current value here) and a star (meaning 
     template    Variable name. Specifies variable from which template should 
                 be loaded.
                                                            *aurum-lo-ignfiles*
-    ignfiles    One of `patch', `renames', `files'. May be specified more then 
-                once. Overrides |g:aurum_ignorefiles|. Determines when `files' 
-                option will be ignored:
+    ignfiles    One of `patch', `renames', `copies', `files'. May be specified 
+                more then once. Overrides |g:aurum_ignorefiles|. Determines 
+                when `files' option will be ignored:
                   Value    Description ~
                   patch    `patch' and `stat' will always show full changeset 
                            patch or statistics.
                   renames  `showrenames' will always show all renamed files.
+                  copies   `showcopies' will always show all copied files.
                   files    `showfiles' will always show all changed files.
     cmd         Command. Determines which command should be used to open log.
                 Default: `silent new'.
     [no]showfiles
                 Flag. Determines whether list of files changed in given 
                 revision should be shown.
+    [no]showcopies
+                Flag. Determines whether copies should be shown.
     [no]showrenames
                 Flag. Determines whether renames should be shown.
 
     object or changeset hash. `propname' can be a name of any property 
     described in |aurum-changeset| section, but it should be normally used for 
     pulling properties that are not obtained by |aurum-rf-getcs| by default: 
-    `files', `changes', `renames', `allfiles', `chidlren'.
+    `files', `changes', `renames', `copies', `allfiles', `chidlren'.
   getrevhex :: csdescr -> hex                             *aurum-rf-getrevhex*
     Given some changeset description (it may be tag, bookmark, branch name, 
     revision number, ... - whatever VCS supports) get changeset hash.
 changes      List of files that were modified in cs         *aurum-cs.changes*
              (unlike |aurum-cs.files| contains removed files)
 renames      Dictionary {newname : oldname}                 *aurum-cs.renames*
+copies       Dictionary {copyname : originname}              *aurum-cs.copies*
 
 vim: ft=help:tw=78

File plugin/aurum/drivers/mercurial.vim

     endtry
 endfunction
 else "▶3
+"▶4 getrfc :: repo, cs[, _] → _ + cs
+function s:F.getrfc(repo, cs, ...)
+    let slines=s:F.hg(a:repo, 'status --change '.a:cs.rev.' -armC', 0,
+                \     'ren', a:cs.rev)[:-2]
+    let copies={}
+    let removed=[]
+    let addedmodified=[]
+    let prevfile=0
+    for line in slines
+        let s=line[0]
+        let file=line[2:]
+        if s is# ' '
+            let copies[prevfile]=file
+        elseif s is# 'R'
+            let removed+=[file]
+        else
+            let addedmodified+=[file]
+        endif
+        let prevfile=file
+    endfor
+    let a:cs.renames = filter(copy(copies), 'index(removed, v:val)!=-1')
+    let a:cs.copies  = filter(copy(copies), '!has_key(a:cs.renames, v:key)')
+    if len(a:cs.parents)>1
+        " TODO Ask whether merge can have a changed file list
+        let a:cs.files=[]
+        let a:cs.changes=[]
+        let a:cs.removes=[]
+    else
+        let a:cs.files=sort(addedmodified)
+        let a:cs.changes=sort(addedmodified+removed)
+        let a:cs.removes=sort(removed)
+    endif
+    let a:cs.gotrenames=1
+endfunction
+"▲4
 function s:F.setcsprop(repo, cs, propname)
     if a:propname is# 'allfiles'
         let r=s:F.hg(a:repo, 'manifest -r '.a:cs.rev, 0,
                     \'csp', a:propname, a:cs.rev)[:-2]
     elseif a:propname is# 'changes' || a:propname is# 'files'
-        let lines=s:F.hg(a:repo, 'status --change '.a:cs.rev.' -arm', 0,
-                    \    'csp', a:propname, a:cs.rev)[:-2]
-        let a:cs.changes=map(lines, 'v:val[2:]')
-        let a:cs.files=filter(copy(a:cs.changes), 'lines[v:key][0] isnot# "R"')
+        call s:F.getrfc(a:repo, a:cs)
         return a:cs[a:propname]
     elseif a:propname is# 'children'
         " XXX str2nr('123:1f6de') will return number 123
     else
         let cs=a:repo.functions.getcs(a:repo, a:csr)
     endif
-    if a:propname is# 'renames'
+    if a:propname is# 'renames' || a:propname is# 'copies'
         return s:F.renamed(a:repo, cs)
     endif
     if has_key(cs, a:propname)
         return cs
     endif
 endfunction
-"▶1 renamed :: repo, cs[, [file]] → {file : Maybe String}
-"▶2 getrenames :: repo, cs, unkfiles → + cs
-if s:usepythondriver "▶3
-function s:F.getrenames(repo, cs, uknfiles)
+"▶1 renamed :: repo, cs → {file : Maybe String}
+if s:usepythondriver "▶2
+function s:F.renamed(repo, cs)
     try
         execute s:_r.py.cmd 'aurum.get_renames(vim.eval("a:repo.path"), '.
-                    \                         'vim.eval("a:cs.hex"), '.
-                    \                         'vim.eval("a:uknfiles"))'
+                    \                         'vim.eval("a:cs.hex"))'
     endtry
 endfunction
-else "▶3
-function s:F.getrenames(repo, cs, ...)
-    let slines=s:F.hg(a:repo, 'status --change '.a:cs.rev.' -raC', 0,
-                \     'ren', a:cs.rev)[:-2]
-    let copies={}
-    let removed=[]
-    let added=[]
-    let prevfile=0
-    for line in slines
-        let s=line[0]
-        let file=line[2:]
-        if s is# 'A'
-            let added+=[file]
-        elseif s is# 'R'
-            let removed+=[file]
-        else
-            let copies[prevfile]=file
-        endif
-        let prevfile=file
-    endfor
-    let renames=filter(copy(copies), 'index(removed, v:val)!=-1')
-    call extend(a:cs.renames, renames)
-endfunction
+else "▶2
+let s:F.renamed=s:F.getrfc
 endif
-"▲2
-function s:F.renamed(repo, cs, ...)
-    let files=a:repo.functions.getcsprop(a:repo, a:cs, 'files')
-    if a:0
-        let filestoprocess=filter(copy(a:1), 'index(v:val, files)!=-1')
-    else
-        if has_key(a:cs, 'gotrenames')
-            return a:cs.renames
-        endif
-        let filestoprocess=files
-    endif
-    if has_key(a:cs, 'renames')
-        let uknfiles=filter(copy(filestoprocess),'!has_key(a:cs.renames,v:val)')
-    else
-        let a:cs.renames={}
-        let uknfiles=filestoprocess
-    endif
-    if !empty(uknfiles)
-        call s:F.getrenames(a:repo, a:cs, uknfiles)
-    endif
-    if a:0
-        let r={}
-        call map(copy(a:files),
-                    \'extend(r, {v:val : get(a:cs.renames, v:val, -1)})')
-        return r
-    else
-        let a:cs.gotrenames=1
-        return a:cs.renames
-    endif
-endfunction
 "▶1 diffopts :: opts → diffopts
 let s:diffopts={
             \      'git': 'git',

File plugin/aurum/log.vim

 let s:F.temp={}
 let s:_options={
             \'ignorefiles': {'default': [],
-            \                'checker': 'list in [patch renames files]'},
+            \                'checker': 'list in [patch renames copies files]'},
             \'closewindow': {'default': 1, 'filter': 'bool'},
         \}
 let s:_messages={
             \           "Bookmarks: $bookmarks\n".
             \           "Files: $changes\n".
             \           "Renamed $renames\n".
+            \           "Copied $copies\n".
             \           "$hide#@# $description\n".
             \           "$hide#$#$stat\n".
             \           "$hide#:#$patch\n".
             \                                    '"file")', ', ']
 let s:kwexpr.renames     = [2, 's:F.temp.renames(@@@, a:cs.files, '.
             \                                   '@<@, @0@)', ' to ']
+let s:kwexpr.copies      = [2, 's:F.temp.renames(@@@, a:cs.files, '.
+            \                                   '@<@, @0@)', ' to ']
 let s:kwmarg={}
 let s:kwmarg.summary='matchstr(a:cs.description, "\\\\v^[^\\n]*")'
 let s:kwmarg.stat='a:opts.repo.functions.getstats(a:opts.repo, diff, a:opts)'
         if (!get(a:opts, 'showfiles', 0) &&
                     \   (kw is# 'files' || kw is# 'changes')) ||
                     \(!get(a:opts, 'showrenames', 0) && kw is# 'renames') ||
+                    \(!get(a:opts, 'showcopies',  0) && kw is# 'copies')  ||
                     \(!get(a:opts, 'patch',       0) && kw is# 'patch')   ||
                     \(!get(a:opts, 'stat',        0) && kw is# 'stat')
             return 1
 function s:F.temp.compile(template, opts)
     "▶3 Cache
     let cid=''
-    for o in ['patch', 'stat', 'showfiles', 'showrenames']
+    for o in ['patch', 'stat', 'showfiles', 'showrenames', 'showcopies']
         let cid.=get(a:opts, o, 0)
     endfor
     let cid.=has_key(a:opts, 'files')
                 elseif hasfiles && (kw is# 'files' || kw is# 'changes') &&
                             \!has_key(a:opts.ignorefiles, 'files')
                     let marg='files'
-                elseif hasfiles && kw is# 'renames' &&
-                            \!has_key(a:opts.ignorefiles, 'renames')
-                    let marg='filter(copy(a:cs.renames), '.
+                elseif hasfiles && (kw is# 'renames' || kw is# 'copies') &&
+                            \!has_key(a:opts.ignorefiles, kw)
+                    let marg='filter(copy(a:cs.'.kw.'), '.
                                 \   '"index(files, v:val)!=-1")'
                 else
                     let marg='a:cs.'.kw
     endif
     "▲2
     let cslist=bvar.repo.cslist[bvar.opts.revs[0]:bvar.opts.revs[1]]
-    "▶2 Generate cs.renames for `showrenames' option
-    if get(bvar.opts, 'showrenames', 0)
-        for cs in cslist
-            call bvar.repo.functions.getcsprop(bvar.repo, cs, 'renames')
-        endfor
-    endif
+    "▶2 Generate cs.{kw} for `show{kw}' option (kw=renames, copies)
+    for key in ['renames', 'copies']
+        if get(bvar.opts, 'show'.key, 0)
+            for cs in cslist
+                call bvar.repo.functions.getcsprop(bvar.repo, cs, key)
+            endfor
+        endif
+    endfor
     "▶2 Generate cs.files for several options
     if has_key(bvar.opts, 'files') || get(bvar.opts, 'showrenames', 0) ||
+                \                     get(bvar.opts, 'showcopies',  0) ||
                 \                     get(bvar.opts, 'showfiles',   0) ||
                 \                     get(bvar.opts, 'stat',        0)
         for cs in cslist
         let bvar.opts.csfiles={}
         for cs in cslist
             let rns     = bvar.repo.functions.getcsprop(bvar.repo,cs, 'renames')
+            let cps     = bvar.repo.functions.getcsprop(bvar.repo,cs, 'copies' )
             let changes = bvar.repo.functions.getcsprop(bvar.repo,cs, 'changes')
             let changes = copy(changes)
             let csfiles = []
 let s:logfunc['@FWC']=['-onlystrings '.
             \          '['.s:_r.cmdutils.nogetrepoarg.']'.
             \          '{ *?files    (type "")'.
-            \          '  *?ignfiles in [patch renames files] ~start'.
+            \          '  *?ignfiles in [patch renames copies files] ~start'.
             \          '   ?date     match /\v[<>]?\=?'.s:datereg.'|'.
             \                                 s:datereg.'\<\=?\>'.s:datereg.'/'.
             \          '   ?search   isreg'.
             \          '  !?stat'.
             \          '  !?showfiles'.
             \          '  !?showrenames'.
+            \          '  !?showcopies'.
             \          s:_r.repo.diffoptsstr.
             \          '   ?cmd      type ""'.
             \          '}', 'filter']

File python/aurum.py

     except AurumError:
         pass
 
-def get_renames(path, rev, files):
+def get_renames(path, rev):
     def get_renames_value(rename):
         return rename[0] if rename else 0
     try:
         cs=g_cs(g_repo(path), rev)
         renames_vim={}
-        for f in files:
-            renames_vim[f]=get_renames_value(g_fctx(cs, f).renamed())
-        vim.eval('extend(a:cs.renames, '+nonutf_dumps(renames_vim)+')')
+        copies_vim={}
+        for f in cs:
+            fctx=g_fctx(cs, f)
+            rename=get_renames_value(fctx.renamed())
+            if rename:
+                if rename in cs:
+                    copies_vim[f]=rename
+                    renames_vim[f]=0
+                else:
+                    copies_vim[f]=0
+                    renames_vim[f]=rename
+            else:
+                copies_vim[f]=0
+                renames_vim[f]=0
+        vim.eval('extend(a:cs, '+nonutf_dumps({'renames': renames_vim,
+                                                'copies': copies_vim})+')')
     except AurumError:
         pass
 

File test/log-templates.ok

 |  
 o  
 |  
-o  hglines.lst to hglines2.lst
+o  
 |  
 o    
 |\   
 |  
 o  
 |  
-o  hglines.lst->hglines2.lst
+o  
 |  
 o    
 |\   
 :W{{{1 showrenames
 :Run AuLog showrenames
 :bw!
+:W{{{1 showcopies
+:Run AuLog showcopies
+:bw!
 :W{{{1 stat
 :Run AuLog revrange 2 2 stat
 :bw!
 |  
 o  Changeset 18:5b7ed139504a773cacfda7307e92cfba9a602d7f (branch default)
 |  Commited 10 Feb 2002 05:00 by A <a@example.com>
-|  Renamed hglines.lst to hglines2.lst
 |  @ Copied “hglines.lst” to “hglines2.lst”
 |  
 o    Changeset 17:21d58f7d0c8a0b75eb5b27fe97e78690c1a18be8 (branch default)
 |  Commited 02 Jan 1999 05:20 by A <a@example.com>
 |  @ Added «createrepo.zsh»
 |  
+{{{1 showcopies
+@  Changeset 22:54d2db605eec15091bb4b194499d6db40e2af027 (branch default)
+|  Commited 11 Feb 2002 05:43 by A <a@example.com>
+|  Tags: tip
+|  @ Added .hgignore
+|  
+o  Changeset 21:214bbd7a8f1198ea9a78a01edf38a3fa8d2ad2ae (branch default)
+|  Commited 11 Feb 2002 03:15 by A <a@example.com>
+|  @ Added ignored10.lst
+|  
+o  Changeset 20:2c2d8b2b8164681fcc1ea55bf8e086f034ddc70e (branch default)
+|  Commited 10 Feb 2002 16:01 by B <b@example.org>
+|  @ Added nohglinesrev.lst
+|  
+o  Changeset 19:a38ec092ab72534eae6240c4378f4e4da9fb7e74 (branch default)
+|  Commited 10 Feb 2002 15:33 by B <b@example.org>
+|  @ Added nohglines.lst
+|  
+o  Changeset 18:5b7ed139504a773cacfda7307e92cfba9a602d7f (branch default)
+|  Commited 10 Feb 2002 05:00 by A <a@example.com>
+|  Copied hglines.lst to hglines2.lst
+|  @ Copied “hglines.lst” to “hglines2.lst”
+|  
+o    Changeset 17:21d58f7d0c8a0b75eb5b27fe97e78690c1a18be8 (branch default)
+|\   Commited 01 Jan 2002 00:00 by C <c@example.gov>
+| |  @ Merge from A
+| |  
+o |    Changeset 16:90772a14fa550b47e27709d36a7c9efd506ba239 (branch default)
+|\ \   Commited 01 Jan 2002 00:00 by C <c@example.gov>
+| | |  @ Merge from C:1
+| | |  
+| | o    Changeset 15:3ced0ae2c577db232d151d5aca4b64aab1ebcf75 (branch A)
+| | |\   Commited 01 Jan 2002 00:00 by C <c@example.gov>
+| | | |  @ Merge from C:2
+| | | |  
+| | o |    Changeset 14:4f33ce8791eb9481ed5e4e198641d6e69fc11ec0 (branch A)
+| | |\ \   Commited 01 Jan 2002 00:00 by C <c@example.gov>
+| | | | |  @ Merge from B
+| | | | |  
+| | | | | o  Changeset 13:331b232648474c521c7f9d96865421698e8936da (branch C)
+| | | | |/   Commited 01 Feb 2001 14:56 by B <b@example.org>
+| | | | |    @ Added tag clines for changeset c767dffcf34d
+| | | | |    
+| +-----o  Changeset 12:c767dffcf34d1d43e8fb4ec1d4ac83e929c68ccc (branch C)
+| | | |    Commited 01 Feb 2001 14:56 by B <b@example.org>
+| | | |    Tags: clines
+| | | |    @ Added clines.lst
+| | | |    
+| +-----o  Changeset 11:e2b6fb70c2c7d6bd3f1d5bff65a7de6681976743 (branch C)
+| | | |    Commited 01 Feb 2001 05:19 by A <a@example.com>
+| | | |    @ Added tag blines for changeset 235d6a7d7b43
+| | | |    
+| o | |  Changeset 10:235d6a7d7b435cd3452b4c84f74fe9bad4b91a59 (branch C)
+| | | |  Commited 01 Feb 2001 05:18 by A <a@example.com>
+| | | |  Tags: blines
+| | | |  @ Added blines.lst
+| | | |  
+o | | |    Changeset 9:00cf93136629e2fbbca9464205bbd381c0451d23 (branch default)
+|\ \ \ \   Commited 01 Jan 2001 00:00 by C <c@example.gov>
+| | | | |  @ Merge from C
+| | | | |  
+| | o | |  Changeset 8:5c5f63aea57fbe740977648a1315f3369cb43663 (branch C)
+| |/ / /   Commited 02 Nov 2000 14:14 by B <b@example.org>
+| | | |    @ Added tag ablines for changeset 0b4ef1ee673d
+| | | |    
+| o---+  Changeset 7:0b4ef1ee673d958bfa691f07fdbb4369b24904fa (branch C)
+|   | |  Commited 02 Nov 2000 14:13 by B <b@example.org>
+|  / /   Tags: ablines
+| | |    @ Added ablines.lst
+| | |    
+| | o  Changeset 6:5cd1070d0a3933f74c9d34e7f5e515d20931bccc (branch B)
+| |/   Commited 02 Nov 2000 05:44 by A <a@example.com>
+| |    @ Added alines.lst
+| |    
+| o  Changeset 5:4654f8e4bccd8ba0e40479e6ba7f4a61874bbcb6 (branch A)
+|/   Commited 01 Nov 2000 13:24 by B <b@example.org>
+|    @ Added dlines.lst
+|    
+o  Changeset 4:aa37b7dd6c397b16a77b1f405d49828aa6434bb2 (branch default)
+|  Commited 10 May 2000 04:23 by A <a@example.com>
+|  @ Added «hglines.lst» and «datelines.lst»
+|  
+o  Changeset 3:ccf3e1d041800ad99d46dcdec6e12c8a770456f9 (branch default)
+|  Commited 01 Feb 2000 14:00 by B <b@example.org>
+|  @ Renamed «crepo.zsh» to «chgrepo.zsh»
+|  
+o  Changeset 2:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1 (branch default)
+|  Commited 15 Jan 2000 15:00 by B <b@example.org>
+|  @ Replaced
+|  @     (
+|  @         ...
+|  @     )
+|  @ with
+|  @     {
+|  @         ...
+|  @     }
+|  
+o  Changeset 1:fe851681c15eb282a18ab7660f85a677ee1e577c (branch default)
+|  Commited 05 Jan 2000 07:30 by A <a@example.com>
+|  @ Renamed «createrepo.zsh» to «crepo.zsh»
+|  
+o  Changeset 0:00b61a9315e2ecb239feba3bc44b2ef3af4c7dd1 (branch default)
+|  Commited 02 Jan 1999 05:20 by A <a@example.com>
+|  @ Added «createrepo.zsh»
+|  
 {{{1 stat
 o  Changeset 2:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1 (branch default)
 |  Commited 15 Jan 2000 15:00 by B <b@example.org>