1. ZyX_I
  2. aurum

Commits

ZyX_I  committed d450099

@%aurum/drivers/bazaar: Extended number of statuses supported by rf-status()
Added rf-astatus() and rf-agetrepoprop() functions

  • Participants
  • Parent commits 02774a9
  • Branches default

Comments (0)

Files changed (5)

File autoload/aurum/drivers/bazaar.vim

View file
  • Ignore whitespace
             \             'in the repository %s: %s',
             \      'lsf': 'Failed to list files in the changeset %s '.
             \             'from the repository %s: %s',
-            \    'statf': 'Failed to get status in the repository %s: %s',
             \'lsignoref': 'Failed to list ignored files '.
             \             'in the repository %s: %s',
             \   'labelf': 'Failed to set %s “%s” for the changeset %s '.
 "▶1 getstatdict :: repo, kwargs → statdict
 function s:F.getstatdict(repo, args, kwargs)
     let status=s:F.bzr(a:repo, 'status', a:args,
-                \      extend({'no-classify': 1}, a:kwargs), 0,
-                \      'statf')[:-2]
+                \      extend({'no-classify': 1, 'no-pending': 1}, a:kwargs),
+                \      0)[:-2]
     let curstatus=0
     let statdict={}
     while !empty(status)
 "▶1 bzr.status :: repo[, rev1[, rev2[, files[, clean[, ign]]]]] → {type:[file]}
 let s:statstats={'added': 'added', 'removed': 'removed', 'modified': 'modified',
             \    'kind changed': 'modified', 'unknown': 'unknown',
-            \    'missing': 'deleted'}
+            \    'missing': 'deleted', 'ignored': 'ignored',
+            \    'nonexistent': 'unknown', 'conflicts': 'modified',}
 function s:bzr.status(repo, ...)
     let args=['--']+((a:0>2 && a:3 isnot 0)?(a:3):([]))
     let statdict=s:F.getstatdict(a:repo, args,
     endfor
     let renames=s:F.getrenames(statdict)
     call filter(r.modified, '!has_key(renames, v:val)')
-    let r.added+=sort(keys(renames))
-    let r.removed+=sort(values(renames))
+    if a:0>2 && !empty(a:3)
+        let r.added   += sort(filter(keys(renames),   'index(a:3, v:val)!=-1'))
+        let r.removed += sort(filter(values(renames), 'index(a:3, v:val)!=-1'))
+    else
+        let r.added   += sort(keys(renames))
+        let r.removed += sort(values(renames))
+    endif
     if a:0>1 && a:1 is 0 && a:2 isnot 0
         let [r.deleted, r.unknown]=[r.unknown, r.deleted]
         let [r.added,   r.removed]=[r.removed, r.added  ]
         let files=r.modified+r.added+r.removed+r.deleted+r.unknown
         let r.clean=filter(allfiles, 'index(files, v:val)==-1')
     endif
-    if (a:0>4 && a:5 && a:1 is 0 && a:2 is 0)
+    " Ignored files are listed in “bzr status” output, but only if they are 
+    " specified on the command-line. Bazaar really has good documentation:
+    " “bzr help status” does not have anything about “missing”, “ignored” and 
+    " “nonexistent” statuses or different behavior for explicitely specified 
+    " paths.
+    if (a:0>4 && a:5 && a:1 is 0 && a:2 is 0 && empty(a:3))
         let r.ignored=s:_r.utils.nullnl(
                     \ s:F.bzr(a:repo, 'ls', args, {'ignored': 1, 'null': 1}, 2,
                     \                 'lsignoref', a:repo))[:-2]
 function s:bzr.checkdir(dir)
     return s:_r.os.path.isdir(s:_r.os.path.join(a:dir, '.bzr'))
 endfunction
-"▶1 iterfuncs
+"▶1 TODO iterfuncs
 " TODO
+"▶1 astatus, agetcs, agetrepoprop
+if s:_r.repo.userepeatedcmd
+    try
+        python import aurum.rcdriverfuncs
+        let s:addafuncs=1
+    catch
+        let s:addafuncs=0
+    endtry
+    if s:addafuncs
+        function s:bzr.astatus(repo, interval, ...)
+            if a:0<3 || a:1 isnot 0 || a:2 isnot 0 ||
+                        \type(a:3)!=type([]) || len(a:3)!=1
+                call s:_f.throw('aconimp')
+            endif
+            return pyeval('aurum.repeatedcmd.new('.string(a:interval).', '.
+                        \       'aurum.rcdriverfuncs.bzr_status, '.
+                        \       'vim.eval("a:repo.path"), '.
+                        \       'vim.eval("a:3[0]"))')
+        endfunction
+        function s:bzr.agetrepoprop(repo, interval, prop)
+            if a:prop isnot# 'branch'
+                call s:_f.throw('anbnimp')
+            endif
+            return pyeval('aurum.repeatedcmd.new('.string(a:interval).', '.
+                        \       'aurum.rcdriverfuncs.bzr_branch, '.
+                        \       'vim.eval("a:repo.path"))')
+        endfunction
+    endif
+endif
 "▶1 Register driver
 call s:_f.regdriver('Bazaar', s:bzr)
 "▶1

File doc/aurum.txt

View file
  • Ignore whitespace
     |g:aurum_statuscachetime|).
     Note: if returned status is an empty string it may indicate that there it 
           failed to get status as well as that this file was not modified.
