Commits

ZyX_I committed f3e8ff9

@aurum/drivers/git: Rearranged repo functions
doc, @aurum/drivers/mercurial: Rearranged add, forget, remove and ignore repo functions

Comments (0)

Files changed (4)

     Move or copy given file or directory (second argument) to given 
     destination (third argument).
     Note: directories are always passed with trailing forward slash.
+  add    :: fdir -> _                                        *aurum-rf-add*
   forget :: fdir -> _                                        *aurum-rf-forget*
   remove :: fdir -> _                                        *aurum-rf-remove*
-  add    :: fdir -> _                                        *aurum-rf-add*
   ignore :: fdir -> _                                        *aurum-rf-ignore*
     Forget, remove, add (make tracked) or ignore (add to .hgignore or 
     something similar) given file or directory. “ignore” function properly 

plugin/aurum/drivers/git.vim

     "▲2
     return cslist
 endfunction
+"▶1 git.revrange :: repo, rev1, rev2 → [cs]
+let s:git.revrange=s:git.getchangesets
+"▶1 git.updatechangesets :: repo → _
+let s:git.updatechangesets=s:git.getchangesets
 "▶1 git.getrevhex :: repo, rev → hex
 let s:prevrevhex={}
 function s:git.getrevhex(repo, rev)
     let s:prevrevhex[a:repo.path]=[a:rev, r]
     return r
 endfunction
-"▶1 git.updatechangesets :: repo → _
-let s:git.updatechangesets=s:git.getchangesets
-"▶1 git.revrange :: repo, rev1, rev2 → [cs]
-let s:git.revrange=s:git.getchangesets
-"▶1 git.getworkhex :: repo → hex
-function s:git.getworkhex(repo)
-    return a:repo.functions.getrevhex(a:repo, 'HEAD')
-endfunction
 "▶1 git.gettiphex
 " XXX Uses master or working directory revision instead of latest revision
 function s:git.gettiphex(repo)
         return a:repo.functions.gettiphex(a:repo)
     endtry
 endfunction
+"▶1 git.getworkhex :: repo → hex
+function s:git.getworkhex(repo)
+    return a:repo.functions.getrevhex(a:repo, 'HEAD')
+endfunction
 "▶1 git.setcsprop :: repo, cs, propname → propvalue
 function s:git.setcsprop(repo, cs, prop)
     if a:prop is# 'allfiles'
     let a:cs[a:prop]=r
     return r
 endfunction
-"▶1 git.readfile :: repo, rev, file → [String]
-function s:git.readfile(repo, rev, file)
-    return s:F.git(a:repo, 'cat-file', ['blob', a:rev.':'.a:file], {}, 2,
-                \  'filef', a:rev, a:file)
-endfunction
-"▶1 git.diff :: repo, rev, rev, files, opts → [String]
-let s:difftrans={
-            \  'reverse': 'R',
-            \ 'ignorews': 'ignore-all-space',
-            \'iwsamount': 'ignore-space-change',
-            \ 'numlines': 'unified',
-            \  'alltext': 'text',
-        \}
-function s:git.diff(repo, rev1, rev2, files, opts)
-    let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
-    if has_key(diffopts, 'unified')
-        let diffopts.unified=''.diffopts.unified
-    endif
-    let kwargs=copy(diffopts)
-    let args=[]
-    if empty(a:rev2)
-        if !empty(a:rev1)
-            let args+=[a:rev1.'^..'.a:rev1]
-        endif
-    else
-        let args+=[a:rev2]
-        if !empty(a:rev1)
-            let args[-1].='..'.a:rev1
-        endif
-    endif
-    if !empty(a:files)
-        let args+=['--']+a:files
-    endif
-    let r=s:F.git(a:repo, 'diff', args, kwargs, 1,
-                \ 'difff', a:rev1, a:rev2, join(a:files, ', '))
-    return r
-endfunction
-"▶1 git.diffre :: _, opts → Regex
-let s:diffre='\m^diff --git \v((\")?%s\/.{-}\2) \2%s\/'
-function s:git.diffre(repo, opts)
-    if get(a:opts, 'reverse', 0)
-        return printf(s:diffre, 'b', 'a')
-    else
-        return printf(s:diffre, 'a', 'b')
-    endif
-endfunction
-"▶1 git.diffname :: _, line, diffre, _ → rpath
-function s:git.diffname(repo, line, diffre, opts)
-    let file=get(matchlist(a:line, a:diffre), 1, 0)
-    if file is 0
-        return 0
-    else
-        return s:F.refile(file)[2:]
-    endif
-endfunction
 "▶1 nullnl :: [String] → [String]
 " Convert between lines (NL separated strings with NULLs represented as NLs) and 
 " NULL separated strings with NLs represented by NLs.
     endif
     return r
 endfunction
