Mercurial > vim-lawrencium
changeset 116:7da11e029773
Revert files from the status window.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 24 Jan 2015 13:27:42 -0800 |
parents | 53a2c9403ba8 |
children | 2e38e754c896 |
files | plugin/lawrencium.vim |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin/lawrencium.vim Sat Dec 27 18:03:18 2014 -0800 +++ b/plugin/lawrencium.vim Sat Jan 24 13:27:42 2015 -0800 @@ -1014,6 +1014,7 @@ command! -buffer Hgstatusvdiffsum :call s:HgStatus_DiffSummary(2) command! -buffer Hgstatustabdiffsum :call s:HgStatus_DiffSummary(3) command! -buffer Hgstatusrefresh :call s:HgStatus_Refresh() + command! -buffer -range -bang Hgstatusrevert :call s:HgStatus_Revert(<line1>, <line2>, <bang>0) command! -buffer -range Hgstatusaddremove :call s:HgStatus_AddRemove(<line1>, <line2>) command! -buffer -range=% -bang Hgstatuscommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 0) command! -buffer -range=% -bang Hgstatusvcommit :call s:HgStatus_Commit(<line1>, <line2>, <bang>0, 1) @@ -1110,6 +1111,26 @@ call s:HgStatus_Refresh() endfunction +function! s:HgStatus_Revert(linestart, lineend, bang) 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 to revert in selection or current line.") + return + endif + + " Run `revert` on those paths. + " If the bang modifier is specified, revert with no backup. + let l:repo = s:hg_repo() + if a:bang + call insert(l:filenames, '-C', 0) + endif + call l:repo.RunCommand('revert', l:filenames) + + " Refresh the status window. + call s:HgStatus_Refresh() +endfunction + function! s:HgStatus_Commit(linestart, lineend, bang, vertical) abort " Get the selected filenames. let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R'])