Commits

ZyX_I committed 1a30b96

@aurum/drivers/subversion: Added cs.renames and cs.copies support
Fixed cs.{file-related} for the case when local repo root is same as remote one
Fixed diff cache
Fixed rf-status(_, _, _, 0) handling
Fixed rf-update(_, _, 1)
Known issue: rf-getstats is not working
@aurum/drivers/mercurial: Added support for rf-status(_, _, _, _, 0) to non-python driver
Made rf-status(_, _, _, []) mean the same as rf-status(_, _, _, 0) for python driver
tests: Added subversion test
Known issue: rf-status() testing is not full

  • Participants
  • Parent commits fff45ab
  • Branches svnsupport

Comments (0)

Files changed (6)

File plugin/aurum/drivers/mercurial.vim

     endtry
 endfunction
 endif
-"▶1 hg.status :: repo[, rev1[, rev2[, files]]] → {type : [file]}
+"▶1 hg.status :: repo[, rev1[, rev2[, files[, clean]]]] → {type : [file]}
 " type :: "modified" | "added" | "removed" | "deleted" | "unknown" | "ignored"
 "       | "clean"
 if s:usepythondriver "▶2
                 \'removed': 1,
                 \'deleted': 1,
                 \'unknown': 1,
-                \'ignored': 1,
-                \  'clean': 1}
+                \'ignored': 1}
+    if (a:0>3 && a:4)
+        let kwargs.clean=1
+    endif
     let reverse=0
     if a:0
         if a:1 is 0

File plugin/aurum/drivers/subversion.vim

                 call s:_f.throw('perr', 'kind="..."', a:csdata[line])
             endif          "▲3
             let line+=1
+            "▶3 Process copies
+            let source=matchstr(a:csdata[line],'\(copyfrom-path="/\)\@<=.*"\@=')
+            if !empty(source)
+                let line+=1
+                let sourcerev=matchstr(a:csdata[line],
+                            \'\v(copyfrom\-rev\=\")@<=\d+\"@=')
+                if empty(sourcerev)
+                    call s:_f.throw('perr', 'copyfrom-rev="N"', a:csdata[line])
+                endif
+                let line+=1
+            endif
+            "▲3
             let match=matchlist(a:csdata[line],
                         \       'action="\(.\)">/\(.\+\)</path>')[1:2]
             if empty(match) "▶3
             endif           "▲3
             let [action, file]=match
             "▶3 Add file to list(s)
-            if file[:(svnplidx)] is# a:repo.svnprefix
+            if svnplidx==-1 || file[:(svnplidx)] is# a:repo.svnprefix
                 if has_key(s:logstatchars, action)
-                    let cs.status[s:logstatchars[action]]+=[file]
+                    let status=s:logstatchars[action]
+                    let cs.status[status]+=[file]
                 else
                     call s:_f.throw('perr', 'action="A/M/D"', action)
                 endif
+                if !empty(source)
+                    let cs.copies[file]=source
+                endif
             endif
             "▲3
             let line+=1
         endwhile
+        "▶3 Move some copies to renames
+        for [destination, source] in items(cs.copies)
+            if index(cs.status.removed, source)!=-1
+                let cs.renames[destination]=source
+                unlet cs.copies[destination]
+            endif
+        endfor
         if line>=lcsdata "▶3
             call s:_f.throw('perr', '</paths>', a:csdata[-1])
         endif            "▲3
     "▶2 Process cache
     if cancache
         let cachekey=string(args).string(sort(items(kwargs)))
-        if has_key(a:repo.diffcache, cachekey)
+        if !has_key(a:repo, 'diffcache')
+            let a:repo.diffcache={}
+        elseif has_key(a:repo.diffcache, cachekey)
             let cache=a:repo.diffcache[cachekey]
             let cache.acccount+=1
             return copy(cache.diff)
             \'M': 'modified',}]
 function s:F.status(repo, files)
     let r=deepcopy(s:initstatdct)
