Commits

ZyX_I  committed e0b0bf7

@%aurum/drivers/bazaar: Added missing 'nocfg' error message
Fixed setcsprop(…, "allfiles")
tests: Added initial testing for bazaar driver

  • Participants
  • Parent commits 458d6c6
  • Branches bzr-support

Comments (0)

Files changed (5)

File autoload/aurum.vim

 endfunction
 "▶1 aurum#repository
 function aurum#repository()
+    " TODO Path instead of buffer cache to reduce number of shell calls
+    " TODO Maybe somehow tell repo.get function not to update repository
     let repo=s:_r.cache.get('repo', s:_r.repo.get, [':'], {})
     if repo is 0
         return {}

File autoload/aurum/drivers/bazaar.vim

             \             'both revisions',
             \   'bfnimp': 'Can’t force branch nick creation',
             \   'drnimp': 'Dry run not implemented',
+            \    'nocfg': 'Can’t get property %s of the repository %s',
         \}
 let s:bzr={}
 let s:_options={
     let rev=+s:F.bzr(a:repo, 'revno', [], {'tree': 1}, 0, 'revnof')[0]
     return a:repo.functions.getcs(a:repo, rev)
 endfunction
-"▶1 bzr.getchangesets :: repo[, rangestart[, rangeend]] → [cs]
+"▶1 bzr.getchangesets :: repo[, rangestart, rangeend] → [cs]
 let s:gcsslogkwargs=extend({'levels': '0'}, s:logkwargs)
 function s:bzr.getchangesets(repo, ...)
     let kwargs=copy(s:gcsslogkwargs)
                     \s:F.bzr(a:repo, 'ls', [], {'revision': 'revid:'.a:cs.hex,
                     \                          'recursive': 1,
                     \                               'null': 1}, 2,
-                    \        'lsf', a:cs.hex)
-        call filter(r, 'v:val[-1:] is# "/"')
+                    \        'lsf', a:cs.hex))[:-2]
     elseif       a:prop is# 'renames' || a:prop is# 'changes' ||
                 \a:prop is# 'files'   || a:prop is# 'removes'
         let statdict=s:F.getstatdict(a:repo, [], {'change': 'revid:'.a:cs.hex})
         return s:F.bzr(a:repo, 'config', ['parent_location'], {}, 0,
                     \  'configf')[:-2]
     elseif a:prop is# 'brancheslist'
-        " FIXME
+        return []
+        " FIXME Use “bzr branches”?
     elseif a:prop is# 'tagslist'
         return map(s:F.bzr(a:repo, 'tags', [], {}, 0, 'tagf')[:-2],
                     \'substitute(v:val, '' \+\S\+$'', "", "")')

File test/createbzrrepo.zsh