+    Note 2: if vim was compiled with |+python| support this function may 
+            launch a separate process which won’t be stopped until current 
+            buffer is no longer visible.
 
 aurum#branch :: ([{repo}]) -> branch                          *aurum#branch()*
     Returns a current branch name (uses |aurum-rf-getrepoprop|). Should be 
     faster then using |aurum#changeset()| and getting “branch” key from 
     returned changeset. Cached (update time is controlled by 
     |g:aurum_branchcachetime|).
+    Note: if vim was compiled with |+python| support this function may launch 
+          a separate process which won’t be stopped until all buffers where it 
+          was called which hold files in one repository are no longer visible. 
+          Only one process is launched for one repository.
 
 ------------------------------------------------------------------------------
 2.3. aurum:// pseudo-protocol                                       *aurum://*
 |aurum-rf-getcsprop|(…, "children") requires at least mercurial-1.7 or manual 
     preceding |aurum-rf-getchangesets| call. Thus many Next mappings do not 
     work.
+|aurum-rf-astatus| in non-python version supports only 
+    status(repo,0,0,[file],1,1) calls.
+|aurum-rf-agetcs| is absent in non-python version of driver.
+|aurum-rf-agetrepoprop| in non-python version supports only “branch” property.
 *aurum-rf-svnrev* exists and produces svn revision number out of repository 
     object and mercurial revision specification.
 *aurum-rf-githex* exists and produces git sha1 out of repository object and 
     name as an argument, but it may also search .git/refs/heads for {hex} 
     argument and use first found file with contents equal to {hex} as a branch 
     name.
+|aurum-rf-astatus| supports only status(repo,0,0,[file],1,1) calls.
+|aurum-rf-agetcs| is absent.
+|aurum-rf-agetrepoprop| supports only “branch” property.
 
 ------------------------------------------------------------------------------
 10.3. Subversion                                     *aurum-driver-Subversion*
     initially wanted.
 |aurum-rf-pull| uses “svn update” to pull and “svn log” for incoming.
 |aurum-rf-push| is not defined.
+|aurum-rf-astatus| supports only status(repo,0,0,[file],1,1) calls.
+|aurum-rf-agetcs| is absent.
+|aurum-rf-agetrepoprop| is absent.
 
 ------------------------------------------------------------------------------
 10.4. Bazaar                                             *aurum-driver-Bazaar*
 |aurum-rf-diffname| will work incorrectly if filenames containing “' => '” 
     were renamed.
 |aurum-repo.iterfuncs| is missing (yet).
+|aurum-rf-astatus| supports only status(repo,0,0,[file],1,1) calls.
+|aurum-rf-agetcs| is absent.
+|aurum-rf-agetrepoprop| supports only “branch” property.
 
 ==============================================================================
 11. Changelog                                                *aurum-changelog*

File python/aurum/rcdriverfuncs.py

View file
  • Ignore whitespace
 def svn_status(path, fname):
     r=deepcopy(emptystatdct)
     try:
-        line=readlines(['svn', 'status', '--', fname]).next()
+        line=readlines(['svn', 'status', '--', fname], cwd=path).next()
         status=line[:7]
         for schar, colschars in zip(status, svnstatchars):
             if schar in colschars:
         r['clean'].append(fname)
     return r
 
