[vim]Update VCS plugin

This commit is contained in:
Mathieu Maret 2013-03-01 17:29:45 +01:00
parent f48625243a
commit 0fc98a9065
14 changed files with 1577 additions and 471 deletions

View File

@ -1,5 +1,5 @@
*vcscommand.txt* vcscommand
Copyright (c) 2007 Bob Hiestand
Copyright (c) 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
@ -81,7 +81,7 @@ output appears in a new window.
Many of the commands accept revisions as arguments. By default, most operate
on the most recent revision on the current branch if no revision is specified.
Each vcscommand is mapped to a key sequence starting with the <Leader>
Each vcscommand is mapped to a key sequence starting with the |<Leader>|
keystroke. The default mappings may be overridden by supplying different
mappings before the plugin is loaded, such as in the vimrc, in the standard
fashion for plugin mappings. For examples, please see
@ -131,7 +131,7 @@ This command adds the current file to source control. Please note, this does
not commit the newly-added file. All parameters to the command are passed to
the underlying VCS.
:VCSAnnotate *:VCSAnnotate*
:VCSAnnotate[!] *:VCSAnnotate*
This command displays the current file with each line annotated with the
version in which it was most recently changed. If an argument is given, the
@ -140,16 +140,19 @@ 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.
If '!' is used, the view of the annotated buffer is split so that the
annotation is in a separate window from the content, and each is highlighted
separately.
For CVS buffers, the 'VCSCommandCVSAnnotateParent' option, if set to non-zero,
will cause the above behavior to change. Instead of annotating the version on
the current line, the parent revision is used instead, crossing branches if
necessary.
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.
With no arguments the cursor will jump to the line in the annotated buffer
corresponding to the current line in the source buffer.
:VCSBlame *:VCSBlame*
:VCSBlame[!] *:VCSBlame*
Alias for |:VCSAnnotate|.
@ -168,9 +171,10 @@ log message. The commit can be abandoned if the log message buffer is deleted
or wiped before being written.
Alternatively, the mapping that is used to invoke :VCSCommit (by default
<Leader>cc) can be used in the log message buffer to immediately commit. This
is useful if the |VCSCommandCommitOnWrite| variable is set to 0 to disable the
normal commit-on-write behavior.
|<Leader>|cc, please see |vcscommand-mappings|) can be used in the log message
buffer in Normal mode to immediately commit. This is useful if the
|VCSCommandCommitOnWrite| variable is set to 0 to disable the normal
commit-on-write behavior.
:VCSDelete *:VCSDelete*
@ -325,45 +329,56 @@ This command performs "cvs watchers" on the current file.
By default, a mapping is defined for each command. These mappings execute the
default (no-argument) form of each command.
<Leader>ca VCSAdd
<Leader>cn VCSAnnotate
<Leader>cc VCSCommit
<Leader>cD VCSDelete
<Leader>cd VCSDiff
<Leader>cg VCSGotoOriginal
<Leader>cG VCSGotoOriginal!
<Leader>ci VCSInfo
<Leader>cl VCSLog
<Leader>cL VCSLock
<Leader>cr VCSReview
<Leader>cs VCSStatus
<Leader>cu VCSUpdate
<Leader>cU VCSUnlock
<Leader>cv VCSVimDiff
|<Leader>|ca VCSAdd
|<Leader>|cn VCSAnnotate
|<Leader>|cN VCSAnnotate!
|<Leader>|cc VCSCommit
|<Leader>|cD VCSDelete
|<Leader>|cd VCSDiff
|<Leader>|cg VCSGotoOriginal
|<Leader>|cG VCSGotoOriginal!
|<Leader>|ci VCSInfo
|<Leader>|cl VCSLog
|<Leader>|cL VCSLock
|<Leader>|cr VCSReview
|<Leader>|cs VCSStatus
|<Leader>|cu VCSUpdate
|<Leader>|cU VCSUnlock
|<Leader>|cv VCSVimDiff
Only for CVS buffers:
<Leader>ce CVSEdit
<Leader>cE CVSEditors
<Leader>ct CVSUnedit
<Leader>cwv CVSWatchers
<Leader>cwa CVSWatchAdd
<Leader>cwn CVSWatchOn
<Leader>cwf CVSWatchOff
<Leader>cwf CVSWatchRemove
|<Leader>|ce CVSEdit
|<Leader>|cE CVSEditors
|<Leader>|ct CVSUnedit
|<Leader>|cwv CVSWatchers
|<Leader>|cwa CVSWatchAdd
|<Leader>|cwn CVSWatchOn
|<Leader>|cwf CVSWatchOff
|<Leader>|cwf CVSWatchRemove
*vcscommand-mappings-override*
The default mappings can be overriden by user-provided instead by mapping to
The default mappings can be overridden by user-provided instead by mapping to
<Plug>CommandName. This is especially useful when these mappings collide with
other existing mappings (vim will warn of this during plugin initialization,
but will not clobber the existing mappings).
For instance, to override the default mapping for :VCSAdd to set it to '\add',
add the following to the vimrc:
There are three methods for controlling mapping:
First, maps can be overriden for individual commands. For instance, to
override the default mapping for :VCSAdd to set it to '\add', add the
following to the vimrc:
nmap \add <Plug>VCSAdd
Second, the default map prefix ('<Leader>c') can be overridden by defining the
|VCSCommandMapPrefix| variable.
Third, the entire set of default maps can be overridden by defining the
|VCSCommandMappings| variable.
4.3 Automatic buffer variables *vcscommand-buffer-variables*
Several buffer variables are defined in each vcscommand result buffer. These
@ -414,10 +429,16 @@ The following variables are available:
|VCSCommandCVSExec|
|VCSCommandDeleteOnHide|
|VCSCommandDiffSplit|
|VCSCommandDisableAll|
|VCSCommandDisableMappings|
|VCSCommandDisableExtensionMappings|
|VCSCommandDisableMenu|
|VCSCommandEdit|
|VCSCommandEnableBufferSetup|
|VCSCommandMappings|
|VCSCommandMapPrefix|
|VCSCommandMenuPriority|
|VCSCommandMenuRoot|
|VCSCommandResultBufferNameExtension|
|VCSCommandResultBufferNameFunction|
|VCSCommandSplit|
@ -425,6 +446,8 @@ The following variables are available:
|VCSCommandSVNDiffExt|
|VCSCommandSVNDiffOpt|
|VCSCommandSVNExec|
|VCSCommandVCSTypeOverride|
|VCSCommandVCSTypePreference|
VCSCommandCommitOnWrite *VCSCommandCommitOnWrite*
@ -453,6 +476,12 @@ VCSCommandDiffSplit *VCSCommandDiffSplit*
This variable overrides the |VCSCommandSplit| variable, but only for buffers
created with |:VCSVimDiff|.
VCSCommandDisableAll *VCSCommandDisableAll*
This variable, if set, prevents the plugin or any extensions from loading at
all. This is useful when a single runtime distribution is used on multiple
systems with varying versions.
VCSCommandDisableMappings *VCSCommandDisableMappings*
This variable, if set to a non-zero value, prevents the default command
@ -469,6 +498,11 @@ VCSCommandEdit *VCSCommandEdit*
This variable controls whether the original buffer is replaced ('edit') or
split ('split'). If not set, it defaults to 'split'.
VCSCommandDisableMenu *VCSCommandDisableMenu*
This variable, if set to a non-zero value, prevents the default command menu
from being set.
VCSCommandEnableBufferSetup *VCSCommandEnableBufferSetup*
This variable, if set to a non-zero value, activates VCS buffer management
@ -477,6 +511,27 @@ mode see (|vcscommand-buffer-management|). This mode means that the
is VCS-controlled. This is useful for displaying version information in the
status bar.
VCSCommandMappings *VCSCommandMappings*
This variable, if set, overrides the default mappings used for shortcuts. It
should be a List of 2-element Lists, each containing a shortcut and function
name pair. The value of the '|VCSCommandMapPrefix|' variable will be added to
each shortcut.
VCSCommandMapPrefix *VCSCommandMapPrefix*
This variable, if set, overrides the default mapping prefix ('<Leader>c').
This allows customization of the mapping space used by the vcscommand
shortcuts.
VCSCommandMenuPriority *VCSCommandMenuPriority*
This variable, if set, overrides the default menu priority '' (empty)
VCSCommandMenuRoot *VCSCommandMenuRoot*
This variable, if set, overrides the default menu root 'Plugin.VCS'
VCSCommandResultBufferNameExtension *VCSCommandResultBufferNameExtension*
This variable, if set to a non-blank value, is appended to the name of the VCS
@ -507,7 +562,8 @@ may occur.
If set to 'horizontal', the resulting windows will be on stacked on top of
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.
VCSVimDiff windows. VCSVimDiff windows default to the user's 'diffopt'
setting, if set, otherwise 'vertical'.
VCSCommandSVKExec *VCSCommandSVKExec*
@ -529,6 +585,22 @@ VCSCommandSVNExec *VCSCommandSVNExec*
This variable controls the executable used for all SVN commands If not set,
it defaults to "svn".
VCSCommandVCSTypeOverride *VCSCommandVCSTypeOverride*
This variable allows the VCS type detection to be overridden on a path-by-path
basis. The value of this variable is expected to be a List of Lists. Each
item in the high-level List is a List containing two elements. The first
element is a regular expression that will be matched against the full file
name of a given buffer. If it matches, the second element will be used as the
VCS type.
VCSCommandVCSTypePreference *VCSCommandVCSTypePreference*
This variable allows the VCS type detection to be weighted towards a specific
VCS, in case more than one potential VCS is detected as useable. The format
of the variable is either a list or a space-separated string containing the
ordered-by-preference abbreviations of the preferred VCS types.
5.2 VCSCommand events *vcscommand-events*
For additional customization, vcscommand can trigger user-defined events.
@ -540,7 +612,7 @@ For instance, the following could be added to the vimrc to provide a 'q'
mapping to quit a vcscommand scratch buffer:
augroup VCSCommand
au User VCSBufferCreated silent! nmap <unique> <buffer> q: bwipeout<cr>
au User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr>
augroup END
The following hooks are available:
@ -712,7 +784,7 @@ too often.
==============================================================================
7. Changes from cvscommandi *cvscommand-changes*
7. Changes from cvscommand *cvscommand-changes*
1. Require Vim 7 in order to leverage several convenient features; also
because I wanted to play with Vim 7.

