Commits

ZyX_I  committed 7e0d7e2

@aurum/drivers/git: Added renames, copies, changes, files and removes support to rf-setcsprop() (untested)

  • Participants
  • Parent commits bd1be2a

Comments (0)

Files changed (4)

File doc/aurum.txt

 bookmarks    List of bookmarks associated with the cs     *aurum-cs.bookmarks*
 allfiles     List of all files present in the revision     *aurum-cs.allfiles*
 files        List of files present in cs that were modified   *aurum-cs.files*
+removes      List of files that were deleted in cs          *aurum-cs.removes*
 changes      List of files that were modified in cs         *aurum-cs.changes*
-             (unlike |aurum-cs.files| contains removed files)
+             (|aurum-cs.files| + |aurum-cs.removes|)
 renames      Dictionary {newname : oldname}                 *aurum-cs.renames*
 copies       Dictionary {copyname : originname}              *aurum-cs.copies*
 
 |aurum-rf-gettiphex|: Same as |aurum-rf-getworkhex|.
 |aurum-rf-diff|: Options "git", "iblanks", "showfunc" are not supported.
 |aurum-rf-checkdir| does not support bare repositories.
+|aurum-rf-setcsprop|:
+    Is not able to get real renames, copies, changes, files and removes for 
+    merge changesets.
 
 ==============================================================================
 11. Changelog                                                *aurum-changelog*

File plugin/aurum.vim

         endif
     endif
     let url=repo.functions.getrepoprop(repo, 'url')
-    let [dummystr, protocol, user, domain, port, path; dummylst]=
+    let [protocol, user, domain, port, path]=
                 \matchlist(url, '\v^%(([^:]+)\:\/\/)?'.
                 \                  '%(([^@/:]+)\@)?'.
                 \                   '([^/:]*)'.
                 \                  '%(\:(\d+))?'.
-                \                   '(.*)$')
+                \                   '(.*)$')[1:5]
     for [matcher, dict] in s:_f.getoption('hypsites')+repo.hypsites
         if eval(matcher)
             if !has_key(dict, utype)

File plugin/aurum/drivers/git.vim

             \           'in the repository %s: %s',
             \ 'sdifff': 'Failed to get status information '.
             \           'for the repository %s: %s',
+            \ 'rdifff': 'Failed to property %s for changeset %s '.
+            \           'in the repository %s: %s',
             \    'lsf': 'Failed to list files in the changeset %s '.
             \           'of the repository %s: %s',
             \'statusf': 'Failed to obtain status of the repository %s: %s',
     return a:repo.functions.getrevhex(a:repo, 'HEAD')
 endfunction
 "▶1 git.gettiphex
-" XXX Use working directory revision instead of latest revision
+" XXX Uses working directory revision instead of latest revision
 let s:git.gettiphex=s:git.getworkhex
-"▶1 git.setcsprop :: repo, cs, prop → propvalue
-function s:git.setcsprop(repo, cs, propname)
-    if a:propname is# 'allfiles'
+"▶1 git.setcsprop :: repo, cs, propname → propvalue
+function s:git.setcsprop(repo, cs, prop)
+    if a:prop is# 'allfiles'
         let r=map(s:F.git(a:repo, 'ls-tree', ['--', a:cs.hex],
                     \                        {'name-only': 1, 'r': 1}, 0,
                     \     'lsf', a:cs.hex)[:-2], 's:F.refile(v:val)')
-    elseif a:propname is# 'children'
+    elseif a:prop is# 'children'
         let lines=filter(map(s:F.git(a:repo, 'rev-list', [], {'all': 1,
                     \                                'full-history': 1,
                     \                                    'children': 1}, 0,
             let a:repo.changesets[hex].children=children
         endfor
         return a:cs.children
+    elseif       a:prop is# 'renames' || a:prop is# 'copies' ||
+                \a:prop is# 'changes' || a:prop is# 'files'  ||
+                \a:prop is# 'removes'
+        let lparents=len(a:cs.parents)
+        if lparents==0
+            let allfiles=a:repo.functions.getcsprop(a:repo, a:cs, 'allfiles')
+            let a:cs.renames={}
+            let a:cs.copies={}
+            let a:cs.changes=copy(allfiles)
+            let a:cs.files=copy(a:cs.changes)
+            let a:cs.removes=[]
+        elseif lparents==1
+            let args=[a:cs.parents[0].'..'.a:cs.hex]
+            let kwargs={'name-status': 1, 'M': 1, 'diff-filter': 'ADMR'}
+            if a:prop is# 'copies'
+                let kwargs.C=1
+                let kwargs['find-copies-harder']=1
+                let kwargs['diff-filter'].='C'
+            endif
+            let d=map(s:F.git(a:repo, 'diff', args, kwargs, 'rdifff', a:prop,
+                        \     a:cs.hex)[:-2], 'split(v:val, "\t")')
+            if a:prop is# 'copies'
+                let a:cs.copies={}
+            endif
+            let a:cs.renames={}
+            let a:cs.files=[]
+            let a:cs.removes=[]
+            for [status; files] in d
+                call map(files, 's:F.refile(v:val)')
+                if status[0] is# 'M' || status[0] is# 'A'
+                    let a:cs.files+=[files[0]]
+                elseif status[0] is# 'D'
+                    let a:cs.removes+=[files[0]]
+                elseif status[0] is# 'R'
+                    let a:cs.renames[files[1]]=files[0]
+                elseif status[0] is# 'C'
+                    let a:cs.copies[files[1]]=files[0]
+                endif
+            endfor
+            let a:cs.changes=a:cs.files+a:cs.removes
+        elseif lparents==2
+            " FIXME Here must be files that had merge conflicts
+            let a:cs.renames={}
+            let a:cs.copies={}
+            let a:cs.changes=[]
+            let a:cs.files=[]
+            let a:cs.removes=[]
+        endif
     endif
-    " TODO renames, copies
-    let a:cs[a:propname]=r
+    let a:cs[a:prop]=r
     return r
 endfunction
 "▶1 git.readfile :: repo, rev, file → [String]

File plugin/aurum/drivers/mercurial.vim

 endif
 "▶1 hg.setcsprop :: repo, cs, propname → a
 if s:usepythondriver "▶2
-function s:hg.setcsprop(repo, cs, propname)
+function s:hg.setcsprop(repo, cs, prop)
     try
         execute s:_r.py.cmd 'aurum.get_cs_prop(vim.eval("a:repo.path"), '.
                     \                         'vim.eval("a:cs.hex"), '.
-                    \                         'vim.eval("a:propname"))'
+                    \                         'vim.eval("a:prop"))'
     endtry
 endfunction
 else "▶2
-function s:hg.setcsprop(repo, cs, propname)
-    if a:propname is# 'allfiles'
+function s:hg.setcsprop(repo, cs, prop)
+    if a:prop 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# 'children'
+                    \'csp', a:prop, a:cs.rev)[:-2]
+    elseif a:prop is# 'children'
         " XXX str2nr('123:1f6de') will return number 123
         let r=map(split(s:F.hg(a:repo, 'log -r '.a:cs.rev.' --template '.
                     \                       shellescape('{children}'), 0,
-                    \          'csp', a:propname, a:cs.rev)[0]),
+                    \          'csp', a:prop, a:cs.rev)[0]),
                     \    'str2nr(v:val)')
         if empty(a:repo.cslist)
             call map(r, 'a:repo.functions.getrevhex(a:repo, v:val)')
             call map(r, 'a:repo.cslist[v:val].hex')
         endif
     endif
-    let a:cs[a:propname]=r
+    let a:cs[a:prop]=r
     return r
 endfunction
 endif