Commits

ZyX_I committed cfb6d61

@aurum: Fixed :AuUpdate: it now uses rf-gettiphex() instead of rf-getrevhex("tip")
@aurum/drivers/git: Fixed rf-commit(): typo, missing variable initialization, missing argument to s:F.gitm()
Fixed rf-revrange(): now better handling of range [-N, -1]
Fixed s:F.parsecs(): now it does not assume that commit message is always terminated by an empty line
tests: Fixed :WT: it uses limit instead of relying on "tip" being a name of latest revision

  • Participants
  • Parent commits da33c7c

Comments (0)

Files changed (5)

File plugin/aurum.vim

 function s:updfunc.function(bang, rev, repopath)
     let repo=s:_r.repo.get(a:repopath)
     call s:_r.cmdutils.checkrepo(repo)
-    let rev=repo.functions.getrevhex(repo, a:rev)
+    if a:rev is 0
+        let rev=repo.functions.gettiphex(repo)
+    else
+        let rev=repo.functions.getrevhex(repo, a:rev)
+    endif
     return repo.functions.update(repo, rev, a:bang)
 endfunction
 let s:updfunc['@FWC']=['-onlystrings _ '.
-            \          '[:"tip" type ""'.
+            \          '[:=(0) type ""'.
             \          '['.s:_r.cmdutils.nogetrepoarg.']]', 'filter']
 call add(s:updcomp,
             \substitute(substitute(substitute(s:updfunc['@FWC'][0],
             \'\V _',                '',            ''),
             \'\V|*_r.repo.get',     '',            ''),
-            \'\V:"tip"\s\+type ""', s:_r.comp.rev, ''))
+            \'\V:=(0)\s\+type ""', s:_r.comp.rev, ''))
 "▶1 movefunc
 " :AuM          — move current file to current directory
 " :AuM dir      — move current file to given directory

File plugin/aurum/drivers/git.vim

             \           'in the repository %s: %s',
             \    'csf': 'Failed to obtain information about revision %s '.
             \           'in the repository %s: %s',
+            \    'cif': 'Failed to commit changes to the repository %s: %s',
             \   'updf': 'Failed to checkout commit %s in the repository %s: %s',
             \    'mvf': 'Failed to move file %s to %s in the repository %s: %s',
             \    'rmf': 'Failed to remove file %s in the repository %s: %s',
     let cs.bookmarks=[]
     "▶2 get description
     let description=[]
-    while a:csdata[line][0] is# ' '
+    let lcsdata=len(a:csdata)
+    while line<lcsdata && a:csdata[line][0] is# ' '
         let description+=[a:csdata[line][1:]]
         let line+=1
     endwhile
     let cs.description=join(description, "\n")
-    let line+=1
+    if empty(get(a:csdata, line, 0))
+        let line+=1
+    endif
     "▲2
     return [cs, line]
 endfunction
 function s:git.getchangesets(repo, ...)
     "▶2 Prepare s:F.git arguments
     let args=[]
+    let kwargs=copy(s:logkwargs)
     if a:0
         if a:1 is 0
+        elseif a:1<0 && a:2 is -1
+            let args+=['-n'.(-a:1), 'HEAD']
         else
-            let args+=[s:F.rerev(a:1).'..'.s:F.rerev(a:2)]
+            let args+=[s:F.rerev(a:1).'^..'.s:F.rerev(a:2)]
         endif
+    else
+        let kwargs.all=1
+        let kwargs['full-history']=1
     endif
-    let gitargs=[a:repo, 'log', args, extend({'all': 1, 'full-history': 1},
-                \                            s:logkwargs), 0]
+    let gitargs=[a:repo, 'log', args, kwargs, 0]
     if a:0
         let gitargs+=['rlogf', a:1, a:2]
     else
     endwhile
     return r
 endfunction
-"▶1 git.commit :: message[, files[, user[, date[, _]]]]
-function s:git.commit(message, ...)
+"▶1 git.commit :: repo, message[, files[, user[, date[, _]]]]
+function s:git.commit(repo, message, ...)
     let kwargs={'cleanup': 'verbatim'}
+    let usingfile=0
     if a:message=~#'\v[\r\n]'
         let tmpfile=tempname()
         call writefile(split(a:message, "\n", 1), tmpfile, 'b')
         endif
     endif
     try
-        return s:F.gitm(a:repo, args, kwargs, 0, 'cif')
+        return s:F.gitm(a:repo, 'commit', args, kwargs, 0, 'cif')
     finally
         if usingfile && filereadable(tmpfile)
             call delete(tmpfile)
     if a:rev is 0
         let kwargs.d=1
     else
-        lat args+=[a:rev]
+        let args+=[a:rev]
     endif
     return s:F.gitm(a:repo, a:type, args, kwargs, 0,
                 \   'lbf', a:type, a:label, a:rev)
+:let $LANG="C"
+:let g:curtest='gittest'
+:W{{{1 Annotate
+:Run! AuAnnotate file ./gittestrepo/* | wincmd w
+:bwipeout!
+:bwipeout!
+:W{{{1 Branch
+:Run! AuBranch next3 repo ./gittestrepo/
+:WT
 :W{{{1 Log: nomerges
 :Run! AuLog ./gittestrepo/ nomerges
 :bwipeout!
 :W{{{1 Status: between two revisions
 :Run! AuStatus ./gittestrepo/ rev1 erevision rev2 next
 :bwipeout!
-:W{{{1 Annotate
-:Run! AuAnnotate file ./gittestrepo/* | wincmd w
+:W{{{1 Commit
+:edit ./gittestrepo/newfile.vim
+iW In file newfile.vim:write
+:Run! AuCommit message Added\ newfile.vim date 1990-10-11 user ZyX\ <zyx@example.by> type unknown ./gittestrepo/newfile.vim
+:WT normal! ggdd
+:W{{{1 Commit 2
+oW File newfile.vim, second line:write
+:Run! AuCommit date 1990-10-12 user ZyX\ <zyx@example.by>
+Added second line to newfile.vim
+// It was not required really:write
+:WT normal! ggdd

File test/git.ok

Binary file modified.
 endfunction
 command -nargs=1 -bar W call WriteFile(<q-args>)
 function s:WriteTip(writecom, cmd)
-    R AuLog revrange tip tip
+    R AuLog limit 1
     setlocal modifiable noreadonly
     if !a:writecom
         g/Commited/delete _