From 402927176379f57ccf5e65bfd6e986f6126d2045 Mon Sep 17 00:00:00 2001 From: Bob Hiestand Date: Wed, 28 Feb 2007 17:39:12 +0000 Subject: [PATCH] r18@localhost: bob | 2007-02-28 09:32:57 -0600 Added SVK support. Replaced SVN-specific command SVNInfo with VCSInfo, which is defined for SVK and SVN. This is mapped to 'ci' by default; as a consequence, the default mapping for the CVS-specific CVSEditors command was changed to 'cE'. Made VCSAnnotate accept parameters to pass to the underlying VCS. Made error messages for operations on non-versioned files more consistent. Added check to disable individual VCS extension plugins. git-svn-id: https://vcscommand.googlecode.com/svn/trunk@11 e7462f97-9721-0410-a4e7-d7c98e439057 --- doc/vcscommand.txt | 43 +++---- plugin/vcscommand.vim | 347 ++++++++++++++++++++++++++++---------------------- plugin/vcscvs.vim | 81 ++++++------ plugin/vcssvk.vim | 257 +++++++++++++++++++++++++++++++++++++ plugin/vcssvn.vim | 146 ++++++++------------- 5 files changed, 572 insertions(+), 302 deletions(-) create mode 100644 plugin/vcssvk.vim diff --git a/doc/vcscommand.txt b/doc/vcscommand.txt index 6b16cfe..b996ec1 100644 --- a/doc/vcscommand.txt +++ b/doc/vcscommand.txt @@ -40,11 +40,11 @@ Credits: Benji Fisher's excellent MatchIt documentation 2. vcscommand Installation *vcscommand-install* -The vcscommand plugin comprises four files, vcscommand.vim, vcssvn.vim, -vcscvs.vim and vcscommand.txt (this file). In order to install the plugin, -place the vcscommand.vim, vcssvn.vim, and vcscvs.vim files into a plugin -directory in your runtime path (please see |add-global-plugin| and -|'runtimepath'|. +The vcscommand plugin comprises five files: vcscommand.vim, vcssvn.vim, +vcscvs.vim, vcssvk.vim and vcscommand.txt (this file). In order to install +the plugin, place the vcscommand.vim, vcssvn.vim, vcssvk.vim, and vcscvs.vim +files into a plugin directory in your runtime path (please see +|add-global-plugin| and |'runtimepath'|. This help file can be included in the VIM help system by copying it into a 'doc' directory in your runtime path and then executing the |:helptags| @@ -122,10 +122,6 @@ The following commands are specific to CVS files: |:CVSWatchRemove| |:CVSWatchers| -The following commands are specific to SVN files: - -|:SVNInfo| - :VCSAdd *:VCSAdd* This command adds the current file to source control. Please note, this does @@ -141,9 +137,9 @@ it uses the most recent version of the file (on the current branch, if under CVS control). Additionally, if the current buffer is a VCSAnnotate buffer already, the version number on the current line is used. -The filetype of the vcscommand scratch buffer is set to either 'CVSAnnotate' -or 'SVNAnnotate' as appropriate, to take advantage of the bundled syntax -files. +The filetype of the vcscommand scratch buffer is set to one of 'CVSAnnotate', +'SVNAnnotate', or 'SVKAnnotate' as appropriate, to take advantage of the +bundled syntax files. :VCSCommit[!] *:VCSCommit* @@ -199,6 +195,11 @@ buffer. Like ":VCSGotoOriginal" but also executes :bufwipeout on all VCS scrach buffers associated with the original file. +:VCSInfo *:VCSInfo* + +This command displays extended information about the current file in a new +scratch buffer. + :VCSLock *:VCSLock* This command locks the current file in order to prevent other users from @@ -303,11 +304,6 @@ This command is an alias for ":CVSWatch remove" This command performs "cvs watchers" on the current file. -:SVNInfo *:SVNInfo* - -This command performs "svn info" on the current file. All parameters are -passed directly to svn. - 4.2 Mappings *vcscommand-mappings* By default, a mapping is defined for each command. These mappings execute the @@ -319,6 +315,7 @@ default (no-argument) form of each command. cd VCSDiff cg VCSGotoOriginal cG VCSGotoOriginal! +ci VCSInfo cl VCSLog cr VCSReview cs VCSStatus @@ -328,7 +325,7 @@ default (no-argument) form of each command. Only for CVS buffers: ce CVSEdit -ci CVSEditors +cE CVSEditors ct CVSUnedit cwv CVSWatchers cwa CVSWatchAdd @@ -336,10 +333,6 @@ Only for CVS buffers: cwf CVSWatchOff cwf CVSWatchRemove -Only for SVN buffers: - -ci SVNInfo - *vcscommand-mappings-override* The default mappings can be overriden by user-provided instead by mapping to @@ -407,6 +400,7 @@ The following variables are available: |VCSCommandResultBufferNameExtension| |VCSCommandResultBufferNameFunction| |VCSCommandSplit| +|VCSCommandSVKExec| |VCSCommandSVNDiffExt| |VCSCommandSVNDiffOpt| |VCSCommandSVNExec| @@ -483,6 +477,11 @@ one another. If set to 'vertical', the resulting windows will be side-by-side. If not set, it defaults to 'horizontal' for all but VCSVimDiff windows. +VCSCommandSVKExec *VCSCommandSVKExec* + +This variable controls the executable used for all SVK commands If not set, +it defaults to "svk". + VCSCommandSVNDiffExt *VCSCommandSVNDiffExt* This variable, if set, is passed to SVN via the --diff-cmd command to select diff --git a/plugin/vcscommand.vim b/plugin/vcscommand.vim index 41414e1..cbfaf44 100644 --- a/plugin/vcscommand.vim +++ b/plugin/vcscommand.vim @@ -2,7 +2,7 @@ " " Vim plugin to assist in working with files under control of CVS or SVN. " -" Version: Beta 11 +" Version: Beta 12 " Maintainer: Bob Hiestand " License: " Copyright (c) 2007 Bob Hiestand @@ -85,6 +85,9 @@ " scratch buffer. If VCSGotoOriginal[!] is used, remove all " VCS scratch buffers associated with the original file. " +" VCSInfo Displays extended information about the current file in a +" new scratch buffer. +" " VCSLock Locks the current file in order to prevent other users from " concurrently modifying it. The exact semantics of this " command depend on the underlying VCS. @@ -149,6 +152,7 @@ " cd VCSDiff " cg VCSGotoOriginal " cG VCSGotoOriginal! +" ci VCSInfo " cl VCSLog " cL VCSLock " cr VCSReview @@ -297,6 +301,14 @@ unlet! s:vimDiffScratchList " Section: Utility functions {{{1 +" Function: s:ReportError(mapping) {{{2 +" Displays the given error in a consistent faction. This is intended to be +" invoked from a catch statement. + +function! s:ReportError(error) + echohl WarningMsg|echomsg 'VCSCommand: ' . a:error|echohl None +endfunction + " Function: s:ExecuteExtensionMapping(mapping) {{{2 " Invokes the appropriate extension mapping depending on the type of the " current buffer. @@ -313,24 +325,44 @@ function! s:ExecuteExtensionMapping(mapping) silent execute 'normal' ':' . s:extendedMappings[vcsType][a:mapping] . "\" endfunction -" Function: s:ExecuteVCSCommand(command, buffer, argList) {{{2 -" Calls the indicated plugin-specific VCS command on the indicated buffer. +" Function: s:ExecuteVCSCommand(command, argList) {{{2 +" Calls the indicated plugin-specific VCS command on the current buffer. " Returns: buffer number of resulting output scratch buffer, or -1 if an error " occurs. -function! s:ExecuteVCSCommand(command, buffer, argList) +function! s:ExecuteVCSCommand(command, argList, verifyBuffer) try - let vcsType = VCSCommandGetVCSType(a:buffer) + let buffer = bufnr('%') + + let vcsType = VCSCommandGetVCSType(buffer) if !has_key(s:plugins, vcsType) throw 'Unknown VCS type: ' . vcsType endif + + let originalBuffer = VCSCommandGetOriginalBuffer(buffer) + let bufferName = bufname(originalBuffer) + if !isdirectory(bufferName) && !filereadable(bufferName) + throw 'No such file ' . bufferName + endif + + if(a:verifyBuffer) + let revision = VCSCommandGetRevision() + if revision == '' + throw 'Unable to obtain version information.' + elseif revision == 'Unknown' + throw 'Item not under source control' + elseif revision == 'New' + throw 'Operation not available on newly-added item.' + endif + endif + let functionMap = s:plugins[vcsType] if !has_key(functionMap, a:command) throw 'Command ''' . a:command . ''' not implemented for ' . vcsType endif return functionMap[a:command](a:argList) catch - echohl WarningMsg|echomsg v:exception|echohl None + call s:ReportError(v:exception) return -1 endtry endfunction @@ -393,7 +425,7 @@ endfunction " overridden with the VCSResultBufferNameFunction variable. function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText) - let fileName=bufname(a:originalBuffer) + let fileName = bufname(a:originalBuffer) let bufferName = a:vcsType . ' ' . a:command if strlen(a:statusText) > 0 let bufferName .= ' ' . a:statusText @@ -413,7 +445,7 @@ endfunction " file name with the VCS type and command appended as extensions. function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText) - let fileName=bufname(a:originalBuffer) + let fileName = bufname(a:originalBuffer) let bufferName = a:vcsType . ' ' . a:command if strlen(a:statusText) > 0 let bufferName .= ' ' . a:statusText @@ -463,7 +495,7 @@ function! s:EditFile(command, originalBuffer, statusText) set buftype=nofile set noswapfile - let &filetype=vcsType . a:command + let &filetype = vcsType . a:command if a:statusText != '' let b:VCSCommandStatusText = a:statusText @@ -506,7 +538,7 @@ function! s:SetupBuffer() let b:VCSCommandBufferInfo = [] endtry - let b:VCSCommandBufferSetup=1 + let b:VCSCommandBufferSetup = 1 endfunction " Function: s:MarkOrigBufferForSetup(buffer) {{{2 @@ -579,7 +611,7 @@ function! s:VimDiffRestore(vimDiffBuff) " All scratch buffers are gone, reset the original. " Only restore if the source buffer is still in Diff mode - let sourceWinNR=bufwinnr(s:vimDiffSourceBuffer) + let sourceWinNR = bufwinnr(s:vimDiffSourceBuffer) if sourceWinNR != -1 " The buffer is visible in at least one window let currentWinNR = winnr() @@ -618,46 +650,50 @@ function! s:VimDiffRestore(vimDiffBuff) endtry endfunction - " Section: Generic VCS command functions {{{1 " Function: s:VCSCommit() {{{2 function! s:VCSCommit(bang, message) - let vcsType = VCSCommandGetVCSType(bufnr('%')) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif + try + let vcsType = VCSCommandGetVCSType(bufnr('%')) + if !has_key(s:plugins, vcsType) + throw 'Unknown VCS type: ' . vcsType + endif - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) + let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - " Handle the commit message being specified. If a message is supplied, it - " is used; if bang is supplied, an empty message is used; otherwise, the - " user is provided a buffer from which to edit the commit message. + " Handle the commit message being specified. If a message is supplied, it + " is used; if bang is supplied, an empty message is used; otherwise, the + " user is provided a buffer from which to edit the commit message. - if strlen(a:message) > 0 || a:bang == '!' - return s:VCSFinishCommit([a:message], originalBuffer) - endif + if strlen(a:message) > 0 || a:bang == '!' + return s:VCSFinishCommit([a:message], originalBuffer) + endif - call s:EditFile('commitlog', originalBuffer, '') - set ft=vcscommit + call s:EditFile('commitlog', originalBuffer, '') + set ft=vcscommit - " Create a commit mapping. + " Create a commit mapping. - nnoremap VCSCommit :call VCSFinishCommitWithBuffer() + nnoremap VCSCommit :call VCSFinishCommitWithBuffer() - silent 0put ='VCS: ----------------------------------------------------------------------' - silent put ='VCS: Please enter log message. Lines beginning with ''VCS:'' are removed automatically.' - silent put ='VCS: To finish the commit, Type cc (or your own VCSCommit mapping)' + silent 0put ='VCS: ----------------------------------------------------------------------' + silent put ='VCS: Please enter log message. Lines beginning with ''VCS:'' are removed automatically.' + silent put ='VCS: To finish the commit, Type cc (or your own VCSCommit mapping)' - if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1 - set buftype=acwrite - au VCSCommandCommit BufWriteCmd call s:VCSFinishCommitWithBuffer() - silent put ='VCS: or write this buffer' - endif + if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1 + set buftype=acwrite + au VCSCommandCommit BufWriteCmd call s:VCSFinishCommitWithBuffer() + silent put ='VCS: or write this buffer' + endif - silent put ='VCS: ----------------------------------------------------------------------' - $ - set nomodified + silent put ='VCS: ----------------------------------------------------------------------' + $ + set nomodified + catch + call s:ReportError(v:exception) + return -1 + endtry endfunction " Function: s:VCSFinishCommitWithBuffer() {{{2 @@ -684,7 +720,7 @@ function! s:VCSFinishCommit(logMessageList, originalBuffer) let messageFileName = tempname() call writefile(a:logMessageList, messageFileName) try - let resultBuffer = s:ExecuteVCSCommand('Commit', a:originalBuffer, [messageFileName]) + let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName], 0) if resultBuffer < 0 return resultBuffer endif @@ -722,121 +758,126 @@ endfunction " Function: s:VCSVimDiff(...) {{{2 function! s:VCSVimDiff(...) - let vcsType = VCSCommandGetVCSType(bufnr('%')) - if !has_key(s:plugins, vcsType) - throw 'Unknown VCS type: ' . vcsType - endif - let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) - let s:isEditFileRunning = s:isEditFileRunning + 1 try - " If there's already a VimDiff'ed window, restore it. - " There may only be one VCSVimDiff original window at a time. - - if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer - " Clear the existing vimdiff setup by removing the result buffers. - call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') + let vcsType = VCSCommandGetVCSType(bufnr('%')) + if !has_key(s:plugins, vcsType) + throw 'Unknown VCS type: ' . vcsType endif + let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) + let s:isEditFileRunning = s:isEditFileRunning + 1 + try + " If there's already a VimDiff'ed window, restore it. + " There may only be one VCSVimDiff original window at a time. - " Split and diff - if(a:0 == 2) - " Reset the vimdiff system, as 2 explicit versions were provided. - if exists('s:vimDiffSourceBuffer') + if exists('s:vimDiffSourceBuffer') && s:vimDiffSourceBuffer != originalBuffer + " Clear the existing vimdiff setup by removing the result buffers. call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') endif - let resultBuffer = s:plugins[vcsType].Review([a:1]) - if resultBuffer < 0 - echomsg 'Can''t open revision ' . a:1 - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - let s:vimDiffScratchList = [resultBuffer] - " If no split method is defined, cheat, and set it to vertical. - try - call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical'))) - let resultBuffer=s:plugins[vcsType].Review([a:2]) - finally - call s:OverrideOption('VCSCommandSplit') - endtry - if resultBuffer < 0 - echomsg 'Can''t open revision ' . a:1 - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - let s:vimDiffScratchList += [resultBuffer] - else - " Add new buffer - call s:OverrideOption('VCSCommandEdit', 'split') - try - " Force splitting behavior, otherwise why use vimdiff? - call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical'))) + + " Split and diff + if(a:0 == 2) + " Reset the vimdiff system, as 2 explicit versions were provided. + if exists('s:vimDiffSourceBuffer') + call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') + endif + let resultBuffer = s:plugins[vcsType].Review([a:1]) + if resultBuffer < 0 + echomsg 'Can''t open revision ' . a:1 + return resultBuffer + endif + let b:VCSCommandCommand = 'vimdiff' + diffthis + let s:vimDiffScratchList = [resultBuffer] + " If no split method is defined, cheat, and set it to vertical. try - if(a:0 == 0) - let resultBuffer=s:plugins[vcsType].Review([]) - else - let resultBuffer=s:plugins[vcsType].Review([a:1]) - endif + call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical'))) + let resultBuffer = s:plugins[vcsType].Review([a:2]) finally call s:OverrideOption('VCSCommandSplit') endtry - finally - call s:OverrideOption('VCSCommandEdit') - endtry - if resultBuffer < 0 - echomsg 'Can''t open current revision' - return resultBuffer - endif - let b:VCSCommandCommand = 'vimdiff' - diffthis - - if !exists('s:vimDiffSourceBuffer') - " New instance of vimdiff. - let s:vimDiffScratchList = [resultBuffer] - - " This could have been invoked on a VCS result buffer, not the - " original buffer. - wincmd W - execute 'buffer' originalBuffer - " Store info for later original buffer restore - let s:vimDiffRestoreCmd = - \ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')' - \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')' - \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')' - \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')' - \ . '|if &foldmethod==''manual''|execute ''normal zE''|endif' + if resultBuffer < 0 + echomsg 'Can''t open revision ' . a:1 + return resultBuffer + endif + let b:VCSCommandCommand = 'vimdiff' diffthis - wincmd w - else - " Adding a window to an existing vimdiff let s:vimDiffScratchList += [resultBuffer] + else + " Add new buffer + call s:OverrideOption('VCSCommandEdit', 'split') + try + " Force splitting behavior, otherwise why use vimdiff? + call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical'))) + try + if(a:0 == 0) + let resultBuffer = s:plugins[vcsType].Review([]) + else + let resultBuffer = s:plugins[vcsType].Review([a:1]) + endif + finally + call s:OverrideOption('VCSCommandSplit') + endtry + finally + call s:OverrideOption('VCSCommandEdit') + endtry + if resultBuffer < 0 + echomsg 'Can''t open current revision' + return resultBuffer + endif + let b:VCSCommandCommand = 'vimdiff' + diffthis + + if !exists('s:vimDiffSourceBuffer') + " New instance of vimdiff. + let s:vimDiffScratchList = [resultBuffer] + + " This could have been invoked on a VCS result buffer, not the + " original buffer. + wincmd W + execute 'buffer' originalBuffer + " Store info for later original buffer restore + let s:vimDiffRestoreCmd = + \ 'call setbufvar('.originalBuffer.', ''&diff'', '.getbufvar(originalBuffer, '&diff').')' + \ . '|call setbufvar('.originalBuffer.', ''&foldcolumn'', '.getbufvar(originalBuffer, '&foldcolumn').')' + \ . '|call setbufvar('.originalBuffer.', ''&foldenable'', '.getbufvar(originalBuffer, '&foldenable').')' + \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')' + \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')' + \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')' + \ . '|if &foldmethod==''manual''|execute ''normal zE''|endif' + diffthis + wincmd w + else + " Adding a window to an existing vimdiff + let s:vimDiffScratchList += [resultBuffer] + endif endif - endif - let s:vimDiffSourceBuffer = originalBuffer + let s:vimDiffSourceBuffer = originalBuffer - " Avoid executing the modeline in the current buffer after the autocommand. + " Avoid executing the modeline in the current buffer after the autocommand. - let currentBuffer = bufnr('%') - let saveModeline = getbufvar(currentBuffer, '&modeline') - try - call setbufvar(currentBuffer, '&modeline', 0) - silent do VCSCommand User VCSVimDiffFinish + let currentBuffer = bufnr('%') + let saveModeline = getbufvar(currentBuffer, '&modeline') + try + call setbufvar(currentBuffer, '&modeline', 0) + silent do VCSCommand User VCSVimDiffFinish + finally + call setbufvar(currentBuffer, '&modeline', saveModeline) + endtry + return resultBuffer finally - call setbufvar(currentBuffer, '&modeline', saveModeline) + let s:isEditFileRunning = s:isEditFileRunning - 1 endtry - return resultBuffer - finally - let s:isEditFileRunning = s:isEditFileRunning - 1 + catch + call s:ReportError(v:exception) + return -1 endtry endfunction " Section: Public functions {{{1 -" Function: VCSCommandGetVCSType(buffer) {{{2 -" Sets the b:VCSCommandVCSType variable in the current buffer to the +" Function: VCSCommandGetVCSType() {{{2 +" Sets the b:VCSCommandVCSType variable in the given buffer to the " appropriate source control system name. function! VCSCommandGetVCSType(buffer) @@ -857,8 +898,8 @@ endfunction " Go to the directory in which the given file is located. function! VCSCommandChangeToCurrentFileDir(fileName) - let oldCwd=getcwd() - let newCwd=fnamemodify(resolve(a:fileName), ':p:h') + let oldCwd = getcwd() + let newCwd = fnamemodify(resolve(a:fileName), ':p:h') if strlen(newCwd) > 0 execute 'cd' escape(newCwd, ' ') endif @@ -908,7 +949,7 @@ function! VCSCommandDoCommand(cmd, cmdName, statusText) throw 'Original buffer no longer exists, aborting.' endif - let fileName=bufname(originalBuffer) + let fileName = resolve(bufname(originalBuffer)) " Work with netrw or other systems where a directory listing is displayed in " a buffer. @@ -916,13 +957,13 @@ function! VCSCommandDoCommand(cmd, cmdName, statusText) if isdirectory(fileName) let realFileName = '.' else - let realFileName = fnamemodify(resolve(fileName), ':t') + let realFileName = fnamemodify(fileName, ':t') endif - let oldCwd=VCSCommandChangeToCurrentFileDir(fileName) + let oldCwd = VCSCommandChangeToCurrentFileDir(fileName) try let fullCmd = a:cmd . ' "' . realFileName . '"' - let resultBuffer=s:CreateCommandBuffer(fullCmd, a:cmdName, originalBuffer, a:statusText) + let resultBuffer = s:CreateCommandBuffer(fullCmd, a:cmdName, originalBuffer, a:statusText) return resultBuffer finally execute 'cd' escape(oldCwd, ' ') @@ -1012,19 +1053,20 @@ endfunction " Section: Command definitions {{{1 " Section: Primary commands {{{2 -com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', bufnr('%'), [])) -com! -nargs=? VCSAnnotate call s:ExecuteVCSCommand('Annotate', bufnr('%'), []) +com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', [], 0)) +com! -nargs=* VCSAnnotate call s:ExecuteVCSCommand('Annotate', [], 1) com! -nargs=? -bang VCSCommit call s:VCSCommit(, ) -com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', bufnr('%'), []) -com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', bufnr('%'), []) +com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', [], 1) +com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', [], 1) com! -nargs=0 -bang VCSGotoOriginal call s:VCSGotoOriginal() -com! -nargs=* VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', bufnr('%'), [])) -com! -nargs=* VCSLog call s:ExecuteVCSCommand('Log', bufnr('%'), []) -com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', bufnr('%'), [])) -com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', bufnr('%'), []) -com! -nargs=* VCSStatus call s:ExecuteVCSCommand('Status', bufnr('%'), []) -com! -nargs=* VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', bufnr('%'), [])) -com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', bufnr('%'), [])) +com! -nargs=* VCSInfo call s:ExecuteVCSCommand('Info', [], 1) +com! -nargs=* VCSLock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Lock', []), 1) +com! -nargs=* VCSLog call s:ExecuteVCSCommand('Log', [], 1) +com! -nargs=0 VCSRevert call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Revert', []), 1) +com! -nargs=? VCSReview call s:ExecuteVCSCommand('Review', [], 1) +com! -nargs=* VCSStatus call s:ExecuteVCSCommand('Status', [], 1) +com! -nargs=* VCSUnlock call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Unlock', []), 1) +com! -nargs=0 VCSUpdate call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Update', []), 1) com! -nargs=* VCSVimDiff call s:VCSVimDiff() " Section: VCS buffer management commands {{{2 @@ -1042,6 +1084,7 @@ nnoremap VCSDelete :VCSDelete nnoremap VCSDiff :VCSDiff nnoremap VCSGotoOriginal :VCSGotoOriginal nnoremap VCSClearAndGotoOriginal :VCSGotoOriginal! +nnoremap VCSInfo :VCSInfo nnoremap VCSLock :VCSLock nnoremap VCSLog :VCSLog nnoremap VCSRevert :VCSRevert @@ -1073,6 +1116,9 @@ endif if !hasmapto('VCSGotoOriginal') nmap cg VCSGotoOriginal endif +if !hasmapto('VCSInfo') + nmap ci VCSInfo +endif if !hasmapto('VCSLock') nmap cL VCSLock endif @@ -1104,6 +1150,7 @@ amenu &Plugin.VCS.A&nnotate VCSAnnotate amenu &Plugin.VCS.&Commit VCSCommit amenu &Plugin.VCS.Delete VCSDelete amenu &Plugin.VCS.&Diff VCSDiff +amenu &Plugin.VCS.&Info VCSInfo amenu &Plugin.VCS.&Log VCSLog amenu &Plugin.VCS.Revert VCSRevert amenu &Plugin.VCS.&Review VCSReview @@ -1125,7 +1172,7 @@ endif " Section: Plugin completion {{{1 -let loaded_VCSCommand=2 +let loaded_VCSCommand = 2 " Load delayed extension plugin registration. silent do VCSCommand User VCSLoadExtensions diff --git a/plugin/vcscvs.vim b/plugin/vcscvs.vim index 51f42d2..fb24b4a 100644 --- a/plugin/vcscvs.vim +++ b/plugin/vcscvs.vim @@ -61,7 +61,7 @@ " The default mappings are as follow: " " ce CVSEdit -" ci CVSEditors +" cE CVSEditors " ct CVSUnedit " cwv CVSWatchers " cwa CVSWatchAdd @@ -83,6 +83,12 @@ if v:version < 700 finish endif +call system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' --version') +if v:shell_error + " CVS is not installed + finish +endif + " Section: Variable initialization {{{1 let s:cvsFunctions = {} @@ -93,16 +99,12 @@ let s:cvsFunctions = {} " Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText) - try - if VCSCommandGetVCSType(expand('%')) == 'CVS' - let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText) - else - throw 'No suitable plugin' - endif - catch /No suitable plugin/ - echohl WarningMsg|echomsg 'Cannot apply CVS commands to this file.'|echohl None - endtry + if VCSCommandGetVCSType(expand('%')) == 'CVS' + let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd + return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText) + else + throw 'CVS VCSCommand plugin called on non-CVS item.' + endif endfunction " Section: VCS function implementations {{{1 @@ -111,12 +113,12 @@ endfunction function! s:cvsFunctions.Identify(buffer) let fileName = resolve(bufname(a:buffer)) if isdirectory(fileName) - let directory = fileName + let directoryName = fileName else - let directory = fnamemodify(fileName, ':h') + let directoryName = fnamemodify(fileName, ':h') endif - if strlen(directory) > 0 - let CVSRoot = directory . '/CVS/Root' + if strlen(directoryName) > 0 + let CVSRoot = directoryName . '/CVS/Root' else let CVSRoot = 'CVS/Root' endif @@ -138,26 +140,21 @@ function! s:cvsFunctions.Annotate(argList) if &filetype == 'CVSAnnotate' " This is a CVSAnnotate buffer. Perform annotation of the version " indicated by the current line. - let revision = matchstr(getline('.'),'\v%(^[0-9.]+)') + let caption = matchstr(getline('.'),'\v%(^[0-9.]+)') + let options = ' -r' . caption else - let revision=VCSCommandGetRevision() - if revision == '' - throw 'Unable to obtain version information.' - elseif revision == 'Unknown' - throw 'File not under source control' - elseif revision == 'New' - throw 'No annotatation available for new file.' - endif + let caption = '' + let options = '' endif + elseif len(a:argList) == 1 && a:argList[0] !~ '^-' + let caption = a:argList[0] + let options = ' -r' . caption else - let revision=a:argList[0] - endif - - if revision == 'New' - throw 'No annotatation available for new file.' + let caption = join(a:argList, ' ') + let options = ' ' . caption endif - let resultBuffer=s:DoCommand('-q annotate -r ' . revision, 'annotate', revision) + let resultBuffer = s:DoCommand('-q annotate' . options, 'annotate', caption) if resultBuffer > 0 set filetype=CVSAnnotate " Remove header lines from standard error @@ -176,8 +173,16 @@ function! s:cvsFunctions.Commit(argList) endfunction " Function: s:cvsFunctions.Delete() {{{2 +" By default, use the -f option to remove the file first. If options are +" passed in, use those instead. function! s:cvsFunctions.Delete(argList) - return s:DoCommand(join(['remove -f'] + a:argList, ' '), 'delete', join(a:argList, ' ')) + let options = ['-f'] + let caption = '' + if len(a:argList) > 0 + let options = a:argList + let caption = join(a:argList, ' ') + endif + return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption) endfunction " Function: s:cvsFunctions.Diff(argList) {{{2 @@ -193,15 +198,15 @@ function! s:cvsFunctions.Diff(argList) let caption = '' endif - let cvsdiffopt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u') + let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u') - if cvsdiffopt == '' - let diffoptionstring = '' + if cvsDiffOpt == '' + let diffOptionString = '' else - let diffoptionstring = ' -' . cvsdiffopt . ' ' + let diffOptionString = ' -' . cvsDiffOpt . ' ' endif - let resultBuffer = s:DoCommand('diff ' . diffoptionstring . revOptions , 'diff', caption) + let resultBuffer = s:DoCommand('diff ' . diffOptionString . revOptions , 'diff', caption) if resultBuffer > 0 set filetype=diff else @@ -224,7 +229,7 @@ function! s:cvsFunctions.GetBufferInfo() if !filereadable(fileName) return ['Unknown'] endif - let oldCwd=VCSCommandChangeToCurrentFileDir(fileName) + let oldCwd = VCSCommandChangeToCurrentFileDir(fileName) try let statusText=system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' status "' . realFileName . '"') if(v:shell_error) @@ -350,7 +355,7 @@ com! CVSWatchers call s:CVSWatchers() let s:cvsExtensionMappings = {} let mappingInfo = [ \['CVSEdit', 'CVSEdit', 'ce'], - \['CVSEditors', 'CVSEditors', 'ci'], + \['CVSEditors', 'CVSEditors', 'cE'], \['CVSUnedit', 'CVSUnedit', 'ct'], \['CVSWatchers', 'CVSWatchers', 'cwv'], \['CVSWatchAdd', 'CVSWatch add', 'cwa'], diff --git a/plugin/vcssvk.vim b/plugin/vcssvk.vim new file mode 100644 index 0000000..8e146fd --- /dev/null +++ b/plugin/vcssvk.vim @@ -0,0 +1,257 @@ +" vim600: set foldmethod=marker: +" +" SVK extension for VCSCommand. +" +" Version: VCS development +" Maintainer: Bob Hiestand +" License: +" Copyright (c) 2007 Bob Hiestand +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to +" deal in the Software without restriction, including without limitation the +" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +" sell copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in +" all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +" IN THE SOFTWARE. +" +" Section: Documentation {{{1 +" +" Options documentation: {{{2 +" +" VCSCommandSVKExec +" This variable specifies the SVK executable. If not set, it defaults to +" 'svk' executed from the user's executable path. + +if v:version < 700 + finish +endif + +call system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' --version') +if v:shell_error + " SVK is not installed + finish +endif + +" Section: Variable initialization {{{1 + +let s:svkFunctions = {} + +" Section: Utility functions {{{1 + +" Function: s:DoCommand(cmd, cmdName, statusText) {{{2 +" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the +" command argument. +function! s:DoCommand(cmd, cmdName, statusText) + if VCSCommandGetVCSType(expand('%')) == 'SVK' + let fullCmd = VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' ' . a:cmd + return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText) + else + throw 'SVK VCSCommand plugin called on non-SVK item.' + endif +endfunction + +" Section: VCS function implementations {{{1 + +" Function: s:svkFunctions.Identify(buffer) {{{2 +function! s:svkFunctions.Identify(buffer) + let fileName = resolve(bufname(a:buffer)) + if isdirectory(fileName) + let directoryName = fileName + else + let directoryName = fnamemodify(fileName, ':p:h') + endif + let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' info "' . directoryName . '"') + if(v:shell_error) + return 0 + else + return 1 + endif +endfunction + +" Function: s:svkFunctions.Add() {{{2 +function! s:svkFunctions.Add(argList) + return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' ')) +endfunction + +" Function: s:svkFunctions.Annotate(argList) {{{2 +function! s:svkFunctions.Annotate(argList) + if len(a:argList) == 0 + if &filetype == 'SVKAnnotate' + " Perform annotation of the version indicated by the current line. + let caption = matchstr(getline('.'),'\v^\s+\zs\d+') + let options = ' -r' . caption + else + let caption = '' + let options = '' + endif + elseif len(a:argList) == 1 && a:argList[0] !~ '^-' + let caption = a:argList[0] + let options = ' -r' . caption + else + let caption = join(a:argList, ' ') + let options = ' ' . caption + endif + + let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption) + if resultBuffer > 0 + set filetype=SVKAnnotate + endif + return resultBuffer +endfunction + +" Function: s:svkFunctions.Commit(argList) {{{2 +function! s:svkFunctions.Commit(argList) + let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '') + if resultBuffer == 0 + echomsg 'No commit needed.' + endif +endfunction + +" Function: s:svkFunctions.Delete() {{{2 +function! s:svkFunctions.Delete(argList) + return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' ')) +endfunction + +" Function: s:svkFunctions.Diff(argList) {{{2 +function! s:svkFunctions.Diff(argList) + if len(a:argList) == 1 + let revOptions = ' -r' . a:argList[0] + let caption = '(' . a:argList[0] . ' : current)' + elseif len(a:argList) == 2 + let revOptions = ' -r' . a:argList[0] . ':' . a:argList[1] + let caption = '(' . a:argList[0] . ' : ' . a:argList[1] . ')' + else + let revOptions = '' + let caption = '' + endif + + let resultBuffer = s:DoCommand('diff' . revOptions , 'diff', caption) + if resultBuffer > 0 + set filetype=diff + else + if svkDiffExt == '' + echomsg 'No differences found' + endif + endif + return resultBuffer +endfunction + +" Function: s:svkFunctions.GetBufferInfo() {{{2 +" Provides version control details for the current file. Current version +" number and current repository version number are required to be returned by +" the vcscommand plugin. +" Returns: List of results: [revision, repository] + +function! s:svkFunctions.GetBufferInfo() + let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) + let fileName = resolve(bufname(originalBuffer)) + let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' status -v "' . fileName . '"') + if(v:shell_error) + return [] + endif + + " File not under SVK control. + if statusText =~ '^?' + return ['Unknown'] + endif + + let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3] + if revision == '' + " Error + return ['Unknown'] + elseif flags =~ '^A' + return ['New', 'New'] + else + return [revision, repository] + endif +endfunction + +" Function: s:svkFunctions.Info(argList) {{{2 +function! s:svkFunctions.Info(argList) + return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' ')) +endfunction + +" Function: s:svkFunctions.Lock(argList) {{{2 +function! s:svkFunctions.Lock(argList) + return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' ')) +endfunction + +" Function: s:svkFunctions.Log() {{{2 +function! s:svkFunctions.Log(argList) + if len(a:argList) == 0 + let options = '' + let caption = '' + elseif len(a:argList) == 1 && a:argList[0] !~ "^-" + let options=' -r' . a:argList[0] + let caption = a:argList[0] + else + " Multiple options, or the option starts with '-' + let caption = join(a:argList, ' ') + let options = ' ' . caption + endif + + let resultBuffer = s:DoCommand('log -v' . options, 'log', caption) + return resultBuffer +endfunction + +" Function: s:svkFunctions.Revert(argList) {{{2 +function! s:svkFunctions.Revert(argList) + return s:DoCommand('revert', 'revert', '') +endfunction + +" Function: s:svkFunctions.Review(argList) {{{2 +function! s:svkFunctions.Review(argList) + if len(a:argList) == 0 + let versiontag = '(current)' + let versionOption = '' + else + let versiontag = a:argList[0] + let versionOption = ' -r ' . versiontag . ' ' + endif + + let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag) + if resultBuffer > 0 + let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') + endif + return resultBuffer +endfunction + +" Function: s:svkFunctions.Status(argList) {{{2 +function! s:svkFunctions.Status(argList) + let options = ['-v'] + if len(a:argList) == 0 + let options = a:argList + endif + return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' ')) +endfunction + +" Function: s:svkFunctions.Unlock(argList) {{{2 +function! s:svkFunctions.Unlock(argList) + return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' ')) +endfunction +" Function: s:svkFunctions.Update(argList) {{{2 +function! s:svkFunctions.Update(argList) + return s:DoCommand('update', 'update', '') +endfunction + +" Section: Plugin Registration {{{1 +" If the vcscommand.vim plugin hasn't loaded, delay registration until it +" loads. +if exists('g:loaded_VCSCommand') + call VCSCommandRegisterModule('SVK', expand(''), s:svkFunctions, []) +else + augroup VCSCommand + au User VCSLoadExtensions call VCSCommandRegisterModule('SVK', expand(''), s:svkFunctions, []) + augroup END +endif diff --git a/plugin/vcssvn.vim b/plugin/vcssvn.vim index 655cfe7..15f53f8 100644 --- a/plugin/vcssvn.vim +++ b/plugin/vcssvn.vim @@ -27,23 +27,6 @@ " " Section: Documentation {{{1 " -" Command documentation {{{2 -" -" The following command only applies to files under SVN source control. -" -" SVNInfo Performs "svn info" on the current file. -" -" Mapping documentation: {{{2 -" -" By default, a mapping is defined for each command. User-provided mappings -" can be used instead by mapping to CommandName, for instance: -" -" nnoremap ,si SVNInfo -" -" The default mappings are as follow: -" -" si SVNInfo -" " Options documentation: {{{2 " " VCSCommandSVNExec @@ -61,6 +44,12 @@ if v:version < 700 finish endif +call system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' --version') +if v:shell_error + " SVN is not installed + finish +endif + " Section: Variable initialization {{{1 let s:svnFunctions = {} @@ -71,16 +60,12 @@ let s:svnFunctions = {} " Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText) - try - if VCSCommandGetVCSType(expand('%')) == 'SVN' - let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd - return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText) - else - throw 'No suitable plugin' - endif - catch /No suitable plugin/ - echohl WarningMsg|echomsg 'Cannot apply SVN commands to this file.'|echohl None - endtry + if VCSCommandGetVCSType(expand('%')) == 'SVN' + let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd + return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText) + else + throw 'SVN VCSCommand plugin called on non-SVN item.' + endif endfunction " Section: VCS function implementations {{{1 @@ -89,12 +74,12 @@ endfunction function! s:svnFunctions.Identify(buffer) let fileName = resolve(bufname(a:buffer)) if isdirectory(fileName) - let directory = fileName + let directoryName = fileName else - let directory = fnamemodify(fileName, ':h') + let directoryName = fnamemodify(fileName, ':h') endif - if strlen(directory) > 0 - let svnDir = directory . '/.svn' + if strlen(directoryName) > 0 + let svnDir = directoryName . '/.svn' else let svnDir = '.svn' endif @@ -115,22 +100,21 @@ function! s:svnFunctions.Annotate(argList) if len(a:argList) == 0 if &filetype == 'SVNAnnotate' " Perform annotation of the version indicated by the current line. - let revision = matchstr(getline('.'),'\v^\s+\zs\d+') + let caption = matchstr(getline('.'),'\v^\s+\zs\d+') + let options = ' -r' . caption else - let revision=VCSCommandGetRevision() - if revision == '' - throw 'Unable to obtain version information.' - elseif revision == 'Unknown' - throw 'File not under source control' - elseif revision == 'New' - throw 'No annotatation available for new file.' - endif + let caption = '' + let options = '' endif + elseif len(a:argList) == 1 && a:argList[0] !~ '^-' + let caption = a:argList[0] + let options = ' -r' . caption else - let revision=a:argList[0] + let caption = join(a:argList, ' ') + let options = ' ' . caption endif - let resultBuffer=s:DoCommand('blame -r' . revision, 'annotate', revision) + let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption) if resultBuffer > 0 set filetype=SVNAnnotate endif @@ -163,26 +147,26 @@ function! s:svnFunctions.Diff(argList) let caption = '' endif - let svndiffext = VCSCommandGetOption('VCSCommandSVNDiffExt', '') - if svndiffext == '' - let diffextstring = '' + let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '') + if svnDiffExt == '' + let diffExtString = '' else - let diffextstring = ' --diff-cmd ' . svndiffext . ' ' + let diffExtString = ' --diff-cmd ' . svnDiffExt . ' ' endif - let svndiffopt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '') + let svnDiffOpt = VCSCommandGetOption('VCSCommandsvnDiffOpt', '') - if svndiffopt == '' - let diffoptionstring = '' + if svnDiffOpt == '' + let diffOptionString = '' else - let diffoptionstring = ' -x -' . svndiffopt . ' ' + let diffOptionString = ' -x -' . svnDiffOpt . ' ' endif - let resultBuffer = s:DoCommand('diff' . diffextstring . diffoptionstring . revOptions , 'diff', caption) + let resultBuffer = s:DoCommand('diff' . diffExtString . diffOptionString . revOptions , 'diff', caption) if resultBuffer > 0 set filetype=diff else - if svndiffext == '' + if svnDiffExt == '' echomsg 'No differences found' endif endif @@ -196,15 +180,12 @@ endfunction " Returns: List of results: [revision, repository, branch] function! s:svnFunctions.GetBufferInfo() - let originalBuffer=VCSCommandGetOriginalBuffer(bufnr('%')) - let fileName=bufname(originalBuffer) + let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) + let fileName = bufname(originalBuffer) let realFileName = fnamemodify(resolve(fileName), ':t') - if !filereadable(fileName) - return ['Unknown'] - endif - let oldCwd=VCSCommandChangeToCurrentFileDir(fileName) + let oldCwd = VCSCommandChangeToCurrentFileDir(fileName) try - let statusText=system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . realFileName . '"') + let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . realFileName . '"') if(v:shell_error) return [] endif @@ -228,18 +209,23 @@ function! s:svnFunctions.GetBufferInfo() endtry endfunction +" Function: s:svnFunctions.Info(argList) {{{2 +function! s:svnFunctions.Info(argList) + return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' ')) +endfunction + " Function: s:svnFunctions.Lock(argList) {{{2 function! s:svnFunctions.Lock(argList) return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' ')) endfunction -" Function: s:svnFunctions.Log() {{{2 +" Function: s:svnFunctions.Log(argList) {{{2 function! s:svnFunctions.Log(argList) if len(a:argList) == 0 let versionOption = '' let caption = '' elseif len(a:argList) == 1 && a:argList[0] !~ "^-" - let versionOption=' -r' . a:argList[0] + let versionOption = ' -r' . a:argList[0] let caption = a:argList[0] else " Multiple options, or the option starts with '-' @@ -247,7 +233,7 @@ function! s:svnFunctions.Log(argList) let versionOption = ' ' . caption endif - let resultBuffer=s:DoCommand('log -v' . versionOption, 'log', caption) + let resultBuffer = s:DoCommand('log -v' . versionOption, 'log', caption) return resultBuffer endfunction @@ -268,17 +254,18 @@ function! s:svnFunctions.Review(argList) let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag) if resultBuffer > 0 - let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype') + let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') endif return resultBuffer endfunction " Function: s:svnFunctions.Status(argList) {{{2 function! s:svnFunctions.Status(argList) + let options = ['-u', '-v'] if len(a:argList) == 0 - let a:argList = ['-u', '-v'] + let options = a:argList endif - return s:DoCommand(join(['status -u -v'] + a:argList, ' '), 'status', join(a:argList, ' ')) + return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' ')) endfunction " Function: s:svnFunctions.Unlock(argList) {{{2 @@ -290,38 +277,13 @@ function! s:svnFunctions.Update(argList) return s:DoCommand('update', 'update', '') endfunction -" Section: SVN-specific functions {{{1 - -" Function: s:SVNInfo() {{{2 -function! s:SVNInfo(argList) - return s:DoCommand(join(['info'] + a:argList, ' '), 'svninfo', join(a:argList, ' ')) -endfunction - -" Section: Command definitions {{{1 -" Section: Primary commands {{{2 -com! -nargs=* SVNInfo call s:SVNInfo([]) - -" Section: Plugin command mappings {{{1 - -let s:svnExtensionMappings = {} -let mappingInfo = [['SVNInfo', 'SVNInfo', 'ci']] -for [pluginName, commandText, shortCut] in mappingInfo - execute 'nnoremap ' . pluginName . ' :' . commandText . '' - if !hasmapto('' . pluginName) - let s:svnExtensionMappings[shortCut] = commandText - endif -endfor - -" Section: Menu items {{{1 -amenu &Plugin.VCS.SVN.&Info SVNInfo - " Section: Plugin Registration {{{1 " If the vcscommand.vim plugin hasn't loaded, delay registration until it " loads. if exists('g:loaded_VCSCommand') - call VCSCommandRegisterModule('SVN', expand(''), s:svnFunctions, s:svnExtensionMappings) + call VCSCommandRegisterModule('SVN', expand(''), s:svnFunctions, []) else augroup VCSCommand - au User VCSLoadExtensions call VCSCommandRegisterModule('SVN', expand(''), s:svnFunctions, s:svnExtensionMappings) + au User VCSLoadExtensions call VCSCommandRegisterModule('SVN', expand(''), s:svnFunctions, []) augroup END endif -- 2.11.4.GIT