-    let slines=s:F.svn(a:repo, 'status', ['--']+a:files, {}, 0, 'statf')
+    let args=[]
+    if !empty(a:files)
+        let args+=['--']+a:files
+    endif
+    let slines=s:F.svn(a:repo, 'status', args, {}, 0, 'statf')
     let revstatus={}
     for line in slines
         let status=line[:6]
     let kwargs={}
     if a:force
         let kwargs.force=1
+        let kwargs.accept='theirs-full'
     endif
     let kwargs.revision=a:rev
     return s:F.svnm(a:repo, 'update', [], kwargs, 0, 'updf', a:rev)
                 \              'branch', 'time', 'user', 'description',
                 \              'renames', 'copies', 'files', 'changes',
                 \              'removes'],
-                \'has_merges': 0, 'diffcache': {},
+                \'has_merges': 0,
                 \}
     "▶2 Get svnprefix
     let str1='URL: '

File python/aurum.py

     except AurumError:
         pass
 
-def get_status(path, rev1=None, rev2=None, files=None):
+def get_status(path, rev1=None, rev2=None, files=None, clean=None):
     try:
         if rev1 is None and rev2 is None:
             rev1='.'
         repo=g_repo(path)
         if hasattr(repo, 'status'):
-            if files is None:
+            if not files:
                 m=None
             else:
                 m=match.match(None, None, files, exact=True)