-"▶1 git.annotate :: repo, rev, file → [(file, hex, linenumber)]
-function s:git.annotate(repo, rev, file)
-    let args=[a:rev, '--', a:file]
-    let kwargs={'porcelain': 1, 'C': 1, 'M': 1}
-    let lines=s:F.git(a:repo, 'blame', args, kwargs, 1, 'annf', a:rev, a:file)
-    call filter(lines, 'v:val=~#''\v^(\x{40}\ |filename\ )''')
-    let r=[]
-    let filename=a:file
-    while !empty(lines)
-        let line=remove(lines, 0)
-        if !empty(lines) && lines[0][:8] is# 'filename '
-            let filename=s:F.refile(remove(lines, 0)[9:])
-        endif
-        let r+=[[filename, line[:39], str2nr(line[41:])]]
-    endwhile
-    return r
-endfunction
 "▶1 git.commit :: repo, message[, files[, user[, date[, _]]]]
 function s:git.commit(repo, message, ...)
     let kwargs={'cleanup': 'verbatim'}
     return s:_r.utils.usefile(a:repo, a:message, 'file', 'message',
                 \             s:F.gitm, args, kwargs, 0, 'cif')
 endfunction
+"▶1 git.branch :: repo, branchname, force → + FS
+function s:git.branch(repo, branch, force)
+    if a:force
+        return s:F.gitm(a:repo, 'checkout', [a:branch], {'B': 1}, 0,
+                    \   'chbf', a:branch)
+    else
+        call a:repo.functions.label(a:repo, 'branch', a:branch, 'HEAD', 0, 0)
+        call a:repo.functions.update(a:repo, a:branch, 0)
+    endif
+endfunction
+"▶1 git.label :: repo, type, label, rev, force, local → + FS
+function s:git.label(repo, type, label, rev, force, local)
+    if a:local
+        call s:_f.throw('nloc')
+    endif
+    let args=['--', a:label]
+    let kwargs={}
+    if a:force
+        let kwargs.force=1
+    endif
+    if a:rev is 0
+        let kwargs.d=1
+    else
+        let args+=[a:rev]
+    endif
+    return s:F.gitm(a:repo, a:type, args, kwargs, 0,
+                \   'lbf', a:type, a:label, a:rev)
+endfunction
 "▶1 git.update :: repo, rev, force → + FS
 " XXX This must not transform {rev} into hash: it will break rf-branch()
 function s:git.update(repo, rev, force)
                 \   a:force ? {'force': 1} : {}, 0, 'mvf',
                 \   a:source, a:destination)
 endfunction
