I added the ability to edit the log messages in another
VIM window. A feature I really missed. I didn't really
like the one line message prompts.
Anyway I've done some testing on this and so far
everythings seems to work. I did my best to not break
and functionality or how things worked. If I did it
right you should not even know there was a change
untill you set my veriable flag.
Also I made the input's into inputdialog. so in a gui
you can get a nice popup but in consol you get the
standard prompt.
Also the echo lines for aborts I added highlighting to
them to make them stand out.
Let me know what you think. Or if you need a full copy
and not a diff patch.
Repository: VimTools
Index: cvsmenu.vim
===================================================================
RCS file: /cvsroot/ezytools/VimTools/cvsmenu.vim,v
retrieving revision 1.79
diff -c -c -r1.79 cvsmenu.vim
*** cvsmenu.vim 15 May 2002 12:19:42 -0000 1.79
--- cvsmenu.vim 13 Jun 2002 19:13:50 -0000
***************
*** 61,66 ****
--- 61,69 ----
if !exists("g:CVSautocheck")
let g:CVSautocheck = 1 " do local status on every read file
endif
+ if !exists("g:CVSmultilinelogs")
+ let g:CVSmultilinelogs = 0 " Edit log
messages in editer.
+ endif
if !exists("g:CVSdefaultmsg")
let g:CVSdefaultmsg = '' " message to use for commands below
endif
***************
*** 449,456 ****
echo 'Mappings in output buffer :'
echo '<2-LeftMouse> , <SHIFT-CR> : open file
in new buffer'
echo 'q : close
output buffer'
! echo '? : close
output buffer'
! echo '<Leader>a : Show this help'
echo '<Leader>d : open file
and CVSdiff'
echo '<Leader>i : open file
and CVScommit'
echo '<Leader>u : open file
and CVSupdate'
--- 452,459 ----
echo 'Mappings in output buffer :'
echo '<2-LeftMouse> , <SHIFT-CR> : open file
in new buffer'
echo 'q : close
output buffer'
! echo '? : Show this help'
! echo '<Leader>a : open file
and CVSadd'
echo '<Leader>d : open file
and CVSdiff'
echo '<Leader>i : open file
and CVScommit'
echo '<Leader>u : open file
and CVSupdate'
***************
*** 700,705 ****
--- 703,715 ----
function! CVSDoCommand(cmd,...)
" needs to be called from orgbuffer
let isfile = CVSUsesFile()
+ " Don't execute CVS if the buffer hasn't been saved.
+ if (&modified > 0)
+ echohl Error
+ echo "Buffer has been modified. Command aborted."
+ echohl None
+ return
+ endif
" change to buffers directory
"exec 'cd '.expand('%:p:h')
call CVSChDir(expand('%:p:h'))
***************
*** 808,813 ****
--- 818,896 ----
endif
endfunction
+ " First step in multi lined log files.
+ function! CVSmultilinelogstart( cvs_cmd, ... )
+ " Added this to avoid some one typing a long log
only to find that
+ " there bufer was modified and the log was lost.
+ if (&modified == 1)
+ echohl Error
+ echo "Buffer has been modified. Command aborted."
+ echohl None
+ return
+ endif
+ let temp_log_file = tempname()
+ exec "new ".temp_log_file
+ exec "au BufWinLeave ".temp_log_file." :call
CVSmultilinelogfinish('".temp_log_file."','".a:cvs_cmd."')"
+ set ft=cvs
+ unlet temp_log_file
+ " End of file changes, Begining of file is always
0 So we put in a
+ " reverse order.
+ let @x = "CVS:
----------------------------------------------------------------------"
+ 1 put x
+ if (a:0 > 0)
+ let @x = "CVS: Arguments: ".a:1 | 1 put x
+ endif
+ let @x = "CVS: To ".a:cvs_cmd." with this log
save and close this window. (:wq or ZZ)"
+ 1 put x
+ let @x = "CVS: To cancle the ".a:cvs_cmd." close
this window WITHOUT SAVING. (:q! or ZQ)"
+ 1 put x
+ let @x = "CVS: Enter Log. Lines beginning with
`CVS:' are removed automatically"
+ 1 put x
+ let @x = "CVS:
----------------------------------------------------------------------"
+ 1 put x
+ 1 " goto beginning of file.
+ " The rest of the commit is executed in
CVSmultilinelogfinish
+ let &modified = 0
+ endfunction
+
+ " Cleans up multi line logs and execute command.
+ function! CVSmultilinelogfinish( log_name, cvs_cmd, ... )
+ "nmapclear <buffer>
+ exec "au! BufWinLeave ".a:log_name
+ " Allow the user to abort using :q!
+ if (&modified == 0 && filereadable(a:log_name))
+ " Remove any `CVS:' since the -F option to cvs does not.
+ global /^CVS:/ delete
+ write
+ close
+ " query revision (if wanted). Assume if arguments
given this is not
+ " needed.
+ if (g:CVSqueryrevision > 0 && a:0 == 0)
+ let rev=CVSInputRev('Revision (optional):')
+ else
+ let rev=''
+ endif
+ if rev!=''
+ let rev='-r '.rev.' '
+ elseif (a:0 > 0)
+ let rev = a:1
+ endif
+ " Added a kludge to support the join in funtion.
+ if (a:cvs_cmd == "add/commit")
+ call CVSsdd()
+ call CVSDoCommand('commit -F "'.a:log_name.'" '.rev)
+ call CVSLocalStatus()
+ else
+ call CVSDoCommand(a:cvs_cmd.' -F "'.a:log_name.'"
'.rev)
+ endif
+ unlet rev
+ else
+ echohl WarningMsg
+ echo "Quit without save. CVS ".a:cvs_cmd." aborted."
+ echohl None
+ endif
+ endfunction
+
"#############################################################################
" following commands read from STDIN. Call CVS directly
"#############################################################################
***************
*** 846,852 ****
"-----------------------------------------------------------------------------
function! CVSrelease()
! let localtoo=input('Release:Also delete local file
[y]:')
if (localtoo=='y') || (localtoo=='')
let localtoo='-d '
else
--- 929,935 ----
"-----------------------------------------------------------------------------
function! CVSrelease()
! let localtoo=inputdialog('Release:Also delete local
file [y]: ')
if (localtoo=='y') || (localtoo=='')
let localtoo='-d '
else
***************
*** 1008,1014 ****
else
let default = ''
endif
! let rev=input('Revisions (optional): ',default)
else
let rev=''
endif
--- 1091,1097 ----
else
let default = ''
endif
! let rev=inputdialog('Revisions (optional): ',default)
else
let rev=''
endif
***************
*** 1033,1039 ****
"-----------------------------------------------------------------------------
function! CVSQueryAction()
! let action=input('Action (e)dit, (u)nedit,
(c)ommit, (a)ll, [n]one:')
if action == 'e'
let action = '-a edit '
elseif action == 'u'
--- 1116,1122 ----
"-----------------------------------------------------------------------------
function! CVSQueryAction()
! let action=inputdialog('Action (e)dit, (u)nedit,
(c)ommit, (a)ll, [n]one: ')
if action == 'e'
let action = '-a edit '
elseif action == 'u'
***************
*** 1096,1102 ****
function! CVSDoTag(usertag,tagopt)
" force tagname input
! let tagname=escape(input('tagname:'),'"<>|&')
if tagname==''
echo 'CVS tag: aborted'
return
--- 1179,1185 ----
function! CVSDoTag(usertag,tagopt)
" force tagname input
! let tagname=escape(inputdialog('tagname: '),'"<>|&')
if tagname==''
echo 'CVS tag: aborted'
return
***************
*** 1104,1110 ****
" if rtag, force module instead local copy
if a:usertag > 0
let tagcmd = 'rtag '
! let module = input('Enter module name:')
if module == ''
echo 'CVS rtag: aborted'
return
--- 1187,1193 ----
" if rtag, force module instead local copy
if a:usertag > 0
let tagcmd = 'rtag '
! let module = inputdialog('Enter module name: ')
if module == ''
echo 'CVS rtag: aborted'
return
***************
*** 1117,1126 ****
endif
" g:CVSqueryrevision ?
" tag by date, revision or local
! let tagby=input('Tag by (d)ate, (r)evision
(default:none):')
if (tagby == 'd')
let tagby='-D '
! let tagwhat=input('Enter date:')
elseif (tagby == 'r')
let tagby='-r '
let tagwhat=CVSInputRev('Revision (optional):')
--- 1200,1209 ----
endif
" g:CVSqueryrevision ?
" tag by date, revision or local
! let tagby=inputdialog('Tag by (d)ate, (r)evision
(default:none): ')
if (tagby == 'd')
let tagby='-D '
! let tagwhat=inputdialog('Enter date: ')
elseif (tagby == 'r')
let tagby='-r '
let tagwhat=CVSInputRev('Revision (optional):')
***************
*** 1140,1146 ****
endif
" check if working file is unchanged (if not rtag)
if a:usertag == 0
! let checksync=input('Override sync check [n]:')
if (checksync == 'n') || (checksync == '')
let checksync='-c '
else
--- 1223,1229 ----
endif
" check if working file is unchanged (if not rtag)
if a:usertag == 0
! let checksync=inputdialog('Override sync check
[n]: ')
if (checksync == 'n') || (checksync == '')
let checksync='-c '
else
***************
*** 1284,1292 ****
function! CVSremove()
" remove from rep. also local ?
if g:CVSforcedirectory>0
! let localtoo=input('Remove:Also delete local
DIRECTORY [y]:')
else
! let localtoo=input('Remove:Also delete local file
[y]:')
endif
if (localtoo=='y') || (localtoo=='')
let localtoo='-f '
--- 1367,1375 ----
function! CVSremove()
" remove from rep. also local ?
if g:CVSforcedirectory>0
! let localtoo=inputdialog('Remove: Also delete
local DIRECTORY [y]: ')
else
! let localtoo=inputdialog('Remove: Also delete
local file [y]: ')
endif
if (localtoo=='y') || (localtoo=='')
let localtoo='-f '
***************
*** 1294,1302 ****
let localtoo=''
endif
" force confirmation
! let confrm=input('Remove:confirm with "y":')
if confrm!='y'
echo 'CVS remove: aborted'
return
endif
call CVSDoCommand('remove '.localtoo)
--- 1377,1387 ----
let localtoo=''
endif
" force confirmation
! let confrm=inputdialog('Remove: confirm with "y": ')
if confrm!='y'
+ echohl WarningMsg
echo 'CVS remove: aborted'
+ echohl None
return
endif
call CVSDoCommand('remove '.localtoo)
***************
*** 1308,1325 ****
"-----------------------------------------------------------------------------
function! CVSadd()
! if (g:CVSusedefaultmsg =~ 'a') && (g:CVSdefaultmsg
!= '')
! let message = g:CVSdefaultmsg
! else
! " force message input
! let message=escape(input('Message:'),'"<>|&')
! endif
! if message==""
! echo 'CVS add: aborted'
! return
! endif
! call CVSDoCommand('add -m "'.message.'"')
! unlet message
endfunction
"-----------------------------------------------------------------------------
--- 1393,1401 ----
"-----------------------------------------------------------------------------
function! CVSadd()
! " cvs add doesn't use a message it is ignored.
! " Use join in to add and commit in one command.
! call CVSDoCommand('add')
endfunction
"-----------------------------------------------------------------------------
***************
*** 1331,1340 ****
let message = g:CVSdefaultmsg
else
" force message input
! let message=escape(input('Message:'),'"<>|&')
endif
if message==''
echo 'CVS commit: aborted'
return
endif
" query revision (if wanted)
--- 1407,1423 ----
let message = g:CVSdefaultmsg
else
" force message input
! if (g:CVSmultilinelogs == 1)
! call CVSmultilinelogstart("commit")
! return
! else
! let message=escape(inputdialog('Message: '),'"<>|&')
! endif
endif
if message==''
+ echohl WarningMsg
echo 'CVS commit: aborted'
+ echohl None
return
endif
" query revision (if wanted)
***************
*** 1368,1379 ****
let message = g:CVSdefaultmsg
else
" force message input
! let message=escape(input('Message:'),'"<>|&')
! if message==""
! echo 'CVS add/commit: aborted'
! return
endif
endif
" query revision (if wanted)
if g:CVSqueryrevision > 0
let rev=CVSInputRev('Revision (optional):')
--- 1451,1469 ----
let message = g:CVSdefaultmsg
else
" force message input
! if (g:CVSmultilinelogs == 1)
! call CVSmultilinelogstart("add/commit")
! return
! else
! let message=escape(inputdialog('Message: '),'"<>|&')
endif
endif
+ if message==''
+ echohl WarningMsg
+ echo 'CVS add/commit: aborted'
+ echohl None
+ return
+ endif
" query revision (if wanted)
if g:CVSqueryrevision > 0
let rev=CVSInputRev('Revision (optional):')
***************
*** 1383,1389 ****
if rev!=''
let rev='-r '.rev.' '
endif
! call CVSDoCommand('add -m "'.message.'"')
call CVSDoCommand('commit -m "'.message.'" '.rev)
call CVSLocalStatus()
unlet message rev
--- 1473,1479 ----
if rev!=''
let rev='-r '.rev.' '
endif
! call CVSadd()
call CVSDoCommand('commit -m "'.message.'" '.rev)
call CVSLocalStatus()
unlet message rev
***************
*** 1405,1419 ****
let message = g:CVSdefaultmsg
else
" force message input
! let message=escape(input('Message:'),'"<>|&')
endif
if message==''
echo 'CVS import: aborted'
return
endif
" query branch (if wanted)
if g:CVSqueryrevision > 0
! let rev=input('Branch (optional):')
else
let rev=''
endif
--- 1495,1515 ----
let message = g:CVSdefaultmsg
else
" force message input
! if (g:CVSmultilinelogs == 1)
! let message = 'n/a'
! else
! let message=escape(inputdialog('Message: '),'"<>|&')
! endif
endif
if message==''
+ echohl WarningMsg
echo 'CVS import: aborted'
+ echohl None
return
endif
" query branch (if wanted)
if g:CVSqueryrevision > 0
! let rev=inputdialog('Branch (optional): ')
else
let rev=''
endif
***************
*** 1421,1446 ****
let rev='-b '.rev.' '
endif
" query vendor tag
! let vendor=input('Vendor tag:')
if vendor==''
echo 'CVS import: aborted'
return
endif
" query release tag
! let release=input('Release tag:')
if release==''
echo 'CVS import: aborted'
return
endif
" query module
! let module=input('Module:')
if module==''
echo 'CVS import: aborted'
return
endif
" only works on directories
! call CVSDoCommand('import -m "'.message.'"
'.rev.module.' '.vendor.' '.release)
! unlet message rev vendor release
endfunction
function! CVSimportrevision()
--- 1517,1552 ----
let rev='-b '.rev.' '
endif
" query vendor tag
! let vendor=inputdialog('Vendor tag: ')
if vendor==''
+ echohl WarningMsg
echo 'CVS import: aborted'
+ echohl None
return
endif
" query release tag
! let release=inputdialog('Release tag: ')
if release==''
+ echohl WarningMsg
echo 'CVS import: aborted'
+ echohl None
return
endif
" query module
! let module=inputdialog('Module: ')
if module==''
+ echohl WarningMsg
echo 'CVS import: aborted'
+ echohl None
return
endif
" only works on directories
! if (g:CVSmultilinelogs == 1)
! call CVSmultilinelogstart('import',
rev.module.' '.vendor.' '.release)
! else
! call CVSDoCommand('import -m "'.message.'"
'.rev.module.' '.vendor.' '.release)
! endif
! unlet message module rev vendor release
endfunction
function! CVSimportrevision()
***************
*** 1456,1466 ****
function! CVScheckout()
let destdir=expand('%:p:h')
! let destdir=input('Checkout to:',destdir)
if destdir==''
return
endif
! let module=input('Module name:')
if module==''
echo 'CVS checkout: aborted'
return
--- 1562,1572 ----
function! CVScheckout()
let destdir=expand('%:p:h')
! let destdir=inputdialog('Checkout to: ',destdir)
if destdir==''
return
endif
! let module=inputdialog('Module name: ')
if module==''
echo 'CVS checkout: aborted'
return
***************
*** 1600,1606 ****
else
let default = ''
endif
! return input(query,default)
endfunction
"-----------------------------------------------------------------------------
--- 1706,1712 ----
else
let default = ''
endif
! return inputdialog(query,default)
endfunction
"-----------------------------------------------------------------------------
***************
*** 1631,1638 ****
let fn = a:1
endif
if fn == '' " no name:query file and rep
! let rep=input("CVSROOT:")
! let fn=input("Filename:")
endif
" still no filename : abort
if fn == ''
--- 1737,1744 ----
let fn = a:1
endif
if fn == '' " no name:query file and rep
! let rep=inputdialog("CVSROOT: ")
! let fn=inputdialog("Filename: ")
endif
" still no filename : abort
if fn == ''
***************
*** 1709,1715 ****
function! CVSInstallAsHelp(...)
" ask for name to save as (if not given)
if (a:0 == 0) || (a:1 == '')
! let dest=input('Helpfilename (clear to abort):')
else
let dest=a:1
endif
--- 1815,1821 ----
function! CVSInstallAsHelp(...)
" ask for name to save as (if not given)
if (a:0 == 0) || (a:1 == '')
! let dest=inputdialog('Helpfilename (clear to
abort): ')
else
let dest=a:1
endif
***************
*** 1730,1736 ****
function! CVSInstallAsPlugin(...)
" ask for name to save as
if (a:0 == 0) || (a:1 == '')
! let dest=input('Pluginfilename (clear to
abort):',a:1)
else
let dest=a:1
endif
--- 1836,1842 ----
function! CVSInstallAsPlugin(...)
" ask for name to save as
if (a:0 == 0) || (a:1 == '')
! let dest=inputdialog('Pluginfilename (clear to
abort): ',a:1)
else
let dest=a:1
endif
Index: cvsmenu.txt
===================================================================
RCS file: /cvsroot/ezytools/VimTools/cvsmenu.txt,v
retrieving revision 1.34
diff -c -c -r1.34 cvsmenu.txt
*** cvsmenu.txt 3 May 2002 11:30:49 -0000 1.34
--- cvsmenu.txt 13 Jun 2002 19:14:33 -0000
***************
*** 148,153 ****
--- 148,155 ----
(0:off 1:on)
g:CVSdontswitch - Stay in current file on |CVS-Diff|
(0:off 1:on)
+ g:CVSmultilinelogs - Allow the editing of log
messages in a vim window
+ (0:off 1:on)
g:CVSjoininmessage - Message for |CVS-JoinIn|
(blank: query)
g:CVSfullstatus - Display all fields for fullstatus
Just in case posting didn't presurve spacing
optional inputdialog
Logged In: YES
user_id=208045
* There still seems to be a bug, wich lead to an empty
commit message, so you shouldnt use this patches in a
production environment.
* The GUI dialog should only be added as an option, as it
doesnt support browing through the last messages (and you'll
never know, where your WinMgr will throw it to).
Logged In: YES
user_id=28297
> * There still seems to be a bug, wich lead to an empty
> commit message, so you shouldnt use this patches in a
> production environment.
I'd like to reproduce this. What steps did you perform?
Logged In: YES
user_id=208045
I am not quite sure how it happened. In any case, it was run
on a whole directory and the commit should be aborted.
I hope, I will find time this weekend to have a deeper look into
it.