Mercurial > vim-lawrencium
changeset 18:4f04d5e052eb
Abort commit if the commit message is empty.
Slightly better error reporting.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 13 Dec 2011 17:30:14 -0800 |
parents | 5c6c605d0660 |
children | 7543d240232c |
files | plugin/lawrencium.vim |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin/lawrencium.vim Tue Dec 13 17:18:08 2011 -0800 +++ b/plugin/lawrencium.vim Tue Dec 13 17:30:14 2011 -0800 @@ -62,6 +62,11 @@ endif endfunction +" Prints an error message with 'lawrencium error' prefixed to it. +function! s:error(message) + echom "lawrencium error: " . a:message +endfunction + " Throw a Lawrencium exception message. function! s:throw(message) let v:errmsg = "lawrencium: " . a:message @@ -260,7 +265,7 @@ if filereadable(s:usage_file) execute "source " . s:usage_file else - echoerr "Can't find the Mercurial usage file. Auto-completion will be disabled in Lawrencium." + call s:error("Can't find the Mercurial usage file. Auto-completion will be disabled in Lawrencium.") endif function! s:CompleteHg(ArgLead, CmdLine, CursorPos) @@ -401,7 +406,7 @@ let l:filename = s:HgStatus_GetSelectedPath() let l:status = s:HgStatus_GetSelectedStatus() if l:status !=# '?' - echoerr "Not an untracked file: " . l:filename + call s:error("Not an untracked file: " . l:filename) endif " Add the file. @@ -582,15 +587,21 @@ function! s:HgCommit_Execute(log_file, show_output) abort " Check if the user actually saved a commit message. if !filereadable(a:log_file) - call s:trace("Commit message was not saved... abort commit.", 1) + call s:error("abort: Commit message not saved") return endif call s:trace("Committing with log file: " . a:log_file) - " Clean up all the 'HG:' lines from the commit message. + " Clean up all the 'HG:' lines from the commit message, and see if there's + " any message left (Mercurial does this automatically, usually, but + " apparently not when you feed it a log file...). let l:lines = readfile(a:log_file) call filter(l:lines, "v:val !~# '\\v^HG:'") + if len(filter(copy(l:lines), "v:val !~# '\\v^\\s*$'")) == 0 + call s:error("abort: Empty commit message") + return + endif call writefile(l:lines, a:log_file) " Get the repo and commit with the given message.