ZyX_I avatar ZyX_I committed eb504ff Merge

Merge

Comments (0)

Files changed (7)

 0af55424c6d5448a4f8e476143a9182668fa33c4 release-1.6
 420f07edccd368c7318135e6c9a2f24ff6c2b2b3 release-1.7
 e6479282431814964374e9d49cb07a00df58b021 release-1.7.1
+1dd11a73ae6e2e43448a02482f202be05111f92d release-1.8

aurum-addon-info.txt

 {
     "name": "aurum",
-    "version": "1.7.1",
+    "version": "1.8",
     "author": "ZyX <kp-pav@yandex.ru>",
     "maintainer": "ZyX <kp-pav@yandex.ru>",
     "description": "Plugin for dealing with source files under various VCS control",

autoload/aurum/drivers/subversion.vim

 "▶1
 scriptencoding utf-8
 execute frawor#Setup('0.1', {'@%aurum/drivers/common/hypsites': '0.0',
-            \                                   '@%aurum/repo': '5.0',
+            \                                   '@%aurum/repo': '5.8',
             \                   '@%aurum/drivers/common/utils': '1.1',
             \                     '@%aurum/drivers/common/xml': '0.0',
             \                                           '@/os': '0.0',
 function s:svn.getwork(repo)
     return a:repo.functions.getcs(a:repo, 'BASE')
 endfunction
-"▶1 svn.getnthparent :: repo, rev, n → cs
-function s:svn.getnthparent(repo, rev, n)
-    let rev=a:repo.functions.getrevhex(a:repo, a:rev)-a:n
-    if a:n<0 && rev<=0
-        let rev=0
-    elseif a:n>0
-        let tiprev=+a:repo.functions.gettiphex(a:repo)
-        if rev>tiprev
-            let rev=tiprev
-        endif
+"▶1 svn.getnthchangerev :: repo, rev, n, [ file ] → (cs, [ file ])
+function s:svn.getnthchangerev(repo, rev, n, files)
+    " TODO Do not download all changesets
+    if empty(a:repo.mutable.cslist)
+        call a:repo.functions.getchangesets(a:repo)
+    else
+        call a:repo.functions.updatechangesets(a:repo)
     endif
-    return a:repo.functions.getcs(a:repo, rev)
+    return s:_r.repo.defaultfuncs.getnthchangerev(a:repo, a:rev, a:n, a:files)
 endfunction
-"▶1 getchangesets :: repo → [cs]
+"▶1 getchangesets :: repo[, hex[, hex]|limit] → [cs]
 function s:F.getchangesets(repo, ...)
     let args=['--', a:repo.svnroot]
     let kwargs={'xml': 1, 'verbose': 1}
         call xml.skipctag()
         call xml.skipws()
         let a:repo.changesets[cs.hex]=cs
-        call insert(cslist, cs)
+        if !empty(cslist)
+            let cs.children=[cslist[-1].hex]
+            let cslist[-1].parents=[cs.hex]
+        endif
+        call add(cslist, cs)
     endwhile
+    if !has_key(kwargs, 'revision')
+        call reverse(cslist)
+    endif
     return cslist
 endfunction
 "▶1 svn.getchangesets :: repo → [cs]
             call remove(a:repo.mutable.cslist, -1)
         endwhile
     elseif tiprev>oldtiprev
-        let cslist=s:F.getchangesets(a:repo, ''.oldtiprev, ''.tiprev)
+        let cslist=s:F.getchangesets(a:repo, ''.(oldtiprev+1), ''.tiprev)
         if !empty(cslist)
-            let a:repo.mutable.cslist[-1].children=
-                        \''.(a:repo.mutable.cslist[-1].rev+1)
-            call map(cslist[:-2], 'extend(v:val, {"children": '.
-                        \                                '["".(v:val.rev-1)]})')
+            let a:repo.mutable.cslist[-1].children=[cslist[0].hex]
+            let cslist[0].parents=[a:repo.mutable.cslist[-1].hex]
             let a:repo.mutable.cslist+=cslist
         endif
     endif
         endif
     "▶2 Not so complicated case: cs and its parent or itself
     elseif a:0>1 && !empty(a:1) && !empty(a:2) && a:1.a:2!~#'\D' &&
-                \abs(a:1-a:2)<=1
+                \(abs(a:1-a:2)<=1 || (has_key(a:repo.changesets, a:1) &&
+                \                     index(a:repo.changesets[a:1].parents+
+                \                           a:repo.changesets[a:1].children,
+                \                           a:2)!=-1) ||
+                \                    (has_key(a:repo.changesets, a:2) &&
+                \                     index(a:repo.changesets[a:2].parents+
+                \                           a:repo.changesets[a:2].children,
+                \                           a:1)!=-1))
         let r=copy(s:_r.utils.emptystatdct)
         if requiresclean
             let allfiles=copy(a:repo.functions.getcsprop(a:repo,a:1,'allfiles'))
                 call filter(allfiles, 'index(a:3, v:val)!=-1')
             endif
         endif
-        if abs(a:1-a:2)==1
-            let reverse=(a:2<a:1)
-            let s=a:repo.functions.getcs(a:repo, ''.max([+a:1, +a:2])).status
-            if a:0>2 && !empty(a:3)
-                call map(copy(s), 'filter(copy(v:val), "index(a:3,v:val)!=-1")')
-            endif
+        let reverse=(a:2<a:1)
+        let s=a:repo.functions.getcs(a:repo, ''.max([+a:1, +a:2])).status
+        if a:0>2 && !empty(a:3)
+            let s=map(deepcopy(s), 'filter(v:val, "index(a:3,v:val)!=-1")')
+        endif
+        if requiresclean
             let revs=s:F.statreverse(s)
-            if requiresclean
-                call filter(allfiles, '!has_key(revs, v:val)')
-            endif
-            call extend(r, s)
-            "▶3 Reversing range
-            if reverse
-                let [r.deleted, r.unknown]=[r.unknown, r.deleted]
-                let [r.added,   r.removed]=[r.removed, r.added  ]
-            endif
-            "▲3
+            call filter(allfiles, '!has_key(revs, v:val)')
         endif
+        call extend(r, s)
+        "▶3 Reversing range
+        if reverse
+            let [r.deleted, r.unknown]=[r.unknown, r.deleted]
+            let [r.added,   r.removed]=[r.removed, r.added  ]
+        endif
+        "▲3
         if requiresclean
             let r.clean=allfiles
         endif

autoload/aurum/maputils.vim

 endfunction
 "▶1 getnthparentfile :: repo, rev, file, n[, changedonly] → (hex, file)
 function s:r.getnthparentfile(repo, rev, file, n, ...)
-    let n=a:n
-    let shift=(n>0 ? 1 : -1)
-    let file=a:file
-    let prevhex=0
-    let hex=a:repo.functions.getrevhex(a:repo, a:rev)
-    while n && hex isnot# prevhex
-        let prevhex=hex
-        let cs=a:repo.functions.getnthparent(a:repo, hex, shift)
-        let rhex=(shift>0 ? hex : cs.hex)
-        if cs.hex is# hex
-            break
-        endif
-        let hex=cs.hex
-        let renames=a:repo.functions.getcsprop(a:repo, rhex, 'renames')
-        if shift<0
-            let rrenames={}
-            call map(copy(renames), 'extend(rrenames, {v:val : v:key})')
-            let renames=rrenames
-        endif
-        let haschanges=get(a:000, 0, 1)
-        if get(renames, file, 0) isnot 0
-            let file=renames[file]
-            let haschanges=1
-        elseif !haschanges
-            let status=a:repo.functions.status(a:repo, prevhex, hex, [a:file])
-            let haschanges=!empty(filter(copy(status),
-                        \              'v:key isnot# "clean" && !empty(v:val)'))
-        endif
-        if haschanges
+    if !a:0 || a:1
+        let n=a:n
+        let shift=(n>0 ? 1 : -1)
+        let file=a:file
+        let prevhex=0
+        let hex=a:repo.functions.getrevhex(a:repo, a:rev)
+        while n && hex isnot# prevhex
+            let prevhex=hex
+            let cs=a:repo.functions.getnthparent(a:repo, hex, shift)
+            let rhex=(shift>0 ? hex : cs.hex)
+            if cs.hex is# hex
+                break
+            endif
+            let hex=cs.hex
+            let renames=a:repo.functions.getcsprop(a:repo, rhex, 'renames')
+            if shift<0
+                let rrenames={}
+                call map(copy(renames), 'extend(rrenames, {v:val : v:key})')
+                let renames=rrenames
+            endif
+            if get(renames, file, 0) isnot 0
+                let file=renames[file]
+            endif
             let n-=shift
-        endif
-    endwhile
-    return [hex, file]
+        endwhile
+        return [hex, file]
+    else
+        let [hex, files]=a:repo.functions.getnthchangerev(a:repo, a:rev, a:n,
+                    \                                     [a:file])
+        return [hex, files[0]]
+    endif
 endfunction
 "▶1 Post maputils resource
 call s:_f.postresource('maputils', s:r)

autoload/aurum/repo.vim

 "▶1
-execute frawor#Setup('5.7', { '@/resources': '0.0',
+execute frawor#Setup('5.9', { '@/resources': '0.0',
             \                        '@/os': '0.0',
             \                   '@/options': '0.0',
             \                    '@/python': '1.0',
     endfor
     return r
 endfunction
+"▶1 getnthchangerev :: repo, rev, n, files → cs
+function s:deffuncs.getnthchangerev(repo, rev, n, files)
+    let n=a:n
+    let shift=(n>0 ? 1 : -1)
+    let files=copy(a:files)
+    let prevhex=0
+    let hex=a:repo.functions.getrevhex(a:repo, a:rev)
+    while n && hex isnot# prevhex
+        let prevhex=hex
+        let cs=a:repo.functions.getnthparent(a:repo, hex, shift)
+        let rhex=(shift>0 ? hex : cs.hex)
+        if cs.hex is# hex
+            break
+        endif
+        let hex=cs.hex
+        let renames=a:repo.functions.getcsprop(a:repo, rhex, 'renames')
+        if shift<0
+            let rrenames={}
+            call map(copy(renames), 'extend(rrenames, {v:val : v:key})')
+            let renames=rrenames
+        endif
+        let haschanges=0
+        let renamed=map(copy(files), 'get(renames, v:val, v:val)')
+        if renamed !=# files
+            let files=renamed
+            let haschanges=1
+        else
+            let status=a:repo.functions.status(a:repo, prevhex, hex, files)
+            let haschanges=!empty(filter(copy(status),
+                        \              'v:key isnot# "clean" && !empty(v:val)'))
+        endif
+        if haschanges
+            let n-=shift
+        endif
+    endwhile
+    return [hex, files]
+endfunction
 "▶1 getcsprop :: repo, Either cs rev, propname → a
 function s:deffuncs.getcsprop(repo, csr, propname)
     if type(a:csr)==type({})
 endfunction
 "▶1 Post resource
 call s:_f.postresource('repo', {'get': s:F.getrepo,
-            \        'userepeatedcmd': s:userepeatedcmd})
+            \        'userepeatedcmd': s:userepeatedcmd,
+            \          'defaultfuncs': s:deffuncs})
 "▶1 regdriver feature
 let s:requiredfuncs=['repo', 'getcs', 'checkdir']
 let s:optfuncs=['readfile', 'annotate', 'diff', 'status', 'commit', 'update',
     |aurum-cs.hex|.
   getwork :: () -> cs                                       *aurum-rf-getwork*
     Get changeset object for the working directory revision.
-  getnthparent :: hex, n -> cs                         *aurum-rf-getnthparent*
+  getnthparent :: hex, n[, [ file ]] -> cs             *aurum-rf-getnthparent*
     Get nth generation grand-parent of given revision. Use negative n to get 
     nth generation child instead. With n equal to zero it must work like 
     |aurum-rf-getcs|(hex).
+                                                    *aurum-rf-getnthchangerev*
+  getnthchangerev :: hex, n, [ file ] -> (cs, [ file ])
+    Like above, but with two differences:
+    1. Only changesets containing changes to files listed in the fourth 
+       argument are taken into account.
+    2. Returns a pair of |aurum-changeset| object and a list of files. In case 
+       there were no renames returned list is equal to the list given in 
+       arguments, otherwise it returns list with new filenames.
+       Note: copies are ignored.
   getchangesets :: () -> [ cs ]                       *aurum-rf-getchangesets*
     Pull all changesets contained in repository into |aurum-repo.changesets| 
     dictionary. If this function is not called, then |aurum-repo.changesets| 
 |aurum-cs.time| is always 0 if “date” programm from coreutils is missing.
 |aurum-cs.children| is always empty.
 |aurum-cs.phase| is always “unknown”.
-|aurum-rf-getchasgesets|, |aurum-rf-getcs| are unable to work with commits 
+|aurum-rf-getchangesets|, |aurum-rf-getcs| are unable to work with commits 
     where description contains line with two spaces followed by 60 dashes.
 |aurum-rf-updatechangesets| is doing nothing.
 |aurum-rf-getrevhex| calls |aurum-rf-getcs| thus it may be slow.
          |aurum-rf-aget| and |aurum-rf-aremove|.
     5.5: Added |aurum-rf-apause| and |aurum-rf-aresume|.
     5.6: Added |aurum-rf-strip|.
-    5.7: Added |aurum-rf-merge| and |aurum-rf-resolve|.
+    5.7: Now exporting default functions in _r.repo.defaultfuncs
+    5.8: Added |aurum-rf-getnthchangerev|.
+    5.9: Added |aurum-rf-merge| and |aurum-rf-resolve|.
 @aurum:
     0.1: Added |:AuBranch| and |:AuName|.
     0.2: Added |:AuOther|.

test/drivers-subversion.ok

 A ghi
 A mno
 A subdir2/stu
+A subdir/file-2
 A subdir/pqr
-A subdir/file-2
 A .
 A new-file
 M file-under-svn-control
 R ghi
 R mno
 R subdir2/stu
+R subdir/file-2
 R subdir/pqr
-R subdir/file-2
 R .
 R new-file
 {{{1 Status: between two revisions
 M file-under-svn-control
+R def
 R ghi
 R --force
 R subdir/pqr
 R subdir/file-2
 R mno
 R subdir2/stu
-R def
 {{{1 Commit
 o Changeset 10
 | @ Added newfile.vim
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.