# HG changeset patch # User Ludovic Chabant # Date 1333146550 25200 # Node ID a63ec818ab216a535258e6ba25596bbb5762421e # Parent 42c40b8144f833f0d08888eb692b75abb9ee6f48 Added `qnew` and `qrefresh` commands to the `Hgstatus` window. diff -r 42c40b8144f8 -r a63ec818ab21 doc/lawrencium.txt --- a/doc/lawrencium.txt Thu Feb 23 21:25:48 2012 -0800 +++ b/doc/lawrencium.txt Fri Mar 30 15:29:10 2012 -0700 @@ -141,6 +141,19 @@ again. Mapped to . + *:Hgstatusqnew* +:Hgstatusqnew {patch} {message}. + If you have the 'mq' extension enabled, creates a new + patch with the file currently mentioned in the buffer, + or in the current selection. You must give a patch name, + and may optionally write a commit message for the patch + (without surrounding quotes). + + *:Hgstatusqrefresh* +:Hgstatusqrefresh If you have the 'mq' extension enabled, refreshes the + current patch with the files currently mentioned in the + buffer, or in the current selection. + *lawrencium-status-mappings* A few other mappings are available in the status window: diff -r 42c40b8144f8 -r a63ec818ab21 plugin/lawrencium.vim --- a/plugin/lawrencium.vim Thu Feb 23 21:25:48 2012 -0800 +++ b/plugin/lawrencium.vim Fri Mar 30 15:29:10 2012 -0700 @@ -370,6 +370,8 @@ command! -buffer -range Hgstatusaddremove :call s:HgStatus_AddRemove(, ) command! -buffer -range=% -bang Hgstatuscommit :call s:HgStatus_Commit(, , 0, 0) command! -buffer -range=% -bang Hgstatusvcommit :call s:HgStatus_Commit(, , 0, 1) + command! -buffer -range=% -nargs=+ Hgstatusqnew :call s:HgStatus_QNew(, , ) + command! -buffer -range=% Hgstatusqrefresh :call s:HgStatus_QRefresh(, ) " Add some handy mappings. if g:lawrencium_define_mappings @@ -463,6 +465,38 @@ call s:HgDiff('%:p', a:vertical) endfunction +function! s:HgStatus_QNew(linestart, lineend, patchname, ...) abort + " Get the selected filenames. + let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) + if len(l:filenames) == 0 + call s:error("No files in selection or file to create patch.") + endif + + " Run `Hg qnew` on those paths. + let l:repo = s:hg_repo() + call insert(l:filenames, a:patchname, 0) + if a:0 > 0 + call insert(l:filenames, '-m', 0) + let l:message = '"' . join(a:000, ' ') . '"' + call insert(l:filenames, l:message, 1) + endif + call l:repo.RunCommand('qnew', l:filenames) +endfunction + +function! s:HgStatus_QRefresh(linestart, lineend) abort + " Get the selected filenames. + let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) + if len(l:filenames) == 0 + call s:error("No files in selection or file to refresh the patch.") + endif + + " Run `Hg qrefresh` on those paths. + let l:repo = s:hg_repo() + call insert(l:filenames, '-s', 0) + call l:repo.RunCommand('qrefresh', l:filenames) +endfunction + + function! s:HgStatus_GetSelectedFile() abort let l:filenames = s:HgStatus_GetSelectedFiles() return l:filenames[0]