Commits

salvator  committed 9f4ec9b Merge

merged

  • Participants
  • Parent commits ff58f3d, ede7610

Comments (0)

Files changed (16)

+let g:netrw_dirhistmax  =10
+let g:netrw_dirhist_cnt =9
+let g:netrw_dirhist_1='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/profile/blog/views'
+let g:netrw_dirhist_2='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/profile/blog/forms'
+let g:netrw_dirhist_3='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/profile/blog/views'
+let g:netrw_dirhist_4='/home/juice/.virtualenvs/simplesea/src/shorter/shorter'
+let g:netrw_dirhist_5='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/profile/blog/forms'
+let g:netrw_dirhist_6='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/lib/photo_uploader/migrations'
+let g:netrw_dirhist_7='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/profile/blog/forms'
+let g:netrw_dirhist_8='/home/juice/.virtualenvs/simplesea/src/simplesea/frontend/static/js'
+let g:netrw_dirhist_9='/home/juice/.virtualenvs/simplesea/src/simplesea/simplesea/settings'

File doc/vcscommand.txt

+*vcscommand.txt*	vcscommand
+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.
+
+For instructions on installing this file, type
+	:help add-local-help
+inside Vim.
+
+Author:  Bob Hiestand <bob.hiestand@gmail.com>
+Credits:  Benji Fisher's excellent MatchIt documentation
+
+==============================================================================
+1. Contents						*vcscommand-contents*
+
+	Installation		: |vcscommand-install|
+	vcscommand Intro	: |vcscommand|
+	vcscommand Manual	: |vcscommand-manual|
+	Customization		: |vcscommand-customize|
+	SSH "integration"	: |vcscommand-ssh|
+	Changes from cvscommand	: |cvscommand-changes|
+	Bugs			: |vcscommand-bugs|
+
+==============================================================================
+
+2. vcscommand Installation				*vcscommand-install*
+
+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|
+command, specifying the full path of the 'doc' directory.  Please see
+|add-local-help| for more details.
+
+vcscommand may be customized by setting variables, creating maps, and
+specifying event handlers.  Please see |vcscommand-customize| for more
+details.
+
+==============================================================================
+
+3. vcscommand Intro					*vcscommand*
+							*vcscommand-intro*
+
+The vcscommand plugin provides global ex commands for manipulating
+version-controlled source files, currently those controlled either by CVS or
+Subversion.  In general, each command operates on the current buffer and
+accomplishes a separate source control function, such as update, commit, log,
+and others (please see |vcscommand-commands| for a list of all available
+commands).  The results of each operation are displayed in a scratch buffer.
+Several buffer variables are defined for those scratch buffers (please see
+|vcscommand-buffer-variables|).
+
+The notion of "current file" means either the current buffer, or, in the case
+of a directory buffer (such as Explorer or netrw buffers), the directory (and
+all subdirectories) represented by the the buffer.
+
+For convenience, any vcscommand invoked on a vcscommand scratch buffer acts as
+though it was invoked on the original file and splits the screen so that the
+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>|
+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
+|vcscommand-mappings-override|.
+
+The vcscommand plugin may be configured in several ways.  For more details,
+please see |vcscommand-customize|.
+
+==============================================================================
+
+4. vcscommand Manual					*vcscommand-manual*
+
+4.1 vcscommand commands					*vcscommand-commands*
+
+vcscommand defines the following commands:
+
+|:VCSAdd|
+|:VCSAnnotate|
+|:VCSBlame|
+|:VCSCommit|
+|:VCSDelete|
+|:VCSDiff|
+|:VCSGotoOriginal|
+|:VCSLog|
+|:VCSRemove|
+|:VCSRevert|
+|:VCSReview|
+|:VCSStatus|
+|:VCSUpdate|
+|:VCSVimDiff|
+
+The following commands are specific to CVS files:
+
+|:CVSEdit|
+|:CVSEditors|
+|:CVSUnedit|
+|:CVSWatch|
+|:CVSWatchAdd|
+|:CVSWatchOn|
+|:CVSWatchOff|
+|:CVSWatchRemove|
+|:CVSWatchers|
+
+:VCSAdd							*:VCSAdd*
+
+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*
+
+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
+argument is used as a revision number to display.  If not given an argument,
+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.
+
+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*
+
+Alias for |:VCSAnnotate|.
+
+:VCSCommit[!]						*:VCSCommit*
+
+This command commits changes to the current file to source control.
+
+If called with arguments, the arguments are the log message.
+
+If '!' is used, an empty log message is committed.
+
+If called with no arguments, this is a two-step command.  The first step opens
+a buffer to accept a log message.  When that buffer is written, it is
+automatically closed and the file is committed using the information from that
+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, 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*
+
+Deletes the current file and removes it from source control.  All parameters
+to the command are passed to the underlying VCS.
+
+:VCSDiff						*:VCSDiff*
+
+With no arguments, this displays the differences between the current file and
+its parent version under source control in a new scratch buffer.
+
+With one argument, the diff is performed on the current file against the
+specified revision.
+
+With two arguments, the diff is performed between the specified revisions of
+the current file.
+
+For CVS, this command uses the |VCSCommandCVSDiffOpt| variable to specify diff
+options.  If that variable does not exist, a plugin-specific default is used.
+If you wish to have no options, then set it to the empty string.
+
+For SVN, this command uses the |VCSCommandSVNDiffOpt| variable to specify diff
+options.  If that variable does not exist, the SVN default is used.
+Additionally, |VCSCommandSVNDiffExt| can be used to select an external diff
+application.
+
+:VCSGotoOriginal					*:VCSGotoOriginal*
+
+This command jumps to the source buffer if the current buffer is a VCS scratch
+buffer.
+
+:VCSGotoOriginal!
+
+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
+concurrently modifying it.  The exact semantics of this command depend on the
+underlying VCS.  This does nothing in CVS.  All parameters are passed to the
+underlying VCS.
+
+:VCSLog							*:VCSLog*
+
+Displays the version history of the current file in a new scratch buffer.  If
+there is one parameter supplied, it is taken as as a revision parameters to be
+passed through to the underlying VCS.  Otherwise, all parameters are passed to
+the underlying VCS.
+
+:VCSRemove						*:VCSRemove*
+
+Alias for |:VCSDelete|.
+
+:VCSRevert						*:VCSRevert*
+
+This command replaces the current file with the most recent version from the
+repository in order to wipe out any undesired changes.
+
+:VCSReview						*:VCSReview*
+
+Displays a particular version of the current file in a new scratch buffer.  If
+no argument is given, the most recent version of the file on the current
+branch is retrieved.
+
+:VCSStatus						*:VCSStatus*
+
+Displays versioning information about the current file in a new scratch
+buffer.  All parameters are passed to the underlying VCS.
+
+
+:VCSUnlock						*:VCSUnlock*
+
+Unlocks the current file in order to allow other users from concurrently
+modifying it.  The exact semantics of this command depend on the underlying
+VCS.  All parameters are passed to the underlying VCS.
+
+:VCSUpdate						*:VCSUpdate*
+
+Updates the current file with any relevant changes from the repository.  This
+intentionally does not automatically reload the current buffer, though vim
+should prompt the user to do so if the underlying file is altered by this
+command.
+
+:VCSVimDiff						*:VCSVimDiff*
+
+Uses vimdiff to display differences between versions of the current file.
+
+If no revision is specified, the most recent version of the file on the
+current branch is used.  With one argument, that argument is used as the
+revision as above.  With two arguments, the differences between the two
+revisions is displayed using vimdiff.
+                                                            
+With either zero or one argument, the original buffer is used to perform the
+vimdiff.  When the scratch buffer is closed, the original buffer will be
+returned to normal mode.
+                                                            
+Once vimdiff mode is started using the above methods, additional vimdiff
+buffers may be added by passing a single version argument to the command.
+There may be up to 4 vimdiff buffers total.
+                                                            
+Using the 2-argument form of the command resets the vimdiff to only those 2
+versions.  Additionally, invoking the command on a different file will close
+the previous vimdiff buffers.
+
+:CVSEdit						*:CVSEdit*
+
+This command performs "cvs edit" on the current file.  Yes, the output buffer
+in this case is almost completely useless.
+
+:CVSEditors						*:CVSEditors*
+
+This command performs "cvs edit" on the current file.
+
+:CVSUnedit						*:CVSUnedit*
+
+Performs "cvs unedit" on the current file.  Again, yes, the output buffer here
+is basically useless.
+
+:CVSWatch						*:CVSWatch*
+
+This command takes an argument which must be one of [on|off|add|remove].  The
+command performs "cvs watch" with the given argument on the current file.
+
+:CVSWatchAdd						*:CVSWatchAdd*
+
+This command is an alias for ":CVSWatch add"
+
+:CVSWatchOn						*:CVSWatchOn*
+
+This command is an alias for ":CVSWatch on"
+
+:CVSWatchOff						*:CVSWatchOff*
+
+This command is an alias for ":CVSWatch off"
+
+:CVSWatchRemove						*:CVSWatchRemove*
+
+This command is an alias for ":CVSWatch remove"
+
+:CVSWatchers						*:CVSWatchers*
+
+This command performs "cvs watchers" on the current file.
+
+4.2 Mappings						*vcscommand-mappings*
+
+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>|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
+
+						*vcscommand-mappings-override*
+
+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).
+
+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
+may be useful for additional customization in callbacks defined in the event
+handlers (please see |vcscommand-events|).
+
+The following variables are automatically defined:
+
+b:VCSCommandOriginalBuffer			*b:VCSCommandOriginalBuffer*
+
+This variable is set to the buffer number of the source file.
+
+b:VCSCommandCommand				*b:VCSCommandCommand*
+
+This variable is set to the name of the vcscommand that created the result
+buffer.
+
+b:VCSCommandSourceFile				*b:VCSCommandSourceFile*
+
+This variable is set to the name of the original file under source control.
+
+b:VCSCommandVCSType				*b:VCSCommandVCSType*
+
+This variable is set to the type of the source control.  This variable is also
+set on the original file itself.
+==============================================================================
+
+5. Configuration and customization			*vcscommand-customize*
+							*vcscommand-config*
+
+The vcscommand plugin can be configured in several ways:  by setting
+configuration variables (see |vcscommand-options|) or by defining vcscommand
+event handlers (see |vcscommand-events|).  Additionally, the vcscommand plugin
+supports a customized status line (see |vcscommand-statusline| and
+|vcscommand-buffer-management|).
+
+5.1 vcscommand configuration variables			*vcscommand-options*
+
+Several variables affect the plugin's behavior.  These variables are checked
+at time of execution, and may be defined at the window, buffer, or global
+level and are checked in that order of precedence.
+
+
+The following variables are available:
+
+|VCSCommandCommitOnWrite|
+|VCSCommandCVSDiffOpt|
+|VCSCommandCVSExec|
+|VCSCommandDeleteOnHide|
+|VCSCommandDiffSplit|
+|VCSCommandDisableAll|
+|VCSCommandDisableMappings|
+|VCSCommandDisableExtensionMappings|
+|VCSCommandDisableMenu|
+|VCSCommandEdit|
+|VCSCommandEnableBufferSetup|
+|VCSCommandMappings|
+|VCSCommandMapPrefix|
+|VCSCommandMenuPriority|
+|VCSCommandMenuRoot|
+|VCSCommandResultBufferNameExtension|
+|VCSCommandResultBufferNameFunction|
+|VCSCommandSplit|
+|VCSCommandSVKExec|
+|VCSCommandSVNDiffExt|
+|VCSCommandSVNDiffOpt|
+|VCSCommandSVNExec|
+|VCSCommandVCSTypeOverride|
+|VCSCommandVCSTypePreference|
+
+VCSCommandCommitOnWrite				*VCSCommandCommitOnWrite*
+
+This variable, if set to a non-zero value, causes the pending commit
+to take place immediately as soon as the log message buffer is written.
+If set to zero, only the VCSCommit mapping will cause the pending commit to
+occur.	If not set, it defaults to 1.
+
+VCSCommandCVSExec				*VCSCommandCVSExec*
+
+This variable controls the executable used for all CVS commands  If not set,
+it defaults to "cvs".
+
+VCSCommandDeleteOnHide				*VCSCommandDeleteOnHide*
+
+This variable, if set to a non-zero value, causes the temporary result buffers
+to automatically delete themselves when hidden.
+
+VCSCommandCVSDiffOpt				*VCSCommandCVSDiffOpt*
+
+This variable, if set, determines the options passed to the diff command of
+CVS.  If not set, it defaults to 'u'.
+
+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
+mappings from being set.  This supercedes 
+|VCSCommandDisableExtensionMappings|.
+
+VCSCommandDisableExtensionMappings	*VCSCommandDisableExtensionMappings*
+
+This variable, if set to a non-zero value, prevents the default command
+mappings from being set for commands specific to an individual VCS.
+
+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
+mode see (|vcscommand-buffer-management|).  This mode means that the
+'VCSCommandBufferInfo' variable is filled with version information if the file
+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
+command output buffers.  For example, '.vcs'.  Using this option may help
+avoid problems caused by autocommands dependent on file extension.
+
+VCSCommandResultBufferNameFunction	*VCSCommandResultBufferNameFunction*
+
+This variable, if set, specifies a custom function for naming VCS command
+output buffers.  This function is expected to return the new buffer name, and
+will be passed the following arguments:
+
+  command - name of the VCS command being executed (such as 'Log' or
+  'Diff').
+  
+  originalBuffer - buffer number of the source file.
+  
+  vcsType - type of VCS controlling this file (such as 'CVS' or 'SVN').
+  
+  statusText - extra text associated with the VCS action (such as version
+  numbers).
+
+VCSCommandSplit					*VCSCommandSplit*
+
+This variable controls the orientation of the various window splits that
+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 default to the user's 'diffopt'
+setting, if set, otherwise 'vertical'.
+
+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
+an external application for performing the diff.
+
+VCSCommandSVNDiffOpt				*VCSCommandSVNDiffOpt*
+
+This variable, if set, determines the options passed with the '-x' parameter
+to the SVN diff command.  If not set, no options are passed.
+
+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.
+Event handlers are provided by defining User event autocommands (see
+|autocommand|, |User|) in the vcscommand group with patterns matching the
+event name.
+
+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>
+augroup END
+
+The following hooks are available:
+
+VCSBufferCreated		This event is fired just after a vcscommand
+                                result buffer is created and populated.  It is
+                                executed within the context of the vcscommand
+                                buffer.  The vcscommand buffer variables may
+                                be useful for handlers of this event (please
+                                see |vcscommand-buffer-variables|).
+
+VCSBufferSetup			This event is fired just after vcscommand buffer
+                                setup occurs, if enabled.
+
+VCSPluginInit			This event is fired when the vcscommand plugin
+				first loads.
+
+VCSPluginFinish			This event is fired just after the vcscommand
+				plugin loads.
+
+VCSVimDiffFinish		This event is fired just after the VCSVimDiff
+				command executes to allow customization of,
+				for instance, window placement and focus.
+
+Additionally, there is another hook which is used internally to handle loading
+the multiple scripts in order.  This hook should probably not be used by an
+end user without a good idea of how it works.  Among other things, any events
+associated with this hook are cleared after they are executed (during
+vcscommand.vim script initialization).
+
+VCSLoadExtensions		This event is fired just before the
+                                VCSPluginFinish.  It is used internally to
+                                execute any commands from the VCS
+                                implementation plugins that needs to be
+                                deferred until the primary plugin is
+                                initialized.
+
+5.3 vcscommand buffer naming				*vcscommand-naming*
+
+vcscommand result buffers use the following naming convention:
+[{VCS type} {VCS command} {Source file name}]
+
+If additional buffers are created that would otherwise conflict, a
+distinguishing number is added:
+
+[{VCS type} {VCS command} {Source file name}] (1,2, etc)
+
+5.4 vcscommand status line support			*vcscommand-statusline*
+
+It is intended that the user will customize the |'statusline'| option to
+include vcscommand result buffer attributes.  A sample function that may be
+used in the |'statusline'| option is provided by the plugin,
+VCSCommandGetStatusLine().  In order to use that function in the status line, do
+something like the following:
+
+set statusline=%<%f\ %{VCSCommandGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P
+
+of which %{VCSCommandGetStatusLine()} is the relevant portion.
+
+The sample VCSCommandGetStatusLine() function handles both vcscommand result
+buffers and VCS-managed files if vcscommand buffer management is enabled
+(please see |vcscommand-buffer-management|).
+
+5.5 vcscommand buffer management		*vcscommand-buffer-management*
+
+The vcscommand plugin can operate in buffer management mode, which means that
+it attempts to set a buffer variable ('VCSCommandBufferInfo') upon entry into
+a buffer.  This is rather slow because it means that the VCS will be invoked
+at each entry into a buffer (during the |BufEnter| autocommand).
+
+This mode is disabled by default.  In order to enable it, set the
+|VCSCommandEnableBufferSetup| variable to a true (non-zero) value.  Enabling
+this mode simply provides the buffer variable mentioned above.  The user must
+explicitly include information from the variable in the |'statusline'| option
+if they are to appear in the status line (but see |vcscommand-statusline| for
+a simple way to do that).
+
+The 'VCSCommandBufferInfo' variable is a list which contains, in order, the
+revision of the current file, the latest revision of the file in the
+repository, and (for CVS) the name of the branch.  If those values cannot be
+determined, the list is a single element:  'Unknown'.
+
+==============================================================================
+
+6. SSH "integration"					*vcscommand-ssh*
+
+The following instructions are intended for use in integrating the
+vcscommand.vim plugin with an SSH-based CVS environment.
+
+Familiarity with SSH and CVS are assumed.
+
+These instructions assume that the intent is to have a message box pop up in
+order to allow the user to enter a passphrase.  If, instead, the user is
+comfortable using certificate-based authentication, then only instructions
+6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then
+work transparently.
+
+6.1 Environment settings				*vcscommand-ssh-env*
+
+6.1.1 CVSROOT should be set to something like:
+
+	:ext:user@host:/path_to_repository
+
+6.1.2 CVS_RSH should be set to:
+
+	ssh
+
+	Together, those settings tell CVS to use ssh as the transport when
+	performing CVS calls.
+
+6.1.3 SSH_ASKPASS should be set to the password-dialog program.  In my case,
+	running gnome, it's set to:
+
+	/usr/libexec/openssh/gnome-ssh-askpass
+
+	This tells SSH how to get passwords if no input is available.
+
+6.1.4 OPTIONAL.  You may need to set SSH_SERVER to the location of the cvs
+	executable on the remote (server) machine.
+
+6.2 CVS wrapper program				*vcscommand-ssh-wrapper*
+
+Now you need to convince SSH to use the password-dialog program.  This means
+you need to execute SSH (and therefore CVS) without standard input.  The
+following script is a simple perl wrapper that dissasociates the CVS command
+from the current terminal.  Specific steps to do this may vary from system to
+system; the following example works for me on linux.
+
+#!/usr/bin/perl -w
+use strict;
+use POSIX qw(setsid);
+open STDIN, '/dev/null';
+fork and do {wait; exit;};
+setsid;
+exec('cvs', @ARGV);
+
+6.3 Configuring vcscommand.vim			*vcscommand-ssh-config*
+
+At this point, you should be able to use your wrapper script to invoke CVS with
+various commands, and get the password dialog.  All that's left is to make CVS
+use your newly-created wrapper script.
+
+6.3.1 Tell vcscommand.vim what CVS executable to use.  The easiest way to do this
+	is globally, by putting the following in your .vimrc:
+
+	let VCSCommandCVSExec=/path/to/cvs/wrapper/script
+
+6.4 Where to go from here			*vcscommand-ssh-other*
+
+The script given above works even when non-SSH CVS connections are used,
+except possibly when interactively entering the message for CVS commit log
+(depending on the editor you use... VIM works fine).  Since the vcscommand.vim
+plugin handles that message without a terminal, the wrapper script can be used
+all the time.
+
+This allows mixed-mode operation, where some work is done with SSH-based CVS
+repositories, and others with pserver or local access.
+
+It is possible, though beyond the scope of the plugin, to dynamically set the
+CVS executable based on the CVSROOT for the file being edited.  The user
+events provided (such as VCSBufferCreated and VCSBufferSetup) can be used to
+set a buffer-local value (b:VCSCommandCVSExec) to override the CVS executable
+on a file-by-file basis.  Alternatively, much the same can be done (less
+automatically) by the various project-oriented plugins out there.
+
+It is highly recommended for ease-of-use that certificates with no passphrase
+or ssh-agent are employed so that the user is not given the password prompt
+too often.
+
+==============================================================================
+
+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.
+
+2.  Renamed commands to start with 'VCS' instead of 'CVS'.  The exceptions are
+the 'CVSEdit' and 'CVSWatch' family of commands, which are specific to CVS.
+
+3.  Renamed options, events to start with 'VCSCommand'.
+
+4.  Removed option to jump to the parent version of the current line in an
+annotated buffer, as opposed to the version on the current line.  This made
+little sense in the branching scheme used by subversion, where jumping to a
+parent branch required finding a different location in the repository.  It
+didn't work consistently in CVS anyway.
+
+5.  Removed option to have nameless scratch buffers.
+
+6.  Changed default behavior of scratch buffers to split the window instead of
+displaying in the current window.  This may still be overridden using the
+'VCSCommandEdit' option.
+
+7.  Split plugin into multiple plugins.
+
+8.  Added 'VCSLock' and 'VCSUnlock' commands.  These are implemented for
+subversion but not for CVS.  These were not kept specific to subversion as they
+seemed more general in nature and more likely to be supported by any future VCS
+supported by this plugin.
+
+9.  Changed name of buffer variables set by commands.
+
+'b:cvsOrigBuffNR' became 'b:VCSCommandOriginalBuffer'
+'b:cvscmd' became 'b:VCSCommandCommand'
+
+10.  Added new automatic variables to command result buffers.
+
+'b:VCSCommandSourceFile'
+'b:VCSCommandVCSType'
+
+==============================================================================
+
+8. Known bugs						*vcscommand-bugs*
+
+Please let me know if you run across any.
+
+CVSUnedit may, if a file is changed from the repository, provide prompt text
+to determine whether the changes should be thrown away.  Currently, that text
+shows up in the CVS result buffer as information; there is no way for the user
+to actually respond to the prompt and the CVS unedit command does nothing.  If
+this really bothers anyone, please let me know.
+
+VCSVimDiff, when using the original (real) source buffer as one of the diff
+buffers, uses some hacks to try to restore the state of the original buffer
+when the scratch buffer containing the other version is destroyed.  There may
+still be bugs in here, depending on many configuration details.
+
+vim:tw=78:ts=8:ft=help

File plugin/vcsbzr.vim

+" 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 plugin/vcscommand.vim

+" vim600: set foldmethod=marker:
+"
+" Vim plugin to assist in working with files under control of various Version
+" Control Systems, such as CVS, SVN, SVK, and git.
+"
+" 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
+"
+" Provides functions to invoke various source control commands on the current
+" file (either the current buffer, or, in the case of an directory buffer, the
+" directory and all subdirectories associated with the current buffer).  The
+" output of the commands is captured in a new scratch window.
+"
+" This plugin needs additional extension plugins, each specific to a source
+" control system, to function.  Several options include the name of the
+" version control system in the option name.  Such options use the placeholder
+" text '{VCSType}', which would be replaced in actual usage with 'CVS' or
+" 'SVN', for instance.
+"
+" Command documentation {{{2
+"
+" VCSAdd           Adds the current file to source control.
+"
+" VCSAnnotate[!]   Displays the current file with each line annotated with the
+"                  version in which it was most recently changed.  If an
+"                  argument is given, the argument is used as a revision
+"                  number to display.  If not given an argument, it uses the
+"                  most recent version of the file on the current branch.
+"                  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.
+"
+" VCSBlame         Alias for 'VCSAnnotate'.
+"
+" VCSCommit[!]     Commits changes to the current file to source control.
+"
+"                  If called with arguments, the arguments are the log message.
+"
+"                  If '!' is used, an empty log message is committed.
+"
+"                  If called with no arguments, this is a two-step command.
+"                  The first step opens a buffer to accept a log message.
+"                  When that buffer is written, it is automatically closed and
+"                  the file is committed using the information from that log
+"                  message.  The commit can be abandoned if the log message
+"                  buffer is deleted or wiped before being written.
+"
+" VCSDelete        Deletes the current file and removes it from source control.
+"
+" VCSDiff          With no arguments, this displays the differences between
+"                  the current file and its parent version under source
+"                  control in a new scratch buffer.
+"
+"                  With one argument, the diff is performed on the
+"                  current file against the specified revision.
+"
+"                  With two arguments, the diff is performed between the
+"                  specified revisions of the current file.
+"
+"                  This command uses the 'VCSCommand{VCSType}DiffOpt' variable
+"                  to specify diff options.  If that variable does not exist,
+"                  a plugin-specific default is used.  If you wish to have no
+"                  options, then set it to the empty string.
+"
+" VCSGotoOriginal  Jumps to the source buffer if the current buffer is a VCS
+"                  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.
+"
+" VCSLog           Displays the version history of the current file in a new
+"                  scratch buffer.
+"
+" VCSRemove        Alias for 'VCSDelete'.
+"
+" VCSRevert        Replaces the modified version of the current file with the
+"                  most recent version from the repository.
+"
+" VCSReview        Displays a particular version of the current file in a new
+"                  scratch buffer.  If no argument is given, the most recent
+"                  version of the file on the current branch is retrieved.
+"
+" VCSStatus        Displays versioning information about the current file in a
+"                  new scratch buffer.
+"
+" VCSUnlock        Unlocks the current file in order to allow other users from
+"                  concurrently modifying it.  The exact semantics of this
+"                  command depend on the underlying VCS.
+"
+" VCSUpdate        Updates the current file with any relevant changes from the
+"                  repository.
+"
+" VCSVimDiff       Uses vimdiff to display differences between versions of the
+"                  current file.
+"
+"                  If no revision is specified, the most recent version of the
+"                  file on the current branch is used.  With one argument,
+"                  that argument is used as the revision as above.  With two
+"                  arguments, the differences between the two revisions is
+"                  displayed using vimdiff.
+"
+"                  With either zero or one argument, the original buffer is
+"                  used to perform the vimdiff.  When the scratch buffer is
+"                  closed, the original buffer will be returned to normal
+"                  mode.
+"
+"                  Once vimdiff mode is started using the above methods,
+"                  additional vimdiff buffers may be added by passing a single
+"                  version argument to the command.  There may be up to 4
+"                  vimdiff buffers total.
+"
+"                  Using the 2-argument form of the command resets the vimdiff
+"                  to only those 2 versions.  Additionally, invoking the
+"                  command on a different file will close the previous vimdiff
+"                  buffers.
+"
+" Mapping documentation: {{{2
+"
+" By default, a mapping is defined for each command.  User-provided mappings
+" can be used instead by mapping to <Plug>CommandName, for instance:
+"
+" nmap ,ca <Plug>VCSAdd
+"
+" The default mappings are as follow:
+"
+"   <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
+"
+" Options documentation: {{{2
+"
+" Several variables are checked by the script to determine behavior as follow:
+"
+" VCSCommandCommitOnWrite
+"   This variable, if set to a non-zero value, causes the pending commit to
+"   take place immediately as soon as the log message buffer is written.  If
+"   set to zero, only the VCSCommit mapping will cause the pending commit to
+"   occur.  If not set, it defaults to 1.
+"
+" VCSCommandDeleteOnHide
+"   This variable, if set to a non-zero value, causes the temporary VCS result
+"   buffers to automatically delete themselves when hidden.
+"
+" VCSCommand{VCSType}DiffOpt
+"   This variable, if set, determines the options passed to the diff command
+"   of the underlying VCS.  Each VCS plugin defines a default value.
+"
+" VCSCommandDiffSplit
+"   This variable overrides the VCSCommandSplit variable, but only for buffers
+"   created with VCSVimDiff.
+"
+" 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
+"   This variable, if set to a non-zero value, prevents the default command
+"   mappings from being set.
+"
+" VCSCommandDisableExtensionMappings
+"   This variable, if set to a non-zero value, prevents the default command
+"   mappings from being set for commands specific to an individual VCS.
+"
+" VCSCommandDisableMenu
+"   This variable, if set to a non-zero value, prevents the default command
+"   menu from being set.
+"
+" VCSCommandEdit
+"   This variable controls whether to split the current window to display a
+"   scratch buffer ('split'), or to display it in the current buffer ('edit').
+"   If not set, it defaults to 'split'.
+"
+" VCSCommandEnableBufferSetup
+"   This variable, if set to a non-zero value, activates VCS buffer management
+"   mode.  This mode means that the buffer variable 'VCSRevision' is set if
+"   the file is VCS-controlled.  This is useful for displaying version
+"   information in the status bar.  Additional options may be set by
+"   individual VCS plugins.
+"
+" 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.
+"
+" 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
+"   This variable, if set, overrides the default menu priority '' (empty)
+"
+" VCSCommandMenuRoot
+"   This variable, if set, overrides the default menu root 'Plugin.VCS'
+"
+" VCSCommandResultBufferNameExtension
+"   This variable, if set to a non-blank value, is appended to the name of the
+"   VCS command output buffers.  For example, '.vcs'.  Using this option may
+"   help avoid problems caused by autocommands dependent on file extension.
+"
+" VCSCommandResultBufferNameFunction
+"   This variable, if set, specifies a custom function for naming VCS command
+"   output buffers.  This function will be passed the following arguments:
+"
+"   command - name of the VCS command being executed (such as 'Log' or
+"   'Diff').
+"
+"   originalBuffer - buffer number of the source file.
+"
+"   vcsType - type of VCS controlling this file (such as 'CVS' or 'SVN').
+"
+"   statusText - extra text associated with the VCS action (such as version
+"   numbers).
+"
+" VCSCommandSplit
+"   This variable controls the orientation of the various window splits that
+"   may occur (such as with VCSVimDiff, when using a VCS command on a VCS
+"   command buffer, or when the 'VCSCommandEdit' variable is set to 'split'.
+"   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.
+"
+" 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 high-level List item 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
+"   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.
+"
+" Event documentation {{{2
+"   For additional customization, VCSCommand.vim uses User event autocommand
+"   hooks.  Each event is in the VCSCommand group, and different patterns
+"   match the various hooks.
+"
+"   For instance, the following could be added to the vimrc to provide a 'q'
+"   mapping to quit a VCS scratch buffer:
+"
+"   augroup VCSCommand
+"     au VCSCommand User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr>
+"   augroup END
+"
+"   The following hooks are available:
+"
+"   VCSBufferCreated           This event is fired just after a VCS command
+"                              output buffer is created.  It is executed
+"                              within the context of the new buffer.
+"
+"   VCSBufferSetup             This event is fired just after VCS buffer setup
+"                              occurs, if enabled.
+"
+"   VCSPluginInit              This event is fired when the VCSCommand plugin
+"                              first loads.
+"
+"   VCSPluginFinish            This event is fired just after the VCSCommand
+"                              plugin loads.
+"
+"   VCSVimDiffFinish           This event is fired just after the VCSVimDiff
+"                              command executes to allow customization of,
+"                              for instance, window placement and focus.
+"
+" Section: Plugin header {{{1
+
+" loaded_VCSCommand is set to 1 when the initialization begins, and 2 when it
+" completes.  This allows various actions to only be taken by functions after
+" system initialization.
+
+if exists('VCSCommandDisableAll')
+	finish
+endif
+
+if exists('loaded_VCSCommand')
+	finish
+endif
+let loaded_VCSCommand = 1
+
+if v:version < 700
+	echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
+	finish
+endif
+
+let s:save_cpo=&cpo
+set cpo&vim
+
+" Section: Event group setup {{{1
+
+augroup VCSCommand
+augroup END
+
+augroup VCSCommandCommit
+augroup END
+
+" Section: Plugin initialization {{{1
+silent do VCSCommand User VCSPluginInit
+
+" Section: Constants declaration {{{1
+
+let g:VCSCOMMAND_IDENTIFY_EXACT = 1
+let g:VCSCOMMAND_IDENTIFY_INEXACT = -1
+
+" Section: Script variable initialization {{{1
+
+" Hidden functions for use by extensions
+let s:VCSCommandUtility = {}
+
+" plugin-specific information:  {vcs -> [script, {command -> function}, {key -> mapping}]}
+let s:plugins = {}
+
+" Stack of dictionaries representing nested options
+let s:executionContext = []
+
+" state flag used to vary behavior of certain automated actions
+let s:isEditFileRunning = 0
+
+" 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:VCSCommandUtility.system(...) {{{2
+" Replacement for system() function.  This version protects the quoting in the
+" command line on Windows systems.
+
+function! s:VCSCommandUtility.system(...)
+	if (has("win32") || has("win64")) && &sxq !~ '"'
+		let save_sxq = &sxq
+		set sxq=\"
+	endif
+	try
+		let output = call('system', a:000)
+		if exists('*iconv') && has('multi_byte')
+			if(strlen(&tenc) && &tenc != &enc)
+				let output = iconv(output, &tenc, &enc)
+			else
+				let originalBuffer = VCSCommandGetOriginalBuffer(VCSCommandGetOption('VCSCommandEncodeAsFile', 0))
+				if originalBuffer
+					let fenc = getbufvar(originalBuffer, '&fenc')
+					if fenc != &enc
+						let output = iconv(output, fenc, &enc)
+					endif
+				endif
+			endif
+
+		endif
+	finally
+		if exists("save_sxq")
+			let &sxq = save_sxq
+		endif
+	endtry
+	return output
+endfunction
+
+" Function: s:VCSCommandUtility.addMenuItem(shortcut, command) {{{2
+" Adds the given menu item.
+
+function! s:VCSCommandUtility.addMenuItem(shortcut, command)
+	if s:menuEnabled
+	    exe 'amenu <silent> '.s:menuPriority.' '.s:menuRoot.'.'.a:shortcut.' '.a:command
+	endif
+endfunction
+
+" Function: s:VCSCommandUtility.pushContext(context) {{{2
+" Adds a dictionary containing current options to the stack.
+
+function! s:VCSCommandUtility.pushContext(context)
+	call insert(s:executionContext, a:context)
+endfunction
+
+" Function: s:VCSCommandUtility.popContext() {{{2
+" Removes a dictionary containing current options from the stack.
+
+function! s:VCSCommandUtility.popContext()
+	call remove(s:executionContext, 0)
+endfunction
+
+" Function: s:ClearMenu() {{{2
+" Removes all VCSCommand menu items
+function! s:ClearMenu()
+	if s:menuEnabled
+		execute 'aunmenu' s:menuRoot
+	endif
+endfunction
+
+" Function: s:CreateMapping(shortcut, expansion, display) {{{2
+" Creates the given mapping by prepending the contents of
+" 'VCSCommandMapPrefix' (by default '<Leader>c') to the given shortcut and
+" mapping it to the given plugin function.  If a mapping exists for the
+" specified shortcut + prefix, emit an error but continue.  If a mapping
+" exists for the specified function, do nothing.
+
+function! s:CreateMapping(shortcut, expansion, display)
+	let lhs = VCSCommandGetOption('VCSCommandMapPrefix', '<Leader>c') . a:shortcut
+	if !hasmapto(a:expansion)
+		try
+			execute 'nmap <silent> <unique>' lhs a:expansion
+		catch /^Vim(.*):E227:/
+			if(&verbose != 0)
+				echohl WarningMsg|echomsg 'VCSCommand:  mapping ''' . lhs . ''' already exists, refusing to overwrite.  The mapping for ' . a:display . ' will not be available.'|echohl None
+			endif
+		endtry
+	endif
+endfunction
+
+" Function: s:ExecuteExtensionMapping(mapping) {{{2
+" Invokes the appropriate extension mapping depending on the type of the
+" current buffer.
+
+function! s:ExecuteExtensionMapping(mapping)
+	let buffer = bufnr('%')
+	let vcsType = VCSCommandGetVCSType(buffer)
+	if !has_key(s:plugins, vcsType)
+		throw 'Unknown VCS type:  ' . vcsType
+	endif
+	if !has_key(s:plugins[vcsType][2], a:mapping)
+		throw 'This extended mapping is not defined for ' . vcsType
+	endif
+	silent execute 'normal!' ':' .  s:plugins[vcsType][2][a:mapping] . "\<CR>"
+endfunction
+
+" 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, argList)
+	try
+		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)
+
+		" It is already known that the directory is under VCS control.  No further
+		" checks are needed.  Otherwise, perform some basic sanity checks to avoid
+		" VCS-specific error messages from confusing things.
+		if !isdirectory(bufferName)
+			if !filereadable(bufferName)
+				throw 'No such file ' . bufferName
+			endif
+		endif
+
+		let functionMap = s:plugins[vcsType][1]
+		if !has_key(functionMap, a:command)
+			throw 'Command ''' . a:command . ''' not implemented for ' . vcsType
+		endif
+		return functionMap[a:command](a:argList)
+	catch
+		call s:ReportError(v:exception)
+		return -1
+	endtry
+endfunction
+
+" Function: s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText) {{{2
+" Default method of generating the name for VCS result buffers.  This can be
+" overridden with the VCSResultBufferNameFunction variable.
+
+function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusText)
+	let fileName = bufname(a:originalBuffer)
+	let bufferName = a:vcsType . ' ' . a:command
+	if strlen(a:statusText) > 0
+		let bufferName .= ' ' . a:statusText
+	endif
+	let bufferName .= ' ' . fileName
+	let counter = 0
+	let versionedBufferName = bufferName
+	while bufexists(versionedBufferName)
+		let counter += 1
+		let versionedBufferName = bufferName . ' (' . counter . ')'
+	endwhile
+	return versionedBufferName
+endfunction
+
+" Function: s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText) {{{2
+" Method of generating the name for VCS result buffers that uses the original
+" file name with the VCS type and command appended as extensions.
+
+function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsType, statusText)
+	let fileName = bufname(a:originalBuffer)
+	let bufferName = a:vcsType . ' ' . a:command
+	if strlen(a:statusText) > 0
+		let bufferName .= ' ' . a:statusText
+	endif
+	let bufferName .= ' ' . fileName . VCSCommandGetOption('VCSCommandResultBufferNameExtension', '.vcs')
+	let counter = 0
+	let versionedBufferName = bufferName
+	while bufexists(versionedBufferName)
+		let counter += 1
+		let versionedBufferName = '(' . counter . ') ' . bufferName
+	endwhile
+	return versionedBufferName
+endfunction
+
+" Function: s:EditFile(command, originalBuffer, statusText) {{{2
+" Creates a new buffer of the given name and associates it with the given
+" original buffer.
+
+function! s:EditFile(command, originalBuffer, statusText)
+	let vcsType = getbufvar(a:originalBuffer, 'VCSCommandVCSType')
+
+	" Protect against useless buffer set-up
+	let s:isEditFileRunning += 1
+	try
+		let editCommand = VCSCommandGetOption('VCSCommandEdit', 'split')
+		if editCommand == 'split'
+			if VCSCommandGetOption('VCSCommandSplit', 'horizontal') == 'horizontal'
+				rightbelow split
+			else
+				vert rightbelow split
+			endif
+		endif
+
+		enew
+
+		call s:SetupScratchBuffer(a:command, vcsType, a:originalBuffer, a:statusText)
+
+	finally
+		let s:isEditFileRunning -= 1
+	endtry
+endfunction
+
+" Function:  s:IdentifyVCSType() {{{2
+" This function implements the non-cached identification strategy for
+" VcsCommandGetVCSType().
+"
+" Returns:  VCS type name identified for the given buffer; an exception is
+" thrown in case no type can be identified.
+
+function!  s:IdentifyVCSType(buffer)
+	if exists("g:VCSCommandVCSTypeOverride")
+		let fullpath = fnamemodify(bufname(a:buffer), ':p')
+		for [path, vcsType] in g:VCSCommandVCSTypeOverride
+			if match(fullpath, path) > -1
+				return vcsType
+			endif
+		endfor
+	endif
+	let matches = []
+	let exactMatch = ''
+	let exactMatchCount = 0
+	for vcsType in keys(s:plugins)
+		let identified = s:plugins[vcsType][1].Identify(a:buffer)
+		if identified
+			if identified == g:VCSCOMMAND_IDENTIFY_EXACT
+				let exactMatch = vcsType
+				let exactMatchCount += 1
+			endif
+			call add(matches, [vcsType, identified])
+		endif
+	endfor
+	if len(matches) == 1
+		return matches[0][0]
+	elseif len(matches) == 0
+		throw 'No suitable plugin'
+	else
+		let preferences = VCSCommandGetOption("VCSCommandVCSTypePreference", [])
+		if len(preferences) > 0
+			if type(preferences) == 1
+				let listPreferences = split(preferences, '\W\+')
+				unlet preferences
+				let preferences = listPreferences
+			endif
+			for preferred in preferences
+				for [vcsType, identified] in matches
+					if vcsType ==? preferred
+						return vcsType
+					endif
+				endfor
+			endfor
+		endif
+
+		if exactMatchCount == 1
+			return exactMatch
+		endif
+
+		throw 'can''t identify VCS type for current buffer due to too many matching VCS:  ' . join(map(matches, 'v:val[0]'))
+	endif
+endfunction
+
+" Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2
+" Creates convenience buffer variables and the name of a vcscommand result
+" buffer.
+
+function! s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText)
+	let nameExtension = VCSCommandGetOption('VCSCommandResultBufferNameExtension', '')
+	if nameExtension == ''
+		let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferName')
+	else
+		let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferNameWithExtension')
+	endif
+
+	let name = call(nameFunction, [a:command, a:originalBuffer, a:vcsType, a:statusText])
+
+	let b:VCSCommandCommand = a:command
+	let b:VCSCommandOriginalBuffer = a:originalBuffer
+	let b:VCSCommandSourceFile = bufname(a:originalBuffer)
+	let b:VCSCommandVCSType = a:vcsType
+	if a:statusText != ''
+		let b:VCSCommandStatusText = a:statusText
+	endif
+
+	setlocal buftype=nofile
+	setlocal noswapfile
+	let &filetype = tolower(a:vcsType . a:command)
+
+	if VCSCommandGetOption('VCSCommandDeleteOnHide', 0)
+		setlocal bufhidden=delete
+	endif
+	silent noautocmd file `=name`
+endfunction
+
+" Function: s:SetupBuffer() {{{2
+" Attempts to set the b:VCSCommandBufferInfo variable
+
+function! s:SetupBuffer()
+	if (exists('b:VCSCommandBufferSetup') && b:VCSCommandBufferSetup)
+		" This buffer is already set up.
+		return
+	endif
+
+	if !isdirectory(@%) && (strlen(&buftype) > 0 || !filereadable(@%))
+		" No special status for special buffers other than directory buffers.
+		return
+	endif
+
+	if !VCSCommandGetOption('VCSCommandEnableBufferSetup', 0) || s:isEditFileRunning > 0
+		unlet! b:VCSCommandBufferSetup
+		return
+	endif
+
+	try
+		let vcsType = VCSCommandGetVCSType(bufnr('%'))
+		let b:VCSCommandBufferInfo = s:plugins[vcsType][1].GetBufferInfo()
+		silent do VCSCommand User VCSBufferSetup
+	catch /No suitable plugin/
+		" This is not a VCS-controlled file.
+		let b:VCSCommandBufferInfo = []
+	endtry
+
+	let b:VCSCommandBufferSetup = 1
+endfunction
+
+" Function: s:MarkOrigBufferForSetup(buffer) {{{2
+" Resets the buffer setup state of the original buffer for a given VCS scratch
+" buffer.
+" Returns:  The VCS buffer number in a passthrough mode.
+
+function! s:MarkOrigBufferForSetup(buffer)
+	checktime
+	if a:buffer > 0
+		let origBuffer = VCSCommandGetOriginalBuffer(a:buffer)
+		" This should never not work, but I'm paranoid
+		if origBuffer != a:buffer
+			call setbufvar(origBuffer, 'VCSCommandBufferSetup', 0)
+		endif
+	endif
+	return a:buffer
+endfunction
+
+" Function: s:WipeoutCommandBuffers() {{{2
+" Clears all current VCS output buffers of the specified type for a given source.
+
+function! s:WipeoutCommandBuffers(originalBuffer, VCSCommand)
+	let buffer = 1
+	while buffer <= bufnr('$')
+		if getbufvar(buffer, 'VCSCommandOriginalBuffer') == a:originalBuffer
+			if getbufvar(buffer, 'VCSCommandCommand') == a:VCSCommand
+				execute 'bw' buffer
+			endif
+		endif
+		let buffer = buffer + 1
+	endwhile
+endfunction
+
+" Function: s:VimDiffRestore(vimDiffBuff) {{{2
+" Checks whether the given buffer is one whose deletion should trigger
+" restoration of an original buffer after it was diffed.  If so, it executes
+" the appropriate setting command stored with that original buffer.
+
+function! s:VimDiffRestore(vimDiffBuff)
+	let s:isEditFileRunning += 1
+	try
+		if exists('t:vcsCommandVimDiffSourceBuffer')
+			if a:vimDiffBuff == t:vcsCommandVimDiffSourceBuffer
+				" Original file is being removed.
+				unlet! t:vcsCommandVimDiffSourceBuffer
+				unlet! t:vcsCommandVimDiffRestoreCmd
+				unlet! t:vcsCommandVimDiffScratchList
+			else
+				let index = index(t:vcsCommandVimDiffScratchList, a:vimDiffBuff)
+				if index >= 0
+					call remove(t:vcsCommandVimDiffScratchList, index)
+					if len(t:vcsCommandVimDiffScratchList) == 0
+						if exists('t:vcsCommandVimDiffRestoreCmd')
+							" All scratch buffers are gone, reset the original.
+							" Only restore if the source buffer is still in Diff mode
+
+							let sourceWinNR = bufwinnr(t:vcsCommandVimDiffSourceBuffer)
+							if sourceWinNR != -1
+								" The buffer is visible in at least one window
+								let currentWinNR = winnr()
+								while winbufnr(sourceWinNR) != -1
+									if winbufnr(sourceWinNR) == t:vcsCommandVimDiffSourceBuffer
+										execute sourceWinNR . 'wincmd w'
+										if getwinvar(0, '&diff')
+											execute t:vcsCommandVimDiffRestoreCmd
+										endif
+									endif
+									let sourceWinNR = sourceWinNR + 1
+								endwhile
+								execute currentWinNR . 'wincmd w'
+							else
+								" The buffer is hidden.  It must be visible in order to set the
+								" diff option.
+								let currentBufNR = bufnr('')
+								execute 'hide buffer' t:vcsCommandVimDiffSourceBuffer
+								if getwinvar(0, '&diff')
+									execute t:vcsCommandVimDiffRestoreCmd
+								endif
+								execute 'hide buffer' currentBufNR
+							endif
+
+							unlet t:vcsCommandVimDiffRestoreCmd
+						endif
+						" All buffers are gone.
+						unlet t:vcsCommandVimDiffSourceBuffer
+						unlet t:vcsCommandVimDiffScratchList
+					endif
+				endif
+			endif
+		endif
+	finally
+		let s:isEditFileRunning -= 1
+	endtry
+endfunction
+
+" Section: Generic VCS command functions {{{1
+
+" Function: s:VCSAnnotate(...) {{{2
+function! s:VCSAnnotate(bang, ...)
+	call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
+	try
+		let line = line('.')
+		let currentBuffer = bufnr('%')
+		let originalBuffer = VCSCommandGetOriginalBuffer(currentBuffer)
+
+		let annotateBuffer = s:ExecuteVCSCommand('Annotate', a:000)
+		if annotateBuffer == -1
+			return -1
+		endif
+		if a:bang == '!' && VCSCommandGetOption('VCSCommandDisableSplitAnnotate', 0) == 0
+			let vcsType = VCSCommandGetVCSType(annotateBuffer)
+			let functionMap = s:plugins[vcsType][1]
+			let splitRegex = ''
+			if has_key(s:plugins[vcsType][1], 'AnnotateSplitRegex')
+				let splitRegex = s:plugins[vcsType][1]['AnnotateSplitRegex']
+			endif
+			let splitRegex = VCSCommandGetOption('VCSCommand' . vcsType . 'AnnotateSplitRegex', splitRegex)
+			if splitRegex == ''
+				return annotateBuffer
+			endif
+			wincmd J
+			let originalFileType = getbufvar(originalBuffer, '&ft')
+			let annotateFileType = getbufvar(annotateBuffer, '&ft')
+
+			let saveselection = &selection
+			set selection=inclusive
+			try
+				execute "normal! 0zR\<c-v>G/" . splitRegex . "/e\<cr>d"
+			finally
+				let &selection = saveselection
+			endtry
+
+			call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype'))
+			set scrollbind
+			leftabove vert new
+			normal! 0P
+			execute "normal!" . (col('$') + (&number ? &numberwidth : 0)). "\<c-w>|"
+			call s:SetupScratchBuffer('annotate', vcsType, originalBuffer, 'header')
+			wincmd l
+		endif
+
+		if currentBuffer == originalBuffer
+			" Starting from the original source buffer, so the
+			" current line is relevant.
+			if a:0 == 0
+				" No argument list means that we're annotating
+				" the current version, so jumping to the same
+				" line is the expected action.
+				execute "normal!" line . 'G'
+				if has('folding')
+					" The execution of the buffer created autocommand
+					" re-folds the buffer.  Display the current line
+					" unfolded.
+					normal! zv
+				endif
+			endif
+		endif
+
+		return annotateBuffer
+	catch
+		call s:ReportError(v:exception)
+		return -1
+	finally
+		call s:VCSCommandUtility.popContext()
+	endtry
+endfunction
+
+" Function: s:VCSCommit() {{{2
+function! s:VCSCommit(bang, message)
+	try
+		let vcsType = VCSCommandGetVCSType(bufnr('%'))
+		if !has_key(s:plugins, vcsType)
+			throw 'Unknown VCS type:  ' . vcsType
+		endif
+
+		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.
+
+		if strlen(a:message) > 0 || a:bang == '!'
+			return s:VCSFinishCommit([a:message], originalBuffer)
+		endif
+
+		call s:EditFile('commitlog', originalBuffer, '')
+		setlocal ft=vcscommit
+
+		" Create a commit mapping.
+
+		nnoremap <silent> <buffer> <Plug>VCSCommit :call <SID>VCSFinishCommitWithBuffer()<CR>
+
+		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 <leader>cc (or your own <Plug>VCSCommit mapping)'
+
+		if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1
+			setlocal buftype=acwrite
+			au VCSCommandCommit BufWriteCmd <buffer> call s:VCSFinishCommitWithBuffer()
+			silent put ='VCS: or write this buffer'
+		endif
+
+		silent put ='VCS: ----------------------------------------------------------------------'
+		$
+		setlocal nomodified
+		silent do VCSCommand User VCSBufferCreated
+	catch
+		call s:ReportError(v:exception)
+		return -1
+	endtry
+endfunction
+
+" Function: s:VCSFinishCommitWithBuffer() {{{2
+" Wrapper for s:VCSFinishCommit which is called only from a commit log buffer
+" which removes all lines starting with 'VCS:'.
+
+function! s:VCSFinishCommitWithBuffer()
+	setlocal nomodified
+	let currentBuffer = bufnr('%')
+	let logMessageList = getbufline('%', 1, '$')
+	call filter(logMessageList, 'v:val !~ ''^\s*VCS:''')
+	let resultBuffer = s:VCSFinishCommit(logMessageList, b:VCSCommandOriginalBuffer)
+	if resultBuffer >= 0
+		execute 'bw' currentBuffer
+	endif
+	return resultBuffer
+endfunction
+
+" Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2
+function! s:VCSFinishCommit(logMessageList, originalBuffer)
+	let messageFileName = tempname()
+	if exists('*iconv') && has('multi_byte')
+		if(strlen(&tenc) && &tenc != &enc)
+			call map(a:logMessageList, 'iconv(v:val, &enc, &tenc)')
+		endif
+	endif
+	call writefile(a:logMessageList, messageFileName)
+	try
+		let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName])
+		if resultBuffer < 0
+			return resultBuffer
+		endif
+		return s:MarkOrigBufferForSetup(resultBuffer)
+	finally
+		call delete(messageFileName)
+	endtry
+endfunction
+
+" Function: s:VCSGotoOriginal(bang) {{{2
+function! s:VCSGotoOriginal(bang)
+	let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
+	if originalBuffer > 0
+		let origWinNR = bufwinnr(originalBuffer)
+		if origWinNR == -1
+			execute 'buffer' originalBuffer
+		else
+			execute origWinNR . 'wincmd w'
+		endif
+		if a:bang == '!'
+			let buffnr = 1
+			let buffmaxnr = bufnr('$')
+			while buffnr <= buffmaxnr
+				if getbufvar(buffnr, 'VCSCommandOriginalBuffer') == originalBuffer
+					execute 'bw' buffnr
+				endif
+				let buffnr = buffnr + 1
+			endwhile
+		endif
+	endif
+endfunction
+
+function! s:VCSDiff(...)  "{{{2
+	call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
+	try
+		let resultBuffer = s:ExecuteVCSCommand('Diff', a:000)
+		if resultBuffer > 0
+			let &filetype = 'diff'
+		elseif resultBuffer == 0
+			echomsg 'No differences found'
+		endif
+		return resultBuffer
+	finally
+		call s:VCSCommandUtility.popContext()
+	endtry
+endfunction
+
+function! s:VCSReview(...)  "{{{2
+	call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')})
+	try
+		let resultBuffer = s:ExecuteVCSCommand('Review', a:000)
+		if resultBuffer > 0
+			let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
+		endif
+		return resultBuffer
+	finally
+		call s:VCSCommandUtility.popContext()
+	endtry
+endfunction
+
+" Function: s:VCSVimDiff(...) {{{2
+function! s:VCSVimDiff(...)
+	try
+		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