+bzrstatstats={
+    'added'       : 'added',
+    'removed'     : 'removed',
+    'renamed'     : 'removed',
+    'modified'    : 'modified',
+    'kind changed': 'modified',
+    'conflicts'   : 'modified',
+    'unknown'     : 'unknown',
+    'nonexistent' : 'unknown',
+    'missing'     : 'deleted',
+    'ignored'     : 'ignored',
+}
+
+def bzr_status(path, fname):
+    r=deepcopy(emptystatdct)
+    try:
+        line=readlines(['bzr', 'status', '--', fname], cwd=path).next()
+        if line[-1] != ':':
+            raise ValueError('Expected colon at the end of first line')
+        line=line[:-1]
+        if line != 'nonexistent':
+            r[bzrstatstats[line]].append(fname)
+    except StopIteration:
+        r['clean'].append(fname)
+    return r
+
+def bzr_branch(path):
+    return "\n".join(readlines(['bzr', 'nick'], cwd=path))
+
 # vim: ft=python ts=4 sw=4 sts=4 et tw=100

File test/drivers-bazaar.ok

  • Ignore whitespace
Binary file modified.

File test/drivers-bazaar.vim

View file
  • Ignore whitespace
                     \string(a:repo.functions.getcsprop(a:repo, a:cs, p))]
     endfor
 endfunction
-function FormatStatus(status, ...)
-    let g:r+=[' >> Status']
+function FormatStatus(repo, args, ...)
+    let status=call(a:repo.functions.status, [a:repo]+a:args, {})
+    let g:r+=[' >> Status ('.fnamemodify(a:repo.path, ':t').'): '.
+                \string(a:args)[1:-2]]
     let expr='"     ".'
     if a:0 && !empty(a:1)
         let expr.='"xr"[filereadable(a:1."/".v:val)]." ".v:val'
     else
         let expr.='v:val'
     endif
-    for [key, files] in items(a:status)
+    for [key, files] in items(status)
         let g:r+=['  - '.key]+map(copy(files), expr)
     endfor
 endfunction
 for cs in Arepo.functions.getchangesets(Arepo)
     call FormatCS(Arepo, cs)
 endfor
-call FormatStatus(Arepo.functions.status(Arepo))
-call FormatStatus(Arepo.functions.status(Arepo, 0,   0,   0,             1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, 0,   0,   [],            1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, '7', 0,   0,             1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, '5', 0,   0,             1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, 0,   '5', 0,             1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, '5', '4', 0,             1, 1))
-call FormatStatus(Arepo.functions.status(Arepo, '4', 0,   ['lines.lst'], 1, 1))
-call FormatStatus(Brepo.functions.status(Brepo, 0, 0, 0, 1, 1))
+call FormatStatus(Arepo, [])
+call FormatStatus(Arepo, [0,   0,   0,             1, 1])
+call FormatStatus(Arepo, [0,   0,   [],            1, 1])
+call FormatStatus(Arepo, ['7', 0,   0,             1, 1])
+call FormatStatus(Arepo, ['5', 0,   0,             1, 1])
+call FormatStatus(Arepo, [0,   '5', 0,             1, 1])
+call FormatStatus(Arepo, ['5', '4', 0,             1, 1])
+call FormatStatus(Arepo, ['4', 0,   ['lines.lst'], 1, 1])
+call FormatStatus(Brepo, [0, 0, 0, 1, 1])
 call Brepo.functions.commit(Brepo, 'Added added, modified and unknown',
             \                      ['added', 'modified', 'unknown'],
             \                      'Abc <abc@example.net>',
 call Brepo.functions.remove(Brepo, 'unknown')
 call Brepo.functions.ignore(Brepo, 'I-')
 call Brepo.functions.ignoreglob(Brepo, 'Ign*')
-call FormatStatus(Brepo.functions.status(Brepo, 0, 0, 0, 1, 1), Brepo.path)
+call FormatStatus(Brepo, [0, 0, 0, 1, 1], Brepo.path)
 function PurgeDiffPlusDates(lines)
     return map(a:lines, 'v:val[:3] is# "+++ " ? '.
                 \           'substitute(v:val, "\t[^\t]\\+$", "", "") : '.