-            status=repo.status(rev1, rev2, ignored=True, clean=True, unknown=True,
-                               match=m)
+            status=repo.status(rev1, rev2, ignored=True, clean=clean,
+                               unknown=True, match=m)
             vim.eval('extend(r, '+nonutf_dumps({'modified': status[0],
                                                    'added': status[1],
                                                  'removed': status[2],

File test/drivers-subversion.in

+:let g:curtest='svntest'
+:let g:tipname='HEAD'
+:let g:testedfile='svntestrepo/file-under-svn-control'
+:command -nargs=0 WTF call WriteFile(readfile(g:testedfile, 'b'))
+:W{{{1 Annotate
+:Run! AuAnnotate file ./svntestrepo/--force | wincmd w
+:bwipeout!
+:bwipeout!
+:W{{{1 Log: everything
+:Run! AuLog ./svntestrepo/ stat patch showfiles showrenames showcopies
+:bwipeout!
+:W{{{1 Status: current
+:W{{{1 Status: relative to other (1)
+:W{{{1 Status: relative to other (2)
+:W{{{1 Status: between two revisions
+:Run! AuStatus ./svntestrepo/ rev HEAD wdrev 2
+:bwipeout!
+:W{{{1 Commit
+:edit ./svntestrepo/newfile.vim
+iW In file newfile.vim:write
+:Run! AuCommit message Added\ newfile.vim type unknown ./svntestrepo/newfile.vim
+:WT
+:W{{{1 Commit 2
+oW File newfile.vim, second line:write
+:Run! AuCommit
+Added second line to newfile.vim
+// It was not required really:write
+:WT
+:W{{{1 Update
+:AuUpdate 3 ./svntestrepo/
+:WTF
+:W{{{1 Update: force
+:write! ./svntestrepo/file-under-svn-control
+:AuUpdate! 4 ./svntestrepo/
+:WTF
+:W{{{1 Update: to tip
+:R AuUpdate
+:WTF
+:W{{{1 Move
+:AuMove ./svntestrepo/--force ./svntestrepo/-f
+:AuCommit message Moved\ --force\ to\ -f repo ./svntestrepo/ all
+:WTa showrenames showcopies
+:W{{{1 Move: copy
+:AuMove copy ./svntestrepo/-f ./svntestrepo/--force
+:AuCommit message Copied\ -f\ to\ --force repo ./svntestrepo/ all
+:WTa showrenames showcopies
+:W{{{1 Junk: forget, remove
+:call WriteFile(filereadable('./svntestrepo/-f').filereadable('./svntestrepo/--force'))
+:AuJunk forget ./svntestrepo/-f
+:AuJunk remove ./svntestrepo/--force
+:call WriteFile(filereadable('./svntestrepo/-f').filereadable('./svntestrepo/--force'))
+:AuCommit ./svntestrepo/**
+ggddGld:write
+:WT
+:W{{{1 Grep: working directory
+:Run! AuGrep W repo ./svntestrepo/ | cwindow
+:cclose
+:W{{{1 Grep: working directory, ignore case
+:Run! AuGrep W ignorecase repo ./svntestrepo/ | cwindow
+:cclose
+:W{{{1 Grep: 6
+:let repo=aurum#repository()
+:Run! AuGrep W revision 6 repo ./svntestrepo/ | cwindow
+:cclose
+:W{{{1 Junk: ignore, ignoreglob
+:write! ./svntestrepo/file.vim
+:write! ./svntestrepo/subdir/file.vim
+:write! ./svntestrepo/ignoredfile.vim
+:write! ./svntestrepo/ignoredfile2.vim
+:W{{{2 Status before junk
+:Run! AuStatus ./svntestrepo/
+:AuJunk ignore ./svntestrepo/subdir/file.vim
+:AuJunk ignoreglob ./svntestrepo/ignored*
+:W{{{2 Status after junk
+:Run! AuStatus ./svntestrepo/

File test/drivers-subversion.ok

+{{{1 Annotate
+3 Added --force                   / zyx
+{{{1 Log: everything
+@  Changeset 5:5
+|  Commited 08 Янв 2012 20:45 by zyx
+|  Files: file-under-svn-control
+|  @ Replaced “Fourth” with “4’th”
+|  $0 files changed, 0 insertions, 0 deletions
+|  :Index: file-under-svn-control
+|  :===================================================================
+|  :--- file-under-svn-control	(revision 4)
+|  :+++ file-under-svn-control	(revision 5)
+|  :@@ -1,7 +1,7 @@
+|  : First line
+|  : Second line
+|  : Third line
+|  :-Fourth line
+|  :+4’th line
+|  : Fifth line
+|  : Sixth line
+|  : Seventh line
+|  
+o  Changeset 4:4
+|  Commited 08 Янв 2012 20:45 by zyx
+|  Files: subdir2/stu, ghi, mno, subdir/pqr, subdir2, def, file-under-svn-control
+|  @ Added seventh line to file-under-svn-control
+|  @ Added def, ghi, mno
+|  @ Added subdir/pqr
+|  @ Added subdir2, subdir2/stu
+|  $0 files changed, 0 insertions, 0 deletions
+|  :Index: ghi
+|  :===================================================================
+|  :--- ghi	(revision 0)
+|  :+++ ghi	(revision 4)
+|  :@@ -0,0 +1 @@
+|  :+Def
+|  :Index: subdir/pqr
+|  :===================================================================
+|  :--- subdir/pqr	(revision 0)
+|  :+++ subdir/pqr	(revision 4)
+|  :@@ -0,0 +1 @@
+|  :+Mno
+|  :Index: mno
+|  :===================================================================
+|  :--- mno	(revision 0)
+|  :+++ mno	(revision 4)
+|  :@@ -0,0 +1 @@
+|  :+Ghi
+|  :Index: subdir2/stu
+|  :===================================================================
+|  :--- subdir2/stu	(revision 0)
+|  :+++ subdir2/stu	(revision 4)
+|  :@@ -0,0 +1 @@
+|  :+Pqr
+|  :Index: file-under-svn-control
+|  :===================================================================
+|  :--- file-under-svn-control	(revision 3)
+|  :+++ file-under-svn-control	(revision 4)
+|  :@@ -4,3 +4,4 @@
+|  : Fourth line
+|  : Fifth line
+|  : Sixth line
+|  :+Seventh line
+|  :Index: def
+|  :===================================================================
+|  :--- def	(revision 0)
+|  :+++ def	(revision 4)
+|  :@@ -0,0 +1 @@
+|  :+Abc
+|  
+o  Changeset 3:3
+|  Commited 08 Янв 2012 20:45 by zyx
+|  Files: --force
+|  @ Added --force
+|  $0 files changed, 0 insertions, 0 deletions
+|  :Index: --force
+|  :===================================================================
+|  :--- --force	(revision 0)
+|  :+++ --force	(revision 3)
+|  :@@ -0,0 +1 @@
+|  :+File that looks like a “svn add” key
+|  
+o  Changeset 2:2
+|  Commited 08 Янв 2012 20:45 by zyx
+|  Files: subdir
+|  @ Commit where only a directory added
+|  $0 files changed, 0 insertions, 0 deletions
+|  :
+|  
+o  Changeset 1:1
+   Commited 08 Янв 2012 20:45 by zyx
+   Files: file-under-svn-control
+   @ Added file-under-svn-control
+   
+{{{1 Status: current
+{{{1 Status: relative to other (1)
+{{{1 Status: relative to other (2)
+{{{1 Status: between two revisions
+M file-under-svn-control
+R ghi
+R --force
+R subdir/pqr
+R mno
+R subdir2/stu
+R def
+{{{1 Commit
+W In file newfile.vim
+o  Changeset 6
+|  @ Added newfile.vim
+{{{1 Commit 2
+
+# Modified newfile.vim
+o  Changeset 7
+|  @ Added second line to newfile.vim
+|  @ // It was not required really
+{{{1 Update
+First line
+Second line
+Third line
+Fourth line
+Fifth line
+Sixth line
+{{{1 Update: force
+First line
+Second line
+Third line
+Fourth line
+Fifth line
+Sixth line
+Seventh line
+{{{1 Update: to tip
+First line
+Second line
+Third line
+4’th line
+Fifth line
+Sixth line
+Seventh line
+{{{1 Move
+o  Changeset 8
+|  Renamed --force to -f
+|  @ Moved --force to -f
+{{{1 Move: copy
+o  Changeset 9
+|  Copied -f to --force
+|  @ Copied -f to --force
+{{{1 Junk: forget, remove
+11
+10
+o  Changeset 10
+|  @ Removed --force
+{{{1 Grep: working directory
+svntestrepo/newfile.vim|1| W In file newfile.vim
+svntestrepo/newfile.vim|2| W File newfile.vim, second line
+{{{1 Grep: working directory, ignore case
+svntestrepo/newfile.vim|1| W In file newfile.vim
+svntestrepo/newfile.vim|2| W File newfile.vim, second line
+{{{1 Grep: 6
+aurum://file:%ETMPDIR%%-test%-svntestrepo:6:newfile.vim|1| W In file newfile.vim
+{{{1 Junk: ignore, ignoreglob
+{{{2 Status before junk
+? ignoredfile.vim
+? ignoredfile2.vim
+? file.vim
+? subdir/file.vim
+{{{2 Status after junk
+M .
+M subdir
+? file.vim
     return ''
 endfunction
 command -nargs=1 -bar W call WriteFile(<q-args>)
-function s:WriteTip(writecom, cmd)
+function s:WriteTip(writecom, cmd, addargs)
     let tipname=get(g:, 'tipname', 'tip')
-    execute 'R AuLog limit 1 revision '.tipname
+    execute 'R AuLog limit 1 revision '.tipname.' '.a:addargs
     setlocal modifiable noreadonly
     if !a:writecom
         g/Commited/delete _
     call WriteFile(getline(1, line('$')-1))
     bwipeout!
 endfunction
-command -nargs=? -bar -bang WT :call s:WriteTip(<bang>0, <q-args>)
+command -nargs=? -bar -bang WT  :call s:WriteTip(<bang>0, <q-args>, '')
+command -nargs=1 -bar -bang WTa :call s:WriteTip(<bang>0, '', <q-args>)
 function s:WriteWindows()
     let wcur=winnr()
     let wprev=winnr('#')