+#!/bin/zsh
+emulate -L zsh
+local A='A <a@example.com>'
+local B='B <b@example.org>'
+local C='C <c@example.gov>'
+export TZ=UTC
+(
+    test -d bzrtestrepo && rm -rf bzrtestrepo
+    mkdir bzrtestrepo
+    cd bzrtestrepo
+    bzr init A
+    pushd A
+    bzr nick A
+    echo $'First line\nSecond line\nThird line\nFourth line' > lines.lst
+    bzr add lines.lst
+    bzr commit -m 'Added lines.lst' \
+        --author $A --commit-time='1990-01-01 00:00:00 +0000'
+    popd
+    bzr branch A B
+    pushd B
+    bzr nick B
+    echo Fifth line >> lines.lst
+    bzr commit -m 'Added fifth line to lines.lst' \
+        --author $B --commit-time='1990-01-01 01:00:00 +0000'
+    popd
+    bzr branch A C
+    pushd C
+    bzr nick C
+    perl -p -i -e 's/First/1’st/' lines.lst
+    bzr commit -m 'Replaced “First” with “1’st” in lines.lst' \
+        --author $B --commit-time='1990-01-01 01:00:00 +0000'
+    popd
+    pushd A
+    bzr merge ../B
+    bzr merge ../C --force
+    bzr commit -m 'Merged B and C'
+    popd
+    pushd B
+    echo Sixth line >> lines.lst
+    bzr commit -m 'Added sixth line to list.lst' \
+        --author $C --commit-time='1991-01-15 02:24:32 +0000'
+    popd
+    pushd C
+    bzr pull
+    perl -p -i -e 's/Second/2’nd/' lines.lst
+    bzr commit -m 'Replaced “Second” with “2’nd” in lines.lst' \
+        --author $A --commit-time='1992-01-16 04:22:33 +0400'
+    popd
+    pushd A
+    bzr merge ../B
+    bzr commit -m 'Merged B'
+    bzr merge ../C
+    bzr commit -m 'Merged C'
+    popd
+    pushd B
+    bzr pull
+    bzr rename lines.lst bzrlines.lst
+    echo 'Seventh line' >> bzrlines.lst
+    bzr commit -m 'Renamed lines.lst to bzrlines.lst, added seventh line' \
+        --author $C --commit-time='1993-01-01 00:00:00 +0000'
+    popd
+    pushd C
+    bzr pull
+    perl -p -i -e 's/Third/3’rd/' lines.lst
+    bzr commit -m 'Replaced “Third” with “3’rd”' \
+        --author $B --commit-time='1993-01-02 00:00:00 +0000'
+    popd
+    pushd A
+    bzr merge ../B
+    bzr commit -m 'Merged B' \
+        --author $A --commit-time='1993-01-02 00:00:00 +0000'
+    bzr merge ../C
+    bzr commit -m 'Merged C' \
+        --author $B --commit-time='1993-01-02 00:00:00 +0000'
+    popd
+    pushd A
+    mkdir subdir
+    bzr add subdir
+    bzr commit -m 'Added subdir' \
+        --author $C --commit-time='1993-01-02 00:00:00 +0000'
+    echo $'line 1\nline 2\nline 3\nline 4\nline 5' > subdir/sublines.lst
+    bzr add subdir/sublines.lst
+    bzr commit -m 'Added subdir/sublines.lst' \
+        --author $A --commit-time='1994-01-02 00:00:00 +0040'
+    popd
+    pushd A
+    bzr tag --revision -4 rev-4
+    bzr tag -- --force
+    bzr config parent_location=.
+    popd
+)
+tar cJf bzrtestrepo.tar.xz bzrtestrepo

File test/drivers-bazaar.ok

Binary file added.

File test/drivers-bazaar.vim

+let g:r=[]
+function FormatRepository(repo)
+    let g:r+=['>>> Repository']
+    let maxlen=len('brancheslist')
+    let g:r+=[' # Keys:']
+    for f in split('local path')
+        let g:r+=[' '.printf('%-*s', maxlen, f).':'.string(a:repo[f])]
+    endfor
+    let g:r+=[' # Properties:']
+    for p in split('tagslist brancheslist url branch')
+        let g:r+=[' '.printf('%-*s', maxlen, p).':'.
+                    \string(a:repo.functions.getrepoprop(a:repo, p))]
+    endfor
+endfunction
+function FormatCS(repo, cs)
+    let g:r+=[' >> Changeset']
+    let maxlen=len('description')
+    let g:r+=[' # Immediately available keys:']
+    for f in split('hex rev time description user parents branch tags')
+        let g:r+=['  '.printf('%-*s', maxlen, f).':'.string(a:cs[f])]
+    endfor
+    let g:r+=[' # Keys needed to be obtained by getcsprop:']
+    for p in split('allfiles renames changes files removes')
+        let g:r+=['  '.printf('%-*s', maxlen, p).':'.
+                    \string(a:repo.functions.getcsprop(a:repo, a:cs, p))]
+    endfor
+endfunction
+cd bzrtestrepo/A
+let Arepo=aurum#repository()
+cd -
+call FormatRepository(Arepo)
+let Acs=Arepo.functions.getwork(Arepo)
+call FormatCS(Arepo, Acs)
+for cs in Arepo.functions.getchangesets(Arepo)
+    call FormatCS(Arepo, cs)
+endfor
+
+call WriteFile(r)
+source addEmessages.vim