264
.vim/plugin/vcsbzr.vim Normal file
View File

@ -0,0 +1,264 @@
" vim600: set foldmethod=marker:
"
" BZR extension for VCSCommand.
"
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 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
"
" VCSCommandBZRExec
" This variable specifies the BZR executable. If not set, it defaults to
" 'bzr' executed from the user's executable path.
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
" BZR is not installed
finish
endif
let s:save_cpo=&cpo
set cpo&vim
" Section: Variable initialization {{{1
let s:bzrFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke bzr suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandBZRExec', 'bzr')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'BZR'
let fullCmd = s:Executable() . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
else
throw 'BZR VCSCommand plugin called on non-BZR item.'
endif
endfunction
" Section: VCS function implementations {{{1
" Function: s:bzrFunctions.Identify(buffer) {{{2
function! s:bzrFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
let l:save_bzr_log=$BZR_LOG
try
let $BZR_LOG=has("win32") || has("win95") || has("win64") || has("win16") ? "nul" : "/dev/null"
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . fileName . '"')
finally
let $BZR_LOG=l:save_bzr_log
endtry
if(v:shell_error)
return 0
else
return 1
endif
endfunction
" Function: s:bzrFunctions.Add() {{{2
function! s:bzrFunctions.Add(argList)
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
endfunction
" Function: s:bzrFunctions.Annotate(argList) {{{2
function! s:bzrFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype ==? 'bzrannotate'
" 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
normal! 1G2dd
endif
return resultBuffer
endfunction
" Function: s:bzrFunctions.Commit(argList) {{{2
function! s:bzrFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
echomsg 'No commit needed.'
endif
endfunction
" Function: s:bzrFunctions.Delete() {{{2
function! s:bzrFunctions.Delete(argList)
return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {})
endfunction
" Function: s:bzrFunctions.Diff(argList) {{{2
function! s:bzrFunctions.Diff(argList)
if len(a:argList) == 0
let revOptions = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let revOptions = ['-r' . join(a:argList, '..')]
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
else
" Pass-through
let caption = join(a:argList, ' ')
let revOptions = a:argList
endif
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
endfunction
" Function: s:bzrFunctions.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:bzrFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = resolve(bufname(originalBuffer))
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -S -- "' . fileName . '"')
let revision = s:VCSCommandUtility.system(s:Executable() . ' revno -- "' . fileName . '"')
if(v:shell_error)
return []
endif
" File not under BZR control.
if statusText =~ '^?'
return ['Unknown']
endif
let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2]
if revision == ''
" Error
return ['Unknown']
elseif flags =~ '^A'
return ['New', 'New']
else
return [revision, repository]
endif
endfunction
" Function: s:bzrFunctions.Info(argList) {{{2
function! s:bzrFunctions.Info(argList)
return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {})
endfunction
" Function: s:bzrFunctions.Lock(argList) {{{2
function! s:bzrFunctions.Lock(argList)
echomsg 'bzr lock is not necessary'
endfunction
" Function: s:bzrFunctions.Log() {{{2
function! s:bzrFunctions.Log(argList)
if len(a:argList) == 0
let options = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let options = ['-r' . join(a:argList, ':')]
let caption = options[0]
else
" Pass-through
let options = a:argList
let caption = join(a:argList, ' ')
endif
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
return resultBuffer
endfunction
" Function: s:bzrFunctions.Revert(argList) {{{2
function! s:bzrFunctions.Revert(argList)
return s:DoCommand('revert', 'revert', '', {})
endfunction
" Function: s:bzrFunctions.Review(argList) {{{2
function! s:bzrFunctions.Review(argList)
if len(a:argList) == 0
let versiontag = '(current)'
let versionOption = ''
else
let versiontag = a:argList[0]
let versionOption = ' -r ' . versiontag . ' '
endif
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:bzrFunctions.Status(argList) {{{2
function! s:bzrFunctions.Status(argList)
let options = ['-S']
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
endfunction
" Function: s:bzrFunctions.Unlock(argList) {{{2
function! s:bzrFunctions.Unlock(argList)
echomsg 'bzr unlock is not necessary'
endfunction
" Function: s:bzrFunctions.Update(argList) {{{2
function! s:bzrFunctions.Update(argList)
return s:DoCommand('update', 'update', '', {})
endfunction
" Annotate setting {{{2
let s:bzrFunctions.AnnotateSplitRegex = '^[^|]\+ | '
" Section: Plugin Registration {{{1
let s:VCSCommandUtility = VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, [])
let &cpo = s:save_cpo

File diff suppressed because it is too large Load Diff

View File

@ -2,10 +2,9 @@
"
" CVS extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) 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
@ -32,23 +31,23 @@
" The following commands only apply to files under CVS source control.
"
" CVSEdit Performs "cvs edit" on the current file.
"
"
" CVSEditors Performs "cvs editors" on the current file.
"
"
" CVSUnedit Performs "cvs unedit" on the current file.
"
"
" CVSWatch Takes an argument which must be one of [on|off|add|remove].
" Performs "cvs watch" with the given argument on the current
" file.
"
"
" CVSWatchers Performs "cvs watchers" on the current file.
"
"
" CVSWatchAdd Alias for "CVSWatch add"
"
"
" CVSWatchOn Alias for "CVSWatch on"
"
"
" CVSWatchOff Alias for "CVSWatch off"
"
"
" CVSWatchRemove Alias for "CVSWatch remove"
"
" Mapping documentation: {{{2
@ -81,12 +80,18 @@
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
runtime plugin/vcscommand.vim
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
" CVS is not installed
@ -102,23 +107,40 @@ let s:cvsFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke cvs suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandCVSExec', 'cvs')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'CVS'
let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
let fullCmd = s:Executable() . ' ' . a:cmd
let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
if ret > 0
if getline(line('$')) =~ '^cvs \w\+: closing down connection'
$d
1
endif
endif
return ret
else
throw 'CVS VCSCommand plugin called on non-CVS item.'
endif
endfunction
" Function: GetRevision() {{{2
" Function: s:GetRevision() {{{2
" Function for retrieving the current buffer's revision number.
" Returns: Revision number or an empty string if an error occurs.
function! GetRevision()
function! s:GetRevision()
if !exists('b:VCSCommandBufferInfo')
let b:VCSCommandBufferInfo = s:cvsFunctions.GetBufferInfo()
endif
@ -160,7 +182,7 @@ endfunction
" Function: s:cvsFunctions.Annotate(argList) {{{2
function! s:cvsFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'CVSAnnotate'
if &filetype ==? 'cvsannotate'
" This is a CVSAnnotate buffer. Perform annotation of the version
" indicated by the current line.
let caption = matchstr(getline('.'),'\v^[0-9.]+')
@ -183,7 +205,7 @@ function! s:cvsFunctions.Annotate(argList)
" CVS defaults to pulling HEAD, regardless of current branch.
" Therefore, always pass desired revision.
let caption = ''
let options = ['-r' . GetRevision()]
let options = ['-r' . s:GetRevision()]
endif
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
let caption = a:argList[0]
@ -195,7 +217,6 @@ function! s:cvsFunctions.Annotate(argList)
let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {})
if resultBuffer > 0
set filetype=CVSAnnotate
" Remove header lines from standard error
silent v/^\d\+\%(\.\d\+\)\+/d
endif
@ -245,13 +266,7 @@ function! s:cvsFunctions.Diff(argList)
let diffOptions = ['-' . cvsDiffOpt]
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
endfunction
" Function: s:cvsFunctions.GetBufferInfo() {{{2
@ -280,7 +295,7 @@ function! s:cvsFunctions.GetBufferInfo()
endif
let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
try
let statusText=system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' status "' . realFileName . '"')
let statusText=s:VCSCommandUtility.system(s:Executable() . ' status -- "' . realFileName . '"')
if(v:shell_error)
return []
endif
@ -288,7 +303,7 @@ function! s:cvsFunctions.GetBufferInfo()
" We can still be in a CVS-controlled directory without this being a CVS
" file
if match(revision, '^New file!$') >= 0
if match(revision, '^New file!$') >= 0
let revision='New'
elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') <0
return ['Unknown']
@ -317,11 +332,7 @@ function! s:cvsFunctions.Log(argList)
let caption = join(a:argList, ' ')
endif
let resultBuffer=s:DoCommand(join(['log'] + options), 'log', caption, {})
if resultBuffer > 0
set filetype=rcslog
endif
return resultBuffer
return s:DoCommand(join(['log'] + options), 'log', caption, {})
endfunction
" Function: s:cvsFunctions.Revert(argList) {{{2
@ -339,11 +350,7 @@ function! s:cvsFunctions.Review(argList)
let versionOption = ' -r ' . versiontag . ' '
endif
let resultBuffer = s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:cvsFunctions.Status(argList) {{{2
@ -387,6 +394,9 @@ function! s:CVSWatchers()
return s:DoCommand('watchers', 'cvswatchers', '', {})
endfunction
" Annotate setting {{{2
let s:cvsFunctions.AnnotateSplitRegex = '): '
" Section: Command definitions {{{1
" Section: Primary commands {{{2
com! CVSEdit call s:CVSEdit()
@ -402,36 +412,42 @@ com! CVSWatchers call s:CVSWatchers()
" Section: Plugin command mappings {{{1
let s:cvsExtensionMappings = {}
let mappingInfo = [
\['CVSEdit', 'CVSEdit', 'ce'],
\['CVSEditors', 'CVSEditors', 'cE'],
\['CVSUnedit', 'CVSUnedit', 'ct'],
\['CVSWatchers', 'CVSWatchers', 'cwv'],
\['CVSWatchAdd', 'CVSWatch add', 'cwa'],
\['CVSWatchOff', 'CVSWatch off', 'cwf'],
\['CVSWatchOn', 'CVSWatch on', 'cwn'],
\['CVSWatchRemove', 'CVSWatch remove', 'cwr']
\]
if !exists("no_plugin_maps")
let mappingInfo = [
\['CVSEdit', 'CVSEdit', 'e'],
\['CVSEditors', 'CVSEditors', 'E'],
\['CVSUnedit', 'CVSUnedit', 't'],
\['CVSWatchers', 'CVSWatchers', 'wv'],
\['CVSWatchAdd', 'CVSWatch add', 'wa'],
\['CVSWatchOff', 'CVSWatch off', 'wf'],
\['CVSWatchOn', 'CVSWatch on', 'wn'],
\['CVSWatchRemove', 'CVSWatch remove', 'wr']
\]
for [pluginName, commandText, shortCut] in mappingInfo
execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
if !hasmapto('<Plug>' . pluginName)
let s:cvsExtensionMappings[shortCut] = commandText
endif
endfor
" Section: Menu items {{{1
silent! aunmenu Plugin.VCS.CVS
amenu <silent> &Plugin.VCS.CVS.&Edit <Plug>CVSEdit
amenu <silent> &Plugin.VCS.CVS.Ed&itors <Plug>CVSEditors
amenu <silent> &Plugin.VCS.CVS.Unedi&t <Plug>CVSUnedit
amenu <silent> &Plugin.VCS.CVS.&Watchers <Plug>CVSWatchers
amenu <silent> &Plugin.VCS.CVS.WatchAdd <Plug>CVSWatchAdd
amenu <silent> &Plugin.VCS.CVS.WatchOn <Plug>CVSWatchOn
amenu <silent> &Plugin.VCS.CVS.WatchOff <Plug>CVSWatchOff
amenu <silent> &Plugin.VCS.CVS.WatchRemove <Plug>CVSWatchRemove
for [pluginName, commandText, shortCut] in mappingInfo
execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
if !hasmapto('<Plug>' . pluginName)
let s:cvsExtensionMappings[shortCut] = commandText
endif
endfor
endif
" Section: Plugin Registration {{{1
call VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
let s:VCSCommandUtility = VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
" Section: Menu items {{{1
for [s:shortcut, s:command] in [
\['CVS.&Edit', '<Plug>CVSEdit'],
\['CVS.Ed&itors', '<Plug>CVSEditors'],
\['CVS.Unedi&t', '<Plug>CVSUnedit'],
\['CVS.&Watchers', '<Plug>CVSWatchers'],
\['CVS.WatchAdd', '<Plug>CVSWatchAdd'],
\['CVS.WatchOn', '<Plug>CVSWatchOn'],
\['CVS.WatchOff', '<Plug>CVSWatchOff'],
\['CVS.WatchRemove', '<Plug>CVSWatchRemove']
\]
call s:VCSCommandUtility.addMenuItem(s:shortcut, s:command)
endfor
unlet s:shortcut s:command
let &cpo = s:save_cpo

View File

@ -2,10 +2,9 @@
"
" git extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2008 Bob Hiestand
" Copyright (c) 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
@ -40,12 +39,18 @@
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
runtime plugin/vcscommand.vim
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
" git is not installed
@ -61,12 +66,19 @@ let s:gitFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke git suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandGitExec', 'git')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the git executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'git'
let fullCmd = VCSCommandGetOption('VCSCommandGitExec', 'git',) . ' ' . a:cmd
let fullCmd = s:Executable() . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
else
throw 'git VCSCommand plugin called on non-git item.'
@ -81,7 +93,7 @@ endfunction
function! s:gitFunctions.Identify(buffer)
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
try
call system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --is-inside-work-tree')
call s:VCSCommandUtility.system(s:Executable() . ' rev-parse --is-inside-work-tree')
if(v:shell_error)
return 0
else
@ -100,7 +112,7 @@ endfunction
" Function: s:gitFunctions.Annotate(argList) {{{2
function! s:gitFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'gitAnnotate'
if &filetype == 'gitannotate'
" Perform annotation of the version indicated by the current line.
let options = matchstr(getline('.'),'^\x\+')
else
@ -112,21 +124,16 @@ function! s:gitFunctions.Annotate(argList)
let options = join(a:argList, ' ')
endif
let resultBuffer = s:DoCommand('blame ' . options . ' -- ', 'annotate', options, {})
if resultBuffer > 0
normal 1G
set filetype=gitAnnotate
endif
return resultBuffer
return s:DoCommand('blame ' . options, 'annotate', options, {})
endfunction
" Function: s:gitFunctions.Commit(argList) {{{2
function! s:gitFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
try
return s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
catch /\m^Version control command failed.*nothing\%( added\)\? to commit/
echomsg 'No commit needed.'
endif
return resultBuffer
endtry
endfunction
" Function: s:gitFunctions.Delete() {{{2
@ -154,13 +161,7 @@ function! s:gitFunctions.Diff(argList)
endfor
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
endfunction
" Function: s:gitFunctions.GetBufferInfo() {{{2
@ -173,7 +174,7 @@ endfunction
function! s:gitFunctions.GetBufferInfo()
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
try
let branch = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' symbolic-ref -q HEAD'), '\n$', '', '')
let branch = substitute(s:VCSCommandUtility.system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '')
if v:shell_error
let branch = 'DETACHED'
else
@ -186,7 +187,7 @@ function! s:gitFunctions.GetBufferInfo()
if method != ''
let method = ' --' . method
endif
let tag = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' describe' . method), '\n$', '', '')
let tag = substitute(s:VCSCommandUtility.system(s:Executable() . ' describe' . method), '\n$', '', '')
if !v:shell_error
call add(info, tag)
break
@ -201,11 +202,7 @@ endfunction
" Function: s:gitFunctions.Log() {{{2
function! s:gitFunctions.Log(argList)
let resultBuffer=s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
if resultBuffer > 0
set filetype=gitlog
endif
return resultBuffer
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
endfunction
" Function: s:gitFunctions.Revert(argList) {{{2
@ -223,18 +220,14 @@ function! s:gitFunctions.Review(argList)
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
try
let prefix = system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --show-prefix')
let prefix = s:VCSCommandUtility.system(s:Executable() . ' rev-parse --show-prefix')
finally
call VCSCommandChdir(oldCwd)
endtry
let prefix = substitute(prefix, '\n$', '', '')
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
let resultBuffer = s:DoCommand('show ' . blob, 'review', revision, {})
if resultBuffer > 0
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
endif
return resultBuffer
return s:DoCommand('show ' . blob, 'review', revision, {})
endfunction
" Function: s:gitFunctions.Status(argList) {{{2
@ -247,8 +240,10 @@ function! s:gitFunctions.Update(argList)
throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know."
endfunction
" Annotate setting {{{2
let s:gitFunctions.AnnotateSplitRegex = ') '
" Section: Plugin Registration {{{1
call VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
let s:VCSCommandUtility = VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
let &cpo = s:save_cpo

275
.vim/plugin/vcshg.vim Normal file
View File

@ -0,0 +1,275 @@
" vim600: set foldmethod=marker:
"
" Mercurial extension for VCSCommand.
"
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 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
"
" VCSCommandHGExec
" This variable specifies the mercurial executable. If not set, it defaults
" to 'hg' executed from the user's executable path.
"
" VCSCommandHGDiffExt
" This variable, if set, sets the external diff program used by Subversion.
"
" VCSCommandHGDiffOpt
" This variable, if set, determines the options passed to the hg diff
" command (such as 'u', 'w', or 'b').
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
" HG is not installed
finish
endif
let s:save_cpo=&cpo
set cpo&vim
" Section: Variable initialization {{{1
let s:hgFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke hg suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandHGExec', 'hg')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'HG'
let fullCmd = s:Executable() . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
else
throw 'HG VCSCommand plugin called on non-HG item.'
endif
endfunction
" Section: VCS function implementations {{{1
" Function: s:hgFunctions.Identify(buffer) {{{2
function! s:hgFunctions.Identify(buffer)
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
try
call s:VCSCommandUtility.system(s:Executable() . ' root')
if(v:shell_error)
return 0
else
return g:VCSCOMMAND_IDENTIFY_INEXACT
endif
finally
call VCSCommandChdir(oldCwd)
endtry
endfunction
" Function: s:hgFunctions.Add() {{{2
function! s:hgFunctions.Add(argList)
return s:DoCommand(join(['add -v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
endfunction
" Function: s:hgFunctions.Annotate(argList) {{{2
function! s:hgFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype ==? 'hgannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s*\w+\s+\zs\d+')
let options = ' -un -r' . caption
else
let caption = ''
let options = ' -un'
endif
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
let caption = a:argList[0]
let options = ' -un -r' . caption
else
let caption = join(a:argList, ' ')
let options = ' ' . caption
endif
return s:DoCommand('blame' . options, 'annotate', caption, {})
endfunction
" Function: s:hgFunctions.Commit(argList) {{{2
function! s:hgFunctions.Commit(argList)
try
return s:DoCommand('commit -v -l "' . a:argList[0] . '"', 'commit', '', {})
catch /Version control command failed.*nothing changed/
echomsg 'No commit needed.'
endtry
endfunction
" Function: s:hgFunctions.Delete() {{{2
function! s:hgFunctions.Delete(argList)
return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {})
endfunction
" Function: s:hgFunctions.Diff(argList) {{{2
function! s:hgFunctions.Diff(argList)
if len(a:argList) == 0
let revOptions = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let revOptions = ['-r' . join(a:argList, ':')]
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
else
" Pass-through
let caption = join(a:argList, ' ')
let revOptions = a:argList
endif
let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '')
if hgDiffExt == ''
let diffExt = []
else
let diffExt = ['--diff-cmd ' . hgDiffExt]
endif
let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '')
if hgDiffOpt == ''
let diffOptions = []
else
let diffOptions = ['-x -' . hgDiffOpt]
endif
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
endfunction
" Function: s:hgFunctions.Info(argList) {{{2
function! s:hgFunctions.Info(argList)
return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {})
endfunction
" Function: s:hgFunctions.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, branch]
function! s:hgFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = bufname(originalBuffer)
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -- "' . fileName . '"')
if(v:shell_error)
return []
endif
" File not under HG control.
if statusText =~ '^?'
return ['Unknown']
endif
let parentsText = s:VCSCommandUtility.system(s:Executable() . ' parents -- "' . fileName . '"')
let revision = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
let logText = s:VCSCommandUtility.system(s:Executable() . ' log -- "' . fileName . '"')
let repository = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
if revision == ''
" Error
return ['Unknown']
elseif statusText =~ '^A'
return ['New', 'New']
else
return [revision, repository]
endif
endfunction
" Function: s:hgFunctions.Log(argList) {{{2
function! s:hgFunctions.Log(argList)
if len(a:argList) == 0
let options = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let options = ['-r' . join(a:argList, ':')]
let caption = options[0]
else
" Pass-through
let options = a:argList
let caption = join(a:argList, ' ')
endif
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
return resultBuffer
endfunction
" Function: s:hgFunctions.Revert(argList) {{{2
function! s:hgFunctions.Revert(argList)
return s:DoCommand('revert', 'revert', '', {})
endfunction
" Function: s:hgFunctions.Review(argList) {{{2
function! s:hgFunctions.Review(argList)
if len(a:argList) == 0
let versiontag = '(current)'
let versionOption = ''
else
let versiontag = a:argList[0]
let versionOption = ' -r ' . versiontag . ' '
endif
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:hgFunctions.Status(argList) {{{2
function! s:hgFunctions.Status(argList)
let options = ['-A', '-v']
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
endfunction
" Function: s:hgFunctions.Update(argList) {{{2
function! s:hgFunctions.Update(argList)
return s:DoCommand('update', 'update', '', {})
endfunction
" Annotate setting {{{2
let s:hgFunctions.AnnotateSplitRegex = '\d\+: '
" Section: Plugin Registration {{{1
let s:VCSCommandUtility = VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
let &cpo = s:save_cpo

View File

@ -2,10 +2,9 @@
"
" SVK extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) 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
@ -35,12 +34,18 @@
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
runtime plugin/vcscommand.vim
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
" SVK is not installed
@ -56,12 +61,19 @@ let s:svkFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke SVK suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandSVKExec', 'svk')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'SVK'
let fullCmd = VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' ' . a:cmd
let fullCmd = s:Executable() . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
else
throw 'SVK VCSCommand plugin called on non-SVK item.'
@ -78,7 +90,7 @@ function! s:svkFunctions.Identify(buffer)
else
let directoryName = fnamemodify(fileName, ':p:h')
endif
let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' info "' . directoryName . '"')
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . directoryName . '"', "no")
if(v:shell_error)
return 0
else
@ -94,7 +106,7 @@ endfunction
" Function: s:svkFunctions.Annotate(argList) {{{2
function! s:svkFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'SVKAnnotate'
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
@ -112,8 +124,7 @@ function! s:svkFunctions.Annotate(argList)
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
if resultBuffer > 0
normal 1G2dd
set filetype=SVKAnnotate
normal! 1G2dd
endif
return resultBuffer
endfunction
@ -134,7 +145,7 @@ endfunction
" Function: s:svkFunctions.Diff(argList) {{{2
function! s:svkFunctions.Diff(argList)
if len(a:argList) == 0
let revOptions = []
let revOptions = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let revOptions = ['-r' . join(a:argList, ':')]
@ -145,13 +156,7 @@ function! s:svkFunctions.Diff(argList)
let revOptions = a:argList
endif
let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
if resultBuffer > 0
set filetype=diff
else
echomsg 'No differences found'
endif
return resultBuffer
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
endfunction
" Function: s:svkFunctions.GetBufferInfo() {{{2
@ -163,7 +168,7 @@ endfunction
function! s:svkFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = resolve(bufname(originalBuffer))
let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' status -v "' . fileName . '"')
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -v -- "' . fileName . '"')
if(v:shell_error)
return []
endif
@ -227,17 +232,13 @@ function! s:svkFunctions.Review(argList)
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
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:svkFunctions.Status(argList) {{{2
function! s:svkFunctions.Status(argList)
let options = ['-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
@ -253,6 +254,6 @@ function! s:svkFunctions.Update(argList)
endfunction
" Section: Plugin Registration {{{1
call VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
let s:VCSCommandUtility = VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
let &cpo = s:save_cpo

View File

@ -2,10 +2,9 @@
"
" SVN extension for VCSCommand.
"
" Version: VCS development
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) 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
@ -42,12 +41,18 @@
" Section: Plugin header {{{1
if exists('VCSCommandDisableAll')
finish
endif
if v:version < 700
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
finish
endif
runtime plugin/vcscommand.vim
if !exists('g:loaded_VCSCommand')
runtime plugin/vcscommand.vim
endif
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
" SVN is not installed
@ -63,12 +68,19 @@ let s:svnFunctions = {}
" Section: Utility functions {{{1
" Function: s:Executable() {{{2
" Returns the executable used to invoke git suitable for use in a shell
" command.
function! s:Executable()
return VCSCommandGetOption('VCSCommandSVNExec', 'svn')
endfunction
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the
" command argument.
function! s:DoCommand(cmd, cmdName, statusText, options)
if VCSCommandGetVCSType(expand('%')) == 'SVN'
let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd
let fullCmd = s:Executable() . ' ' . a:cmd
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
else
throw 'SVN VCSCommand plugin called on non-SVN item.'
@ -79,22 +91,17 @@ endfunction
" Function: s:svnFunctions.Identify(buffer) {{{2
function! s:svnFunctions.Identify(buffer)
let fileName = resolve(bufname(a:buffer))
if isdirectory(fileName)
let directoryName = fileName
else
let directoryName = fnamemodify(fileName, ':h')
endif
if strlen(directoryName) > 0
let svnDir = directoryName . '/.svn'
else
let svnDir = '.svn'
endif
if isdirectory(svnDir)
return 1
else
return 0
endif
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
try
call s:VCSCommandUtility.system(s:Executable() . ' info .')
if(v:shell_error)
return 0
else
return g:VCSCOMMAND_IDENTIFY_EXACT
endif
finally
call VCSCommandChdir(oldCwd)
endtry
endfunction
" Function: s:svnFunctions.Add() {{{2
@ -105,7 +112,7 @@ endfunction
" Function: s:svnFunctions.Annotate(argList) {{{2
function! s:svnFunctions.Annotate(argList)
if len(a:argList) == 0
if &filetype == 'SVNAnnotate'
if &filetype ==? 'svnannotate'
" Perform annotation of the version indicated by the current line.
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
let options = ' -r' . caption
@ -121,16 +128,12 @@ function! s:svnFunctions.Annotate(argList)
let options = ' ' . caption
endif
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
if resultBuffer > 0
set filetype=SVNAnnotate
endif
return resultBuffer
return s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
endfunction
" Function: s:svnFunctions.Commit(argList) {{{2
function! s:svnFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
echomsg 'No commit needed.'
endif
@ -138,13 +141,13 @@ endfunction
" Function: s:svnFunctions.Delete() {{{2
function! s:svnFunctions.Delete(argList)
return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
endfunction
" Function: s:svnFunctions.Diff(argList) {{{2
function! s:svnFunctions.Diff(argList)
if len(a:argList) == 0
let revOptions = []
let revOptions = []
let caption = ''
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
let revOptions = ['-r' . join(a:argList, ':')]
@ -169,15 +172,7 @@ function! s:svnFunctions.Diff(argList)
let diffOptions = ['-x -' . svnDiffOpt]
endif
let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
if resultBuffer > 0
set filetype=diff
else
if svnDiffExt == ''
echomsg 'No differences found'
endif
endif
return resultBuffer
return s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
endfunction
" Function: s:svnFunctions.GetBufferInfo() {{{2
@ -189,7 +184,7 @@ endfunction
function! s:svnFunctions.GetBufferInfo()
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
let fileName = bufname(originalBuffer)
let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . fileName . '"')
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -v -- "' . fileName . '"')
if(v:shell_error)
return []
endif
@ -199,12 +194,14 @@ function! s:svnFunctions.GetBufferInfo()
return ['Unknown']
endif
let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
let [flags, revision, repository] = matchlist(statusText, '^\(.\{9}\)\s*\(\d\+\)\s\+\(\d\+\)')[1:3]
if revision == ''
" Error
return ['Unknown']
elseif flags =~ '^A'
return ['New', 'New']
elseif flags =~ '*'
return [revision, repository, '*']
else
return [revision, repository]
endif
@ -212,12 +209,12 @@ endfunction
" Function: s:svnFunctions.Info(argList) {{{2
function! s:svnFunctions.Info(argList)
return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
return s:DoCommand(join(['info --non-interactive'] + 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, ' '), {})
return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
endfunction
" Function: s:svnFunctions.Log(argList) {{{2
@ -234,7 +231,7 @@ function! s:svnFunctions.Log(argList)
let caption = join(a:argList, ' ')
endif
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {})
return resultBuffer
endfunction
@ -253,32 +250,32 @@ function! s:svnFunctions.Review(argList)
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
return s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
endfunction
" Function: s:svnFunctions.Status(argList) {{{2
function! s:svnFunctions.Status(argList)
let options = ['-u', '-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})
endfunction
" Function: s:svnFunctions.Unlock(argList) {{{2
function! s:svnFunctions.Unlock(argList)
return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
endfunction
" Function: s:svnFunctions.Update(argList) {{{2
function! s:svnFunctions.Update(argList)
return s:DoCommand('update', 'update', '', {})
return s:DoCommand('update --non-interactive', 'update', '', {})
endfunction
" Annotate setting {{{2
let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ '
" Section: Plugin Registration {{{1
call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
let s:VCSCommandUtility = VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
let &cpo = s:save_cpo

View File

@ -0,0 +1,45 @@
" Vim syntax file
" Language: CVS annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the cvscommand plugin. Originally written by Mathieu
" Clabaut
" License:
" Copyright (c) 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.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn match cvsDate /\d\d-...-\d\d/ contained
syn match cvsName /(\S* /hs=s+1,he=e-1 contained nextgroup=cvsDate
syn match cvsVer /^\d\+\(\.\d\+\)\+/ contained nextgroup=cvsName
syn region cvsHead start="^\d\+\.\d\+" end="):" contains=cvsVer,cvsName,cvsDate
if !exists("did_cvsannotate_syntax_inits")
let did_cvsannotate_syntax_inits = 1
hi link cvsDate Comment
hi link cvsName Type
hi link cvsVer Statement
endif
let b:current_syntax="CVSAnnotate"

View File

@ -0,0 +1,44 @@
" Vim syntax file
" Language: git annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) 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.
if exists("b:current_syntax")
finish
endif
syn region gitName start="(\@<=" end="\( \d\d\d\d-\)\@=" contained
syn match gitCommit /^\^\?\x\+/ contained
syn match gitDate /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ contained
syn match gitLineNumber /\d\+)\@=/ contained
syn region gitAnnotation start="^" end=") " oneline keepend contains=gitCommit,gitLineNumber,gitDate,gitName
if !exists("did_gitannotate_syntax_inits")
let did_gitannotate_syntax_inits = 1
hi link gitName Type
hi link gitCommit Statement
hi link gitDate Comment
hi link gitLineNumber Label
endif
let b:current_syntax="gitAnnotate"

View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: HG annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) 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.
if exists("b:current_syntax")
finish
endif
syn match hgVer /\d\+/ contained
syn match hgName /^\s*\S\+/ contained
syn match hgHead /^\s*\S\+\s\+\d\+:/ contains=hgVer,hgName
if !exists("did_hgannotate_syntax_inits")
let did_hgannotate_syntax_inits = 1
hi link hgName Type
hi link hgVer Statement
endif
let b:current_syntax="hgAnnotate"

View File

@ -0,0 +1,42 @@
" Vim syntax file
" Language: SVK annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) 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.
if exists("b:current_syntax")
finish
endif
syn match svkDate /\d\{4}-\d\{1,2}-\d\{1,2}/ skipwhite contained
syn match svkName /(\s*\zs\S\+/ contained nextgroup=svkDate skipwhite
syn match svkVer /^\s*\d\+/ contained nextgroup=svkName skipwhite
syn region svkHead start=/^/ end="):" contains=svkVer,svkName,svkDate oneline
if !exists("did_svkannotate_syntax_inits")
let did_svkannotate_syntax_inits = 1
hi link svkName Type
hi link svkDate Comment
hi link svkVer Statement
endif
let b:current_syntax="svkAnnotate"

View File

@ -0,0 +1,40 @@
" Vim syntax file
" Language: SVN annotate output
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
" Remark: Used by the vcscommand plugin.
" License:
" Copyright (c) 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.
if exists("b:current_syntax")
finish
endif
syn match svnName /\S\+/ contained
syn match svnVer /^\s*\zs\d\+/ contained nextgroup=svnName skipwhite
syn match svnHead /^\s*\d\+\s\+\S\+/ contains=svnVer,svnName
if !exists("did_svnannotate_syntax_inits")
let did_svnannotate_syntax_inits = 1
hi link svnName Type
hi link svnVer Statement
endif
let b:current_syntax="svnAnnotate"

View File

@ -2,7 +2,7 @@
" Language: VCS commit file
" Maintainer: Bob Hiestand (bob.hiestand@gmail.com)
" License:
" Copyright (c) 2007 Bob Hiestand
" Copyright (c) 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