Commits

ZyX_I committed 03f4799

Implemented `closebranch' :AuCommit option support

Comments (0)

Files changed (4)

     endtry
     return r
 endfunction
-"▶3 hg.commit :: repo, message[, files[, user[, date[, force]]]]
+"▶3 hg.commit :: repo, message[, files[, user[, date[, closebranch[, force]]]]]
 function s:F.hg.commit(repo, message, ...)
     let args  =  'text=vim.eval("a:message"), '.
                 \'force='.((get(a:000, 3, 0))?('True'):('False')).', '.
-                \join(map(['files', 'user', 'date'],
+                \join(map(['files', 'user', 'date', 'close_branch'],
                 \         'v:val."=".(empty(a:000[v:key])?'.
                 \                       '"None":'.
                 \                       '"vim.eval(''a:".(v:key+1)."'')")'),
     elseif a:action is# 'commit'
         let epath=escape(bvar.repo.path, ':\')
         let files=filter(copy(bvar.files), 'bvar.statuses[v:key]>1')
-        aboveleft execute 'new' fnameescape('aurum://commit:'.epath.':::'.
+        aboveleft execute 'new' fnameescape('aurum://commit:'.epath.'::::'.
                     \join(map(copy(files), 'escape(v:val, "\\;")'), ';'))
         let cbvar=s:bufvars[bufnr('%')]
         let cbvar.sbvar=bvar
     if a:action is# 'commit'
         let message=join(getline(1, '$'), "\n")
         call bvar.repo.functions.commit(bvar.repo, message, bvar.files,
-                    \                   bvar.user, bvar.date)
+                    \                   bvar.user, bvar.date, bvar.closebranch)
         if !a:0
             bwipeout!
             stopinsert
         runtime ftplugin/aurumstatus.vim
     "▶3 commit command  (repo:user:date:files)
     elseif command is# 'commit'
-        let [repo, user, date, files]=s:F.comm.repotuplesplit(tail, 3)
-        let bvar={'repo': repo, 'user': user, 'date': date}
+        let [repo, user, date, cb, files]=s:F.comm.repotuplesplit(tail, 4)
+        let bvar={'repo': repo, 'user': user, 'date': date, 'closebranch': !!cb}
         let bvar.files=map(split(files, '\v%(\\@<!\\%(\\\\)*)@<!;'),
                     \      'substitute(v:val, ''\v\\([\;])'', "\\1", "g")')
         let s:bufvars[buf]=bvar
     let user=''
     let date=''
     let message=''
+    let cb=get(a:opts, 'closebranch', 0)
     for key in filter(['user', 'date', 'message'], 'has_key(a:opts, v:val)')
         let l:{key}=a:opts[key]
     endfor
         let euser=escape(user, ':\')
         execute 'silent new'
                     \fnameescape('aurum://commit:'.epath.':'.euser.':'.date.':'.
+                    \                                        cb.':'.
                     \            join(map(copy(files), 'escape(v:val, "\\;")'),
                     \                 ';'))
         startinsert
     else
-        call repo.functions.commit(repo, message, files, user, date)
+        call repo.functions.commit(repo, message, files, user, date,
+                    \              get(a:opts, 'closebranch', 0))
     endif
 endfunction
 let s:comfunc['@FWC']=['-onlystrings '.
     except FindError:
         pass
 
-def commit(path, text, force=False, user=None, date=None, files=None):
+def commit(path, text, force=False, user=None, date=None, files=None, close_branch=False):
     try:
         repo=g_repo(path)
         args=[ui.ui(), repo]
         if files:
             args.extend(files)
-        kwargs={'addremove': True, 'close_branch': False, 'message': text}
+        kwargs={'addremove': True, 'close_branch': close_branch, 'message': text}
         if date:
             kwargs['date']=date
         if user:

test/annotate-buffers.in

 :bwipeout!
 :bwipeout!
 :W{{{1 aurum://commit
-:silent edit aurum://commit:annotate-buffersrepo:::nohglinesrev.lst
+:silent edit aurum://commit:annotate-buffersrepo::::nohglinesrev.lst
 :AuAnnotate
 :call WriteFile(bufname('%'), bufname(winbufnr(winnr('#'))), bufname(winbufnr(winnr('$'))), 'w$: '.winnr('$').', w0: '.winnr().', w#: '.winnr('#'))
 :bwipeout!

test/annotate-buffers.ok

 {{{1 aurum://commit
 aurum://file:%TMPDIR%/test/annotate-buffersrepo:bd8865085771912fc9ab56425f385a1751696ec1:nohglinesrev.lst
 aurum://annotate:%TMPDIR%/test/annotate-buffersrepo:bd8865085771912fc9ab56425f385a1751696ec1:nohglinesrev.lst
-aurum://commit:annotate-buffersrepo:::nohglinesrev.lst
+aurum://commit:annotate-buffersrepo::::nohglinesrev.lst
 w$: 3, w0: 2, w#: 1
 {{{1 aurum://annotate 1
 aurum://file:%TMPDIR%/test/testrepo:6a040abfa9457d6066c8469fab4f9e3ae1f3e494:crepo.zsh