-"▶1 git.remove :: repo, file → + FS
-function s:git.remove(repo, file)
-    return s:F.gitm(a:repo, 'rm', ['--', a:file], {}, 0, 'rmf',
+"▶1 git.add :: repo, file → + FS
+function s:git.add(repo, file)
+    return s:F.gitm(a:repo, 'add', ['--', a:file], {}, 0, 'addf',
                 \   escape(a:file, '\'))
 endfunction
 "▶1 git.forget :: repo, file → + FS
     return s:F.gitm(a:repo, 'rm', ['--', a:file], {'cached': 1}, 0, 'fgf',
                 \   escape(a:file, '\'))
 endfunction
-"▶1 git.add :: repo, file → + FS
-function s:git.add(repo, file)
-    return s:F.gitm(a:repo, 'add', ['--', a:file], {}, 0, 'addf',
+"▶1 git.remove :: repo, file → + FS
+function s:git.remove(repo, file)
+    return s:F.gitm(a:repo, 'rm', ['--', a:file], {}, 0, 'rmf',
                 \   escape(a:file, '\'))
 endfunction
 "▶1 addtoignfile :: file, line → + FS
 function s:git.ignoreglob(repo, glob)
     return s:F.addtoignfile(s:_r.os.path.join(a:repo.path,'.gitignore'), a:glob)
 endfunction
-"▶1 git.branch :: repo, branchname, force → + FS
-function s:git.branch(repo, branch, force)
-    if a:force
-        return s:F.gitm(a:repo, 'checkout', [a:branch], {'B': 1}, 0,
-                    \   'chbf', a:branch)
-    else
-        call a:repo.functions.label(a:repo, 'branch', a:branch, 'HEAD', 0, 0)
-        call a:repo.functions.update(a:repo, a:branch, 0)
-    endif
-endfunction
-"▶1 git.label :: repo, type, label, rev, force, local → + FS
-function s:git.label(repo, type, label, rev, force, local)
-    if a:local
-        call s:_f.throw('nloc')
-    endif
-    let args=['--', a:label]
-    let kwargs={}
-    if a:force
-        let kwargs.force=1
-    endif
-    if a:rev is 0
-        let kwargs.d=1
-    else
-        let args+=[a:rev]
-    endif
-    return s:F.gitm(a:repo, a:type, args, kwargs, 0,
-                \   'lbf', a:type, a:label, a:rev)
-endfunction
 "▶1 git.grep :: repo, files, revisions, ignorecase, wdfiles::Bool → qflist
 "▶2 parsegrep :: lines → [(file, lnum, String)]
 function s:F.parsegrep(lines)
     endif
     return r
 endfunction
+"▶1 git.readfile :: repo, rev, file → [String]
+function s:git.readfile(repo, rev, file)
+    return s:F.git(a:repo, 'cat-file', ['blob', a:rev.':'.a:file], {}, 2,
+                \  'filef', a:rev, a:file)
+endfunction
+"▶1 git.annotate :: repo, rev, file → [(file, hex, linenumber)]
+function s:git.annotate(repo, rev, file)
+    let args=[a:rev, '--', a:file]
+    let kwargs={'porcelain': 1, 'C': 1, 'M': 1}
+    let lines=s:F.git(a:repo, 'blame', args, kwargs, 1, 'annf', a:rev, a:file)
+    call filter(lines, 'v:val=~#''\v^(\x{40}\ |filename\ )''')
+    let r=[]
+    let filename=a:file
+    while !empty(lines)
+        let line=remove(lines, 0)
+        if !empty(lines) && lines[0][:8] is# 'filename '
+            let filename=s:F.refile(remove(lines, 0)[9:])
+        endif
+        let r+=[[filename, line[:39], str2nr(line[41:])]]
+    endwhile
+    return r
+endfunction
+"▶1 git.diff :: repo, rev, rev, files, opts → [String]
+let s:difftrans={
+            \  'reverse': 'R',
+            \ 'ignorews': 'ignore-all-space',
+            \'iwsamount': 'ignore-space-change',
+            \ 'numlines': 'unified',
+            \  'alltext': 'text',
+        \}
+function s:git.diff(repo, rev1, rev2, files, opts)
+    let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
+    if has_key(diffopts, 'unified')
+        let diffopts.unified=''.diffopts.unified
+    endif
+    let kwargs=copy(diffopts)
+    let args=[]
+    if empty(a:rev2)
+        if !empty(a:rev1)
+            let args+=[a:rev1.'^..'.a:rev1]
+        endif
+    else
+        let args+=[a:rev2]
+        if !empty(a:rev1)
+            let args[-1].='..'.a:rev1
+        endif
+    endif
+    if !empty(a:files)
+        let args+=['--']+a:files
+    endif
+    let r=s:F.git(a:repo, 'diff', args, kwargs, 1,
+                \ 'difff', a:rev1, a:rev2, join(a:files, ', '))
+    return r
+endfunction
+"▶1 git.diffre :: _, opts → Regex
+let s:diffre='\m^diff --git \v((\")?%s\/.{-}\2) \2%s\/'
+function s:git.diffre(repo, opts)
+    if get(a:opts, 'reverse', 0)
+        return printf(s:diffre, 'b', 'a')
+    else
+        return printf(s:diffre, 'a', 'b')
+    endif
+endfunction
+"▶1 git.diffname :: _, line, diffre, _ → rpath
+function s:git.diffname(repo, line, diffre, opts)
+    let file=get(matchlist(a:line, a:diffre), 1, 0)
+    if file is 0
+        return 0
+    else
+        return s:F.refile(file)[2:]
+    endif
+endfunction
 "▶1 git.getrepoprop :: repo, propname → a
 function s:git.getrepoprop(repo, prop)
     if a:prop is# 'url'

plugin/aurum/drivers/mercurial.vim

 function s:hg.copy(repo, force, ...)
     return s:F.runcmd(a:repo, 'copy', a:000, a:force ? {'force': 1} : {})
 endfunction
+"▶1 hg.add :: repo, file → + FS
+function s:hg.add(repo, ...)
+    return s:F.runcmd(a:repo, 'add', a:000, {})
+endfunction
 "▶1 hg.forget :: repo, file → + FS
 function s:hg.forget(repo, ...)
     return s:F.runcmd(a:repo, 'forget', a:000, {})
 function s:hg.remove(repo, ...)
     return s:F.runcmd(a:repo, 'remove', a:000, {})
 endfunction
-"▶1 hg.add :: repo, file → + FS
-function s:hg.add(repo, ...)
-    return s:F.runcmd(a:repo, 'add', a:000, {})
-endfunction
 "▶1 addtosection :: repo, hgignore::path, section, line → + FS(hgignore)
 function s:F.addtosection(repo, hgignore, section, line)
     let addsect=['syntax: '.a:section,

plugin/aurum/drivers/subversion.vim

     endwhile
     return cs
 endfunction
+"▶1 svn.getcs :: repo, rev → cs
+function s:svn.getcs(repo, rev)
+    "▶2 Do the best trying to get it from repo.changesets
+    if has_key(a:repo.changesets, a:rev)
+        return a:repo.changesets[a:rev]
+    else
+        let rev=a:repo.functions.getrevhex(a:repo, a:rev)
+        if has_key(a:repo.changesets, rev)
+            return a:repo.changesets[rev]
+        elseif !empty(a:repo.cslist)
+            call a:repo.functions.updatechangesets(a:repo)
+            if has_key(a:repo.changesets, rev)
+                return a:repo.changesets[rev]
+            endif
+        endif
+    endif
+    "▲2
+    let cs=s:F.parsecs(a:repo,
+                \      s:_r.xml.new(
+                \      s:F.svn(a:repo, 'log', ['--', a:repo.svnroot],
+                \              {'revision': rev, 'limit': '1', 'xml': 1,
+                \               'verbose': 1},
+                \              0, 'csf', a:rev)[2:]))
+    let a:repo.changesets[cs.hex]=cs
+    return a:repo.changesets[cs.hex]
+endfunction
+"▶1 svn.getwork :: repo → cs
+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)
+endfunction
+"▶1 svn.getchangesets :: repo → [cs]
+function s:svn.getchangesets(repo)
+    if empty(a:repo.cslist)
+        let cslist=s:F.getchangesets(a:repo)
+        let cslist[-1].children=[]
+        call map(cslist[:-2], 'extend(v:val, {"children": ["".(v:val.rev-1)]})')
+        let a:repo.cslist+=cslist
+    else
+        call a:repo.functions.updatechangesets(a:repo)
+    endif
+    return a:repo.cslist
+endfunction
 "▶1 getchangesets :: repo → [cs]
 function s:F.getchangesets(repo, ...)
     let args=['--', a:repo.svnroot]
     endwhile
     return cslist
 endfunction
-"▶1 svn.getchangesets :: repo → [cs]
-function s:svn.getchangesets(repo)
-    if empty(a:repo.cslist)
-        let cslist=s:F.getchangesets(a:repo)
-        let cslist[-1].children=[]
-        call map(cslist[:-2], 'extend(v:val, {"children": ["".(v:val.rev-1)]})')
-        let a:repo.cslist+=cslist
-    else
-        call a:repo.functions.updatechangesets(a:repo)
-    endif
-    return a:repo.cslist
-endfunction
 "▶1 svn.updatechangesets :: repo → _
 function s:svn.updatechangesets(repo)
     let oldtiprev=a:repo.cslist[-1].rev
     endif
     return a:repo.cslist[(i):(r2i)]
 endfunction
-"▶1 svn.getcs :: repo, rev → cs
-function s:svn.getcs(repo, rev)
-    "▶2 Do the best trying to get it from repo.changesets
-    if has_key(a:repo.changesets, a:rev)
-        return a:repo.changesets[a:rev]
-    else
-        let rev=a:repo.functions.getrevhex(a:repo, a:rev)
-        if has_key(a:repo.changesets, rev)
-            return a:repo.changesets[rev]
-        elseif !empty(a:repo.cslist)
-            call a:repo.functions.updatechangesets(a:repo)
-            if has_key(a:repo.changesets, rev)
-                return a:repo.changesets[rev]
-            endif
-        endif
-    endif
-    "▲2
-    let cs=s:F.parsecs(a:repo,
-                \      s:_r.xml.new(
-                \      s:F.svn(a:repo, 'log', ['--', a:repo.svnroot],
-                \              {'revision': rev, 'limit': '1', 'xml': 1,
-                \               'verbose': 1},
-                \              0, 'csf', a:rev)[2:]))
-    let a:repo.changesets[cs.hex]=cs
-    return a:repo.changesets[cs.hex]
-endfunction
-"▶1 svn.getwork :: repo → cs
-function s:svn.getwork(repo)
-    return a:repo.functions.getcs(a:repo, 'BASE')
-endfunction
 "▶1 svn.getworkhex :: repo → hex
 function s:svn.getworkhex(repo)
     return a:repo.functions.getrevhex(a:repo, 'BASE')