contrib/vim/hgcommand.vim
author "Mathieu Clabaut <mathieu.clabaut@gmail.com>"
Mon, 10 Jul 2006 23:39:08 +0200
changeset 2591 61f2008cd6bf
child 2592 457846f400e8
permissions -rw-r--r--
Addition of CVScommand vim script as a base for HGcommand
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2591
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     1
" vim600: set foldmethod=marker:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     2
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     3
" Vim plugin to assist in working with CVS-controlled files.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     4
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     5
" Last Change:   2006/02/22
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     6
" Version:       1.76
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     7
" Maintainer:    Bob Hiestand <bob.hiestand@gmail.com>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     8
" License:       This file is placed in the public domain.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
     9
" Credits: {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    10
"                Mathieu Clabaut for many suggestions and improvements.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    11
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    12
"                Suresh Govindachar and Jeeva Chelladhurai for finding waaaay
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    13
"                too many bugs.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    14
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    15
"                Suresh Govindachar (again!) for finding the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    16
"                fully-folded-last-line-delete bug.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    17
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    18
"                Albrecht Gass for the Delete-on-Hide behavior suggestion.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    19
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    20
"                Joe MacDonald for finding the CVS log message header bug and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    21
"                pointing out that buffer refreshes are needed after CVS
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    22
"                \%(un\)\?edit.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    23
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    24
"                Srinath Avadhanula for the suggestion and original patch for
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    25
"                the CVSCommitOnWrite option and mapping hot key.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    26
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    27
"                John Sivak for helping to debug Windows issues and suggesting
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    28
"                the CVSEditors and CVSWatchers commands.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    29
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    30
"                Igor Levko for the patch to recognize numerical sticky tags.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    31
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    32
"                Domink Strasser for the patch to correct the status line for
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    33
"                CVSAdd'd files.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    34
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    35
"                Weerapong Sirikanya for finding a bug with CVSCommit and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    36
"                autochdir.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    37
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    38
"                David Gotz for finding a bug with CVSVimDiff buffer splitting
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    39
"                and original buffer restoration.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    40
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    41
"                CJ van den Berg for the patch to not change working directory
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    42
"                when editing a non-CVS file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    43
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    44
"                Luca Gerli for noticing bad behavior for keywords in files
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    45
"                after commit if split windows are used.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    46
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    47
" Section: Documentation {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    48
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    49
" Provides functions to invoke various CVS commands on the current file
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    50
" (either the current buffer, or, in the case of an directory buffer, the file
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    51
" on the current line).  The output of the commands is captured in a new
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    52
" scratch window.  For convenience, if the functions are invoked on a CVS
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    53
" output window, the original file is used for the cvs operation instead after
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    54
" the window is split.  This is primarily useful when running CVSCommit and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    55
" you need to see the changes made, so that CVSDiff is usable and shows up in
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    56
" another window.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    57
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    58
" Command documentation {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    59
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    60
" CVSAdd           Performs "cvs add" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    61
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    62
" CVSAnnotate      Performs "cvs annotate" on the current file.  If an
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    63
"                  argument is given, the argument is used as a revision
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    64
"                  number to display.  If not given an argument, it uses the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    65
"                  most recent version of the file on the current branch.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    66
"                  Additionally, if the current buffer is a CVSAnnotate buffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    67
"                  already, the version number on the current line is used.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    68
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    69
"                  If the 'CVSCommandAnnotateParent' variable is set to a
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    70
"                  non-zero value, the version previous to the one on the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    71
"                  current line is used instead.  This allows one to navigate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    72
"                  back to examine the previous version of a line.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    73
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    74
" CVSCommit[!]     If called with arguments, this performs "cvs commit" using
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    75
"                  the arguments as the log message.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    76
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    77
"                  If '!' is used, an empty log message is committed.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    78
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    79
"                  If called with no arguments, this is a two-step command.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    80
"                  The first step opens a buffer to accept a log message.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    81
"                  When that buffer is written, it is automatically closed and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    82
"                  the file is committed using the information from that log
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    83
"                  message.  The commit can be abandoned if the log message
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    84
"                  buffer is deleted or wiped before being written.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    85
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    86
" CVSDiff          With no arguments, this performs "cvs diff" on the current
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    87
"                  file.  With one argument, "cvs diff" is performed on the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    88
"                  current file against the specified revision.  With two
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    89
"                  arguments, cvs diff is performed between the specified
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    90
"                  revisions of the current file.  This command uses the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    91
"                  'CVSCommandDiffOpt' variable to specify diff options.  If
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    92
"                  that variable does not exist, then 'wbBc' is assumed.  If
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    93
"                  you wish to have no options, then set it to the empty
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    94
"                  string.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    95
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    96
" CVSEdit          Performs "cvs edit" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    97
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    98
" CVSEditors       Performs "cvs editors" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
    99
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   100
" CVSGotoOriginal  Returns the current window to the source buffer if the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   101
"                  current buffer is a CVS output buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   102
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   103
" CVSLog           Performs "cvs log" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   104
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   105
" CVSRevert        Replaces the modified version of the current file with the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   106
"                  most recent version from the repository.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   107
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   108
" CVSReview        Retrieves a particular version of the current file.  If no
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   109
"                  argument is given, the most recent version of the file on
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   110
"                  the current branch is retrieved.  The specified revision is
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   111
"                  retrieved into a new buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   112
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   113
" CVSStatus        Performs "cvs status" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   114
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   115
" CVSUnedit        Performs "cvs unedit" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   116
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   117
" CVSUpdate        Performs "cvs update" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   118
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   119
" CVSVimDiff       With no arguments, this prompts the user for a revision and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   120
"                  then uses vimdiff to display the differences between the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   121
"                  current file and the specified revision.  If no revision is
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   122
"                  specified, the most recent version of the file on the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   123
"                  current branch is used.  With one argument, that argument
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   124
"                  is used as the revision as above.  With two arguments, the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   125
"                  differences between the two revisions is displayed using
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   126
"                  vimdiff.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   127
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   128
"                  With either zero or one argument, the original buffer is used
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   129
"                  to perform the vimdiff.  When the other buffer is closed, the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   130
"                  original buffer will be returned to normal mode.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   131
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   132
"                  Once vimdiff mode is started using the above methods,
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   133
"                  additional vimdiff buffers may be added by passing a single
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   134
"                  version argument to the command.  There may be up to 4
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   135
"                  vimdiff buffers total.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   136
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   137
"                  Using the 2-argument form of the command resets the vimdiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   138
"                  to only those 2 versions.  Additionally, invoking the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   139
"                  command on a different file will close the previous vimdiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   140
"                  buffers.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   141
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   142
" CVSWatch         Takes an argument which must be one of [on|off|add|remove].
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   143
"                  Performs "cvs watch" with the given argument on the current
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   144
"                  file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   145
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   146
" CVSWatchers      Performs "cvs watchers" on the current file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   147
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   148
" CVSWatchAdd      Alias for "CVSWatch add"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   149
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   150
" CVSWatchOn       Alias for "CVSWatch on"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   151
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   152
" CVSWatchOff      Alias for "CVSWatch off"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   153
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   154
" CVSWatchRemove   Alias for "CVSWatch remove"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   155
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   156
" Mapping documentation: {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   157
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   158
" By default, a mapping is defined for each command.  User-provided mappings
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   159
" can be used instead by mapping to <Plug>CommandName, for instance:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   160
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   161
" nnoremap ,ca <Plug>CVSAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   162
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   163
" The default mappings are as follow:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   164
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   165
"   <Leader>ca CVSAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   166
"   <Leader>cn CVSAnnotate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   167
"   <Leader>cc CVSCommit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   168
"   <Leader>cd CVSDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   169
"   <Leader>ce CVSEdit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   170
"   <Leader>ci CVSEditors
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   171
"   <Leader>cg CVSGotoOriginal
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   172
"   <Leader>cG CVSGotoOriginal!
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   173
"   <Leader>cl CVSLog
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   174
"   <Leader>cr CVSReview
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   175
"   <Leader>cs CVSStatus
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   176
"   <Leader>ct CVSUnedit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   177
"   <Leader>cu CVSUpdate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   178
"   <Leader>cv CVSVimDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   179
"   <Leader>cwv CVSWatchers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   180
"   <Leader>cwa CVSWatchAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   181
"   <Leader>cwn CVSWatchOn
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   182
"   <Leader>cwa CVSWatchOff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   183
"   <Leader>cwr CVSWatchRemove
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   184
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   185
" Options documentation: {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   186
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   187
" Several variables are checked by the script to determine behavior as follow:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   188
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   189
" CVSCommandAnnotateParent
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   190
"   This variable, if set to a non-zero value, causes the zero-argument form
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   191
"   of CVSAnnotate when invoked on a CVSAnnotate buffer to go to the version
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   192
"   previous to that displayed on the current line.  If not set, it defaults
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   193
"   to 0.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   194
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   195
" CVSCommandCommitOnWrite
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   196
"   This variable, if set to a non-zero value, causes the pending cvs commit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   197
"   to take place immediately as soon as the log message buffer is written.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   198
"   If set to zero, only the CVSCommit mapping will cause the pending commit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   199
"   to occur.  If not set, it defaults to 1.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   200
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   201
" CVSCommandDeleteOnHide
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   202
"   This variable, if set to a non-zero value, causes the temporary CVS result
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   203
"   buffers to automatically delete themselves when hidden.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   204
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   205
" CVSCommandDiffOpt
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   206
"   This variable, if set, determines the options passed to the diff command
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   207
"   of CVS.  If not set, it defaults to 'wbBc'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   208
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   209
" CVSCommandDiffSplit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   210
"   This variable overrides the CVSCommandSplit variable, but only for buffers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   211
"   created with CVSVimDiff.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   212
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   213
" CVSCommandEdit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   214
"   This variable controls whether the original buffer is replaced ('edit') or
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   215
"   split ('split').  If not set, it defaults to 'edit'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   216
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   217
" CVSCommandEnableBufferSetup
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   218
"   This variable, if set to a non-zero value, activates CVS buffer management
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   219
"   mode.  This mode means that two buffer variables, 'CVSRevision' and
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   220
"   'CVSBranch', are set if the file is CVS-controlled.  This is useful for
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   221
"   displaying version information in the status bar.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   222
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   223
" CVSCommandInteractive
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   224
"   This variable, if set to a non-zero value, causes appropriate functions (for
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   225
"   the moment, only CVSReview) to query the user for a revision to use
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   226
"   instead of the current revision if none is specified.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   227
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   228
" CVSCommandNameMarker
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   229
"   This variable, if set, configures the special attention-getting characters
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   230
"   that appear on either side of the cvs buffer type in the buffer name.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   231
"   This has no effect unless 'CVSCommandNameResultBuffers' is set to a true
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   232
"   value.  If not set, it defaults to '_'.  
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   233
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   234
" CVSCommandNameResultBuffers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   235
"   This variable, if set to a true value, causes the cvs result buffers to be
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   236
"   named in the old way ('<source file name> _<cvs command>_').  If not set
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   237
"   or set to a false value, the result buffer is nameless.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   238
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   239
" CVSCommandSplit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   240
"   This variable controls the orientation of the various window splits that
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   241
"   may occur (such as with CVSVimDiff, when using a CVS command on a CVS
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   242
"   command buffer, or when the 'CVSCommandEdit' variable is set to 'split'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   243
"   If set to 'horizontal', the resulting windows will be on stacked on top of
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   244
"   one another.  If set to 'vertical', the resulting windows will be
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   245
"   side-by-side.  If not set, it defaults to 'horizontal' for all but
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   246
"   CVSVimDiff windows.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   247
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   248
" Event documentation {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   249
"   For additional customization, cvscommand.vim uses User event autocommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   250
"   hooks.  Each event is in the CVSCommand group, and different patterns
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   251
"   match the various hooks.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   252
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   253
"   For instance, the following could be added to the vimrc to provide a 'q'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   254
"   mapping to quit a CVS buffer:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   255
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   256
"   augroup CVSCommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   257
"     au CVSCommand User CVSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr> 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   258
"   augroup END
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   259
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   260
"   The following hooks are available:
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   261
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   262
"   CVSBufferCreated           This event is fired just after a cvs command
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   263
"                              result buffer is created and filled with the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   264
"                              result of a cvs command.  It is executed within
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   265
"                              the context of the new buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   266
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   267
"   CVSBufferSetup             This event is fired just after CVS buffer setup
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   268
"                              occurs, if enabled.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   269
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   270
"   CVSPluginInit              This event is fired when the CVSCommand plugin
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   271
"                              first loads.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   272
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   273
"   CVSPluginFinish            This event is fired just after the CVSCommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   274
"                              plugin loads.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   275
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   276
"   CVSVimDiffFinish           This event is fired just after the CVSVimDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   277
"                              command executes to allow customization of,
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   278
"                              for instance, window placement and focus.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   279
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   280
" Section: Plugin header {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   281
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   282
" loaded_cvscommand is set to 1 when the initialization begins, and 2 when it
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   283
" completes.  This allows various actions to only be taken by functions after
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   284
" system initialization.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   285
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   286
if exists("loaded_cvscommand")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   287
   finish
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   288
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   289
let loaded_cvscommand = 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   290
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   291
if v:version < 602
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   292
  echohl WarningMsg|echomsg "CVSCommand 1.69 or later requires VIM 6.2 or later"|echohl None
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   293
  finish
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   294
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   295
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   296
" Section: Event group setup {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   297
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   298
augroup CVSCommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   299
augroup END
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   300
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   301
" Section: Plugin initialization {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   302
silent do CVSCommand User CVSPluginInit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   303
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   304
" Section: Script variable initialization {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   305
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   306
let s:CVSCommandEditFileRunning = 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   307
unlet! s:vimDiffRestoreCmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   308
unlet! s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   309
unlet! s:vimDiffBufferCount
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   310
unlet! s:vimDiffScratchList
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   311
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   312
" Section: Utility functions {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   313
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   314
" Function: s:CVSResolveLink() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   315
" Fully resolve the given file name to remove shortcuts or symbolic links.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   316
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   317
function! s:CVSResolveLink(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   318
  let resolved = resolve(a:fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   319
  if resolved != a:fileName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   320
    let resolved = s:CVSResolveLink(resolved)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   321
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   322
  return resolved
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   323
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   324
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   325
" Function: s:CVSChangeToCurrentFileDir() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   326
" Go to the directory in which the current CVS-controlled file is located.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   327
" If this is a CVS command buffer, first switch to the original file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   328
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   329
function! s:CVSChangeToCurrentFileDir(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   330
  let oldCwd=getcwd()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   331
  let fileName=s:CVSResolveLink(a:fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   332
  let newCwd=fnamemodify(fileName, ':h')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   333
  if strlen(newCwd) > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   334
    execute 'cd' escape(newCwd, ' ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   335
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   336
  return oldCwd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   337
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   338
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   339
" Function: s:CVSGetOption(name, default) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   340
" Grab a user-specified option to override the default provided.  Options are
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   341
" searched in the window, buffer, then global spaces.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   342
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   343
function! s:CVSGetOption(name, default)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   344
  if exists("s:" . a:name . "Override")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   345
    execute "return s:".a:name."Override"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   346
  elseif exists("w:" . a:name)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   347
    execute "return w:".a:name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   348
  elseif exists("b:" . a:name)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   349
    execute "return b:".a:name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   350
  elseif exists("g:" . a:name)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   351
    execute "return g:".a:name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   352
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   353
    return a:default
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   354
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   355
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   356
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   357
" Function: s:CVSEditFile(name, origBuffNR) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   358
" Wrapper around the 'edit' command to provide some helpful error text if the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   359
" current buffer can't be abandoned.  If name is provided, it is used;
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   360
" otherwise, a nameless scratch buffer is used.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   361
" Returns: 0 if successful, -1 if an error occurs.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   362
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   363
function! s:CVSEditFile(name, origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   364
  "Name parameter will be pasted into expression.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   365
  let name = escape(a:name, ' *?\')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   366
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   367
  let editCommand = s:CVSGetOption('CVSCommandEdit', 'edit')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   368
  if editCommand != 'edit'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   369
    if s:CVSGetOption('CVSCommandSplit', 'horizontal') == 'horizontal'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   370
      if name == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   371
        let editCommand = 'rightbelow new'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   372
      else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   373
        let editCommand = 'rightbelow split ' . name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   374
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   375
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   376
      if name == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   377
        let editCommand = 'vert rightbelow new'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   378
      else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   379
        let editCommand = 'vert rightbelow split ' . name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   380
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   381
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   382
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   383
    if name == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   384
      let editCommand = 'enew'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   385
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   386
      let editCommand = 'edit ' . name
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   387
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   388
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   389
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   390
  " Protect against useless buffer set-up
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   391
  let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   392
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   393
    execute editCommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   394
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   395
    let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning - 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   396
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   397
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   398
  let b:CVSOrigBuffNR=a:origBuffNR
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   399
  let b:CVSCommandEdit='split'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   400
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   401
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   402
" Function: s:CVSCreateCommandBuffer(cmd, cmdName, statusText, filename) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   403
" Creates a new scratch buffer and captures the output from execution of the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   404
" given command.  The name of the scratch buffer is returned.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   405
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   406
function! s:CVSCreateCommandBuffer(cmd, cmdName, statusText, origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   407
  let fileName=bufname(a:origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   408
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   409
  let resultBufferName=''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   410
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   411
  if s:CVSGetOption("CVSCommandNameResultBuffers", 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   412
    let nameMarker = s:CVSGetOption("CVSCommandNameMarker", '_')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   413
    if strlen(a:statusText) > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   414
      let bufName=a:cmdName . ' -- ' . a:statusText
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   415
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   416
      let bufName=a:cmdName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   417
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   418
    let bufName=fileName . ' ' . nameMarker . bufName . nameMarker
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   419
    let counter=0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   420
    let resultBufferName = bufName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   421
    while buflisted(resultBufferName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   422
      let counter=counter + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   423
      let resultBufferName=bufName . ' (' . counter . ')'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   424
    endwhile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   425
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   426
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   427
  let cvsCommand = s:CVSGetOption("CVSCommandCVSExec", "cvs") . " " . a:cmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   428
  let cvsOut = system(cvsCommand)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   429
  " HACK:  diff command does not return proper error codes
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   430
  if v:shell_error && a:cmdName != 'cvsdiff'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   431
    if strlen(cvsOut) == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   432
      echoerr "CVS command failed"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   433
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   434
      echoerr "CVS command failed:  " . cvsOut
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   435
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   436
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   437
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   438
  if strlen(cvsOut) == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   439
    " Handle case of no output.  In this case, it is important to check the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   440
    " file status, especially since cvs edit/unedit may change the attributes
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   441
    " of the file with no visible output.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   442
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   443
    echomsg "No output from CVS command"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   444
    checktime
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   445
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   446
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   447
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   448
  if s:CVSEditFile(resultBufferName, a:origBuffNR) == -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   449
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   450
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   451
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   452
  set buftype=nofile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   453
  set noswapfile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   454
  set filetype=
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   455
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   456
  if s:CVSGetOption("CVSCommandDeleteOnHide", 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   457
    set bufhidden=delete
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   458
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   459
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   460
  silent 0put=cvsOut
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   461
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   462
  " The last command left a blank line at the end of the buffer.  If the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   463
  " last line is folded (a side effect of the 'put') then the attempt to
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   464
  " remove the blank line will kill the last fold.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   465
  "
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   466
  " This could be fixed by explicitly detecting whether the last line is
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   467
  " within a fold, but I prefer to simply unfold the result buffer altogether.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   468
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   469
  if has('folding')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   470
    normal zR
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   471
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   472
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   473
  $d
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   474
  1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   475
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   476
  " Define the environment and execute user-defined hooks.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   477
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   478
  let b:CVSSourceFile=fileName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   479
  let b:CVSCommand=a:cmdName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   480
  if a:statusText != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   481
    let b:CVSStatusText=a:statusText
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   482
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   483
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   484
  silent do CVSCommand User CVSBufferCreated
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   485
  return bufnr("%")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   486
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   487
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   488
" Function: s:CVSBufferCheck(cvsBuffer) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   489
" Attempts to locate the original file to which CVS operations were applied
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   490
" for a given buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   491
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   492
function! s:CVSBufferCheck(cvsBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   493
  let origBuffer = getbufvar(a:cvsBuffer, "CVSOrigBuffNR")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   494
  if origBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   495
    if bufexists(origBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   496
      return origBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   497
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   498
      " Original buffer no longer exists.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   499
      return -1 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   500
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   501
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   502
    " No original buffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   503
    return a:cvsBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   504
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   505
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   506
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   507
" Function: s:CVSCurrentBufferCheck() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   508
" Attempts to locate the original file to which CVS operations were applied
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   509
" for the current buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   510
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   511
function! s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   512
  return s:CVSBufferCheck(bufnr("%"))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   513
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   514
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   515
" Function: s:CVSToggleDeleteOnHide() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   516
" Toggles on and off the delete-on-hide behavior of CVS buffers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   517
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   518
function! s:CVSToggleDeleteOnHide()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   519
  if exists("g:CVSCommandDeleteOnHide")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   520
    unlet g:CVSCommandDeleteOnHide
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   521
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   522
    let g:CVSCommandDeleteOnHide=1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   523
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   524
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   525
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   526
" Function: s:CVSDoCommand(cvscmd, cmdName, statusText) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   527
" General skeleton for CVS function execution.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   528
" Returns: name of the new command buffer containing the command results
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   529
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   530
function! s:CVSDoCommand(cmd, cmdName, statusText)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   531
  let cvsBufferCheck=s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   532
  if cvsBufferCheck == -1 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   533
    echo "Original buffer no longer exists, aborting."
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   534
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   535
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   536
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   537
  let fileName=bufname(cvsBufferCheck)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   538
  if isdirectory(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   539
    let fileName=fileName . "/" . getline(".")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   540
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   541
  let realFileName = fnamemodify(s:CVSResolveLink(fileName), ':t')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   542
  let oldCwd=s:CVSChangeToCurrentFileDir(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   543
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   544
    if !filereadable('CVS/Root')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   545
      throw fileName . ' is not a CVS-controlled file.'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   546
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   547
    let fullCmd = a:cmd . ' "' . realFileName . '"'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   548
    let resultBuffer=s:CVSCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, cvsBufferCheck)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   549
    return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   550
  catch
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   551
    echoerr v:exception
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   552
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   553
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   554
    execute 'cd' escape(oldCwd, ' ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   555
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   556
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   557
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   558
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   559
" Function: s:CVSGetStatusVars(revision, branch, repository) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   560
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   561
" Obtains a CVS revision number and branch name.  The 'revisionVar',
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   562
" 'branchVar'and 'repositoryVar' arguments, if non-empty, contain the names of variables to hold
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   563
" the corresponding results.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   564
"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   565
" Returns: string to be exec'd that sets the multiple return values.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   566
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   567
function! s:CVSGetStatusVars(revisionVar, branchVar, repositoryVar)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   568
  let cvsBufferCheck=s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   569
  if cvsBufferCheck == -1 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   570
    return ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   571
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   572
  let fileName=bufname(cvsBufferCheck)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   573
  let realFileName = fnamemodify(s:CVSResolveLink(fileName), ':t')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   574
  let oldCwd=s:CVSChangeToCurrentFileDir(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   575
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   576
    if !filereadable('CVS/Root')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   577
      return ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   578
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   579
    let cvsCommand = s:CVSGetOption("CVSCommandCVSExec", "cvs") . " status " . escape(realFileName, ' *?\')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   580
    let statustext=system(cvsCommand)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   581
    if(v:shell_error)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   582
      return ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   583
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   584
    let revision=substitute(statustext, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', "")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   585
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   586
    " We can still be in a CVS-controlled directory without this being a CVS
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   587
    " file
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   588
    if match(revision, '^New file!$') >= 0 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   589
      let revision="NEW"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   590
    elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') >=0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   591
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   592
      return ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   593
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   594
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   595
    let returnExpression = "let " . a:revisionVar . "='" . revision . "'"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   596
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   597
    if a:branchVar != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   598
      let branch=substitute(statustext, '^\_.*Sticky Tag:\s\+\(\d\+\%(\.\d\+\)\+\|\a[A-Za-z0-9-_]*\|(none)\).*$', '\1', "")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   599
      let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   600
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   601
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   602
    if a:repositoryVar != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   603
      let repository=substitute(statustext, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', "")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   604
      let repository=substitute(repository, '^New file!\|No revision control file$', 'NEW', "")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   605
      let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   606
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   607
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   608
    return returnExpression
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   609
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   610
    execute 'cd' escape(oldCwd, ' ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   611
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   612
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   613
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   614
" Function: s:CVSSetupBuffer() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   615
" Attempts to set the b:CVSBranch, b:CVSRevision and b:CVSRepository variables.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   616
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   617
function! s:CVSSetupBuffer()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   618
  if (exists("b:CVSBufferSetup") && b:CVSBufferSetup)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   619
    " This buffer is already set up.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   620
    return
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   621
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   622
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   623
  if !s:CVSGetOption("CVSCommandEnableBufferSetup", 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   624
        \ || @% == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   625
        \ || s:CVSCommandEditFileRunning > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   626
        \ || exists("b:CVSOrigBuffNR")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   627
    unlet! b:CVSRevision
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   628
    unlet! b:CVSBranch
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   629
    unlet! b:CVSRepository
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   630
    return
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   631
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   632
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   633
  if !filereadable(expand("%"))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   634
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   635
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   636
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   637
  let revision=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   638
  let branch=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   639
  let repository=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   640
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   641
  exec s:CVSGetStatusVars('revision', 'branch', 'repository')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   642
  if revision != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   643
    let b:CVSRevision=revision
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   644
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   645
    unlet! b:CVSRevision
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   646
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   647
  if branch != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   648
    let b:CVSBranch=branch
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   649
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   650
    unlet! b:CVSBranch
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   651
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   652
  if repository != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   653
     let b:CVSRepository=repository
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   654
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   655
     unlet! b:CVSRepository
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   656
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   657
  silent do CVSCommand User CVSBufferSetup
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   658
  let b:CVSBufferSetup=1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   659
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   660
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   661
" Function: s:CVSMarkOrigBufferForSetup(cvsbuffer) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   662
" Resets the buffer setup state of the original buffer for a given CVS buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   663
" Returns:  The CVS buffer number in a passthrough mode.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   664
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   665
function! s:CVSMarkOrigBufferForSetup(cvsBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   666
  checktime
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   667
  if a:cvsBuffer != -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   668
    let origBuffer = s:CVSBufferCheck(a:cvsBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   669
    "This should never not work, but I'm paranoid
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   670
    if origBuffer != a:cvsBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   671
      call setbufvar(origBuffer, "CVSBufferSetup", 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   672
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   673
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   674
  return a:cvsBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   675
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   676
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   677
" Function: s:CVSOverrideOption(option, [value]) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   678
" Provides a temporary override for the given CVS option.  If no value is
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   679
" passed, the override is disabled.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   680
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   681
function! s:CVSOverrideOption(option, ...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   682
  if a:0 == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   683
    unlet! s:{a:option}Override
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   684
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   685
    let s:{a:option}Override = a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   686
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   687
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   688
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   689
" Function: s:CVSWipeoutCommandBuffers() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   690
" Clears all current CVS buffers of the specified type for a given source.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   691
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   692
function! s:CVSWipeoutCommandBuffers(originalBuffer, cvsCommand)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   693
  let buffer = 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   694
  while buffer <= bufnr('$')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   695
    if getbufvar(buffer, 'CVSOrigBuffNR') == a:originalBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   696
      if getbufvar(buffer, 'CVSCommand') == a:cvsCommand
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   697
        execute 'bw' buffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   698
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   699
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   700
    let buffer = buffer + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   701
  endwhile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   702
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   703
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   704
" Section: Public functions {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   705
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   706
" Function: CVSGetRevision() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   707
" Global function for retrieving the current buffer's CVS revision number.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   708
" Returns: Revision number or an empty string if an error occurs.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   709
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   710
function! CVSGetRevision()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   711
  let revision=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   712
  exec s:CVSGetStatusVars('revision', '', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   713
  return revision
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   714
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   715
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   716
" Function: CVSDisableBufferSetup() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   717
" Global function for deactivating the buffer autovariables.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   718
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   719
function! CVSDisableBufferSetup()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   720
  let g:CVSCommandEnableBufferSetup=0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   721
  silent! augroup! CVSCommandPlugin
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   722
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   723
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   724
" Function: CVSEnableBufferSetup() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   725
" Global function for activating the buffer autovariables.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   726
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   727
function! CVSEnableBufferSetup()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   728
  let g:CVSCommandEnableBufferSetup=1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   729
  augroup CVSCommandPlugin
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   730
    au!
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   731
    au BufEnter * call s:CVSSetupBuffer()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   732
  augroup END
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   733
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   734
  " Only auto-load if the plugin is fully loaded.  This gives other plugins a
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   735
  " chance to run.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   736
  if g:loaded_cvscommand == 2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   737
    call s:CVSSetupBuffer()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   738
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   739
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   740
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   741
" Function: CVSGetStatusLine() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   742
" Default (sample) status line entry for CVS files.  This is only useful if
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   743
" CVS-managed buffer mode is on (see the CVSCommandEnableBufferSetup variable
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   744
" for how to do this).
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   745
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   746
function! CVSGetStatusLine()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   747
  if exists('b:CVSSourceFile')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   748
    " This is a result buffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   749
    let value='[' . b:CVSCommand . ' ' . b:CVSSourceFile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   750
    if exists('b:CVSStatusText')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   751
      let value=value . ' ' . b:CVSStatusText
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   752
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   753
    let value = value . ']'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   754
    return value
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   755
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   756
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   757
  if exists('b:CVSRevision')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   758
        \ && b:CVSRevision != ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   759
        \ && exists('b:CVSBranch')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   760
        \ && b:CVSBranch != ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   761
        \ && exists('b:CVSRepository')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   762
        \ && b:CVSRepository != ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   763
        \ && exists('g:CVSCommandEnableBufferSetup')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   764
        \ && g:CVSCommandEnableBufferSetup
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   765
    if b:CVSRevision == b:CVSRepository
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   766
      return '[CVS ' . b:CVSBranch . '/' . b:CVSRevision . ']'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   767
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   768
      return '[CVS ' . b:CVSBranch . '/' . b:CVSRevision . '/' . b:CVSRepository . ']'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   769
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   770
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   771
    return ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   772
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   773
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   774
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   775
" Section: CVS command functions {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   776
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   777
" Function: s:CVSAdd() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   778
function! s:CVSAdd()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   779
  return s:CVSMarkOrigBufferForSetup(s:CVSDoCommand('add', 'cvsadd', ''))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   780
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   781
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   782
" Function: s:CVSAnnotate(...) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   783
function! s:CVSAnnotate(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   784
  if a:0 == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   785
    if &filetype == "CVSAnnotate"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   786
      " This is a CVSAnnotate buffer.  Perform annotation of the version
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   787
      " indicated by the current line.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   788
      let revision = substitute(getline("."),'\(^[0-9.]*\).*','\1','')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   789
      let revmin = substitute(revision,'^[0-9.]*\.\([0-9]\+\)','\1','')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   790
      let revmaj = substitute(revision,'^\([0-9.]*\)\.[0-9]\+','\1','')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   791
      if s:CVSGetOption('CVSCommandAnnotateParent', 0) != 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   792
        let revmin = revmin - 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   793
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   794
      if revmin == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   795
        " Jump to ancestor branch
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   796
        let revision = substitute(revmaj,'^\([0-9.]*\)\.[0-9]\+','\1','')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   797
      else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   798
        let revision=revmaj . "." .  revmin
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   799
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   800
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   801
      let revision=CVSGetRevision()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   802
      if revision == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   803
        echoerr "Unable to obtain CVS version information."
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   804
        return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   805
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   806
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   807
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   808
    let revision=a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   809
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   810
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   811
  if revision == "NEW"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   812
    echo "No annotatation available for new file."
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   813
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   814
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   815
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   816
  let resultBuffer=s:CVSDoCommand('-q annotate -r ' . revision, 'cvsannotate', revision) 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   817
  if resultBuffer !=  -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   818
    set filetype=CVSAnnotate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   819
    " Remove header lines from standard error
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   820
    silent v/^\d\+\%(\.\d\+\)\+/d
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   821
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   822
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   823
  return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   824
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   825
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   826
" Function: s:CVSCommit() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   827
function! s:CVSCommit(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   828
  " Handle the commit message being specified.  If a message is supplied, it
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   829
  " is used; if bang is supplied, an empty message is used; otherwise, the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   830
  " user is provided a buffer from which to edit the commit message.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   831
  if a:2 != "" || a:1 == "!"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   832
    return s:CVSMarkOrigBufferForSetup(s:CVSDoCommand('commit -m "' . a:2 . '"', 'cvscommit', ''))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   833
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   834
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   835
  let cvsBufferCheck=s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   836
  if cvsBufferCheck ==  -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   837
    echo "Original buffer no longer exists, aborting."
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   838
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   839
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   840
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   841
  " Protect against windows' backslashes in paths.  They confuse exec'd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   842
  " commands.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   843
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   844
  let shellSlashBak = &shellslash
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   845
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   846
    set shellslash
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   847
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   848
    let messageFileName = tempname()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   849
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   850
    let fileName=bufname(cvsBufferCheck)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   851
    let realFilePath=s:CVSResolveLink(fileName)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   852
    let newCwd=fnamemodify(realFilePath, ':h')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   853
    if strlen(newCwd) == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   854
      " Account for autochdir being in effect, which will make this blank, but
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   855
      " we know we'll be in the current directory for the original file.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   856
      let newCwd = getcwd()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   857
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   858
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   859
    let realFileName=fnamemodify(realFilePath, ':t')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   860
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   861
    if s:CVSEditFile(messageFileName, cvsBufferCheck) == -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   862
      return
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   863
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   864
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   865
    " Protect against case and backslash issues in Windows.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   866
    let autoPattern = '\c' . messageFileName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   867
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   868
    " Ensure existance of group
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   869
    augroup CVSCommit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   870
    augroup END
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   871
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   872
    execute 'au CVSCommit BufDelete' autoPattern 'call delete("' . messageFileName . '")'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   873
    execute 'au CVSCommit BufDelete' autoPattern 'au! CVSCommit * ' autoPattern
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   874
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   875
    " Create a commit mapping.  The mapping must clear all autocommands in case
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   876
    " it is invoked when CVSCommandCommitOnWrite is active, as well as to not
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   877
    " invoke the buffer deletion autocommand.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   878
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   879
    execute 'nnoremap <silent> <buffer> <Plug>CVSCommit '.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   880
          \ ':au! CVSCommit * ' . autoPattern . '<CR>'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   881
          \ ':g/^CVS:/d<CR>'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   882
          \ ':update<CR>'.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   883
          \ ':call <SID>CVSFinishCommit("' . messageFileName . '",' .
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   884
          \                             '"' . newCwd . '",' .
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   885
          \                             '"' . realFileName . '",' .
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   886
          \                             cvsBufferCheck . ')<CR>'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   887
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   888
    silent 0put ='CVS: ----------------------------------------------------------------------'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   889
    silent put =\"CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically\"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   890
    silent put ='CVS: Type <leader>cc (or your own <Plug>CVSCommit mapping)'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   891
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   892
    if s:CVSGetOption('CVSCommandCommitOnWrite', 1) == 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   893
      execute 'au CVSCommit BufWritePre' autoPattern 'g/^CVS:/d'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   894
      execute 'au CVSCommit BufWritePost' autoPattern 'call s:CVSFinishCommit("' . messageFileName . '", "' . newCwd . '", "' . realFileName . '", ' . cvsBufferCheck . ') | au! * ' autoPattern
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   895
      silent put ='CVS: or write this buffer'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   896
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   897
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   898
    silent put ='CVS: to finish this commit operation'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   899
    silent put ='CVS: ----------------------------------------------------------------------'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   900
    $
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   901
    let b:CVSSourceFile=fileName
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   902
    let b:CVSCommand='CVSCommit'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   903
    set filetype=cvs
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   904
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   905
    let &shellslash = shellSlashBak
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   906
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   907
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   908
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   909
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   910
" Function: s:CVSDiff(...) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   911
function! s:CVSDiff(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   912
  if a:0 == 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   913
    let revOptions = '-r' . a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   914
    let caption = a:1 . ' -> current'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   915
  elseif a:0 == 2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   916
    let revOptions = '-r' . a:1 . ' -r' . a:2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   917
    let caption = a:1 . ' -> ' . a:2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   918
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   919
    let revOptions = ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   920
    let caption = ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   921
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   922
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   923
  let cvsdiffopt=s:CVSGetOption('CVSCommandDiffOpt', 'wbBc')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   924
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   925
  if cvsdiffopt == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   926
    let diffoptionstring=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   927
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   928
    let diffoptionstring=" -" . cvsdiffopt . " "
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   929
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   930
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   931
  let resultBuffer = s:CVSDoCommand('diff ' . diffoptionstring . revOptions , 'cvsdiff', caption)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   932
  if resultBuffer != -1 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   933
    set filetype=diff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   934
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   935
  return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   936
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   937
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   938
" Function: s:CVSEdit() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   939
function! s:CVSEdit()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   940
  return s:CVSDoCommand('edit', 'cvsedit', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   941
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   942
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   943
" Function: s:CVSEditors() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   944
function! s:CVSEditors()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   945
  return s:CVSDoCommand('editors', 'cvseditors', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   946
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   947
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   948
" Function: s:CVSGotoOriginal(["!]) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   949
function! s:CVSGotoOriginal(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   950
  let origBuffNR = s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   951
  if origBuffNR > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   952
    let origWinNR = bufwinnr(origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   953
    if origWinNR == -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   954
      execute 'buffer' origBuffNR
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   955
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   956
      execute origWinNR . 'wincmd w'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   957
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   958
    if a:0 == 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   959
      if a:1 == "!"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   960
        let buffnr = 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   961
        let buffmaxnr = bufnr("$")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   962
        while buffnr <= buffmaxnr
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   963
          if getbufvar(buffnr, "CVSOrigBuffNR") == origBuffNR
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   964
            execute "bw" buffnr
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   965
          endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   966
          let buffnr = buffnr + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   967
        endwhile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   968
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   969
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   970
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   971
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   972
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   973
" Function: s:CVSFinishCommit(messageFile, targetDir, targetFile) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   974
function! s:CVSFinishCommit(messageFile, targetDir, targetFile, origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   975
  if filereadable(a:messageFile)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   976
    let oldCwd=getcwd()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   977
    if strlen(a:targetDir) > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   978
      execute 'cd' escape(a:targetDir, ' ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   979
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   980
    let resultBuffer=s:CVSCreateCommandBuffer('commit -F "' . a:messageFile . '" "'. a:targetFile . '"', 'cvscommit', '', a:origBuffNR)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   981
    execute 'cd' escape(oldCwd, ' ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   982
    execute 'bw' escape(a:messageFile, ' *?\')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   983
    silent execute 'call delete("' . a:messageFile . '")'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   984
    return s:CVSMarkOrigBufferForSetup(resultBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   985
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   986
    echoerr "Can't read message file; no commit is possible."
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   987
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   988
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   989
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   990
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   991
" Function: s:CVSLog() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   992
function! s:CVSLog(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   993
  if a:0 == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   994
    let versionOption = ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   995
    let caption = ''
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   996
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   997
    let versionOption=" -r" . a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   998
    let caption = a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
   999
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1000
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1001
  let resultBuffer=s:CVSDoCommand('log' . versionOption, 'cvslog', caption)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1002
  if resultBuffer != ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1003
    set filetype=rcslog
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1004
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1005
  return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1006
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1007
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1008
" Function: s:CVSRevert() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1009
function! s:CVSRevert()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1010
  return s:CVSMarkOrigBufferForSetup(s:CVSDoCommand('update -C', 'cvsrevert', ''))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1011
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1012
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1013
" Function: s:CVSReview(...) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1014
function! s:CVSReview(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1015
  if a:0 == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1016
    let versiontag=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1017
    if s:CVSGetOption('CVSCommandInteractive', 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1018
      let versiontag=input('Revision:  ')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1019
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1020
    if versiontag == ""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1021
      let versiontag="(current)"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1022
      let versionOption=""
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1023
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1024
      let versionOption=" -r " . versiontag . " "
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1025
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1026
  else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1027
    let versiontag=a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1028
    let versionOption=" -r " . versiontag . " "
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1029
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1030
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1031
  let resultBuffer = s:CVSDoCommand('-q update -p' . versionOption, 'cvsreview', versiontag)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1032
  if resultBuffer > 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1033
    let &filetype=getbufvar(b:CVSOrigBuffNR, '&filetype')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1034
  endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1035
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1036
  return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1037
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1038
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1039
" Function: s:CVSStatus() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1040
function! s:CVSStatus()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1041
  return s:CVSDoCommand('status', 'cvsstatus', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1042
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1043
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1044
" Function: s:CVSUnedit() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1045
function! s:CVSUnedit()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1046
  return s:CVSDoCommand('unedit', 'cvsunedit', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1047
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1048
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1049
" Function: s:CVSUpdate() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1050
function! s:CVSUpdate()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1051
  return s:CVSMarkOrigBufferForSetup(s:CVSDoCommand('update', 'update', ''))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1052
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1053
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1054
" Function: s:CVSVimDiff(...) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1055
function! s:CVSVimDiff(...)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1056
  let originalBuffer = s:CVSCurrentBufferCheck()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1057
  let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1058
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1059
    " If there's already a VimDiff'ed window, restore it.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1060
    " There may only be one CVSVimDiff original window at a time.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1061
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1062
    if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1063
      " Clear the existing vimdiff setup by removing the result buffers.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1064
      call s:CVSWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1065
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1066
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1067
    " Split and diff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1068
    if(a:0 == 2)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1069
      " Reset the vimdiff system, as 2 explicit versions were provided.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1070
      if exists('s:vimDiffSourceBuffer')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1071
        call s:CVSWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1072
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1073
      let resultBuffer = s:CVSReview(a:1)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1074
      if resultBuffer < 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1075
        echomsg "Can't open CVS revision " . a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1076
        return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1077
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1078
      let b:CVSCommand = 'vimdiff'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1079
      diffthis
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1080
      let s:vimDiffBufferCount = 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1081
      let s:vimDiffScratchList = '{'. resultBuffer . '}'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1082
      " If no split method is defined, cheat, and set it to vertical.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1083
      try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1084
        call s:CVSOverrideOption('CVSCommandSplit', s:CVSGetOption('CVSCommandDiffSplit', s:CVSGetOption('CVSCommandSplit', 'vertical')))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1085
        let resultBuffer=s:CVSReview(a:2)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1086
      finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1087
        call s:CVSOverrideOption('CVSCommandSplit')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1088
      endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1089
      if resultBuffer < 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1090
        echomsg "Can't open CVS revision " . a:1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1091
        return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1092
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1093
      let b:CVSCommand = 'vimdiff'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1094
      diffthis
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1095
      let s:vimDiffBufferCount = 2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1096
      let s:vimDiffScratchList = s:vimDiffScratchList . '{'. resultBuffer . '}'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1097
    else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1098
      " Add new buffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1099
      try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1100
        " Force splitting behavior, otherwise why use vimdiff?
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1101
        call s:CVSOverrideOption("CVSCommandEdit", "split")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1102
        call s:CVSOverrideOption("CVSCommandSplit", s:CVSGetOption('CVSCommandDiffSplit', s:CVSGetOption('CVSCommandSplit', 'vertical')))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1103
        if(a:0 == 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1104
          let resultBuffer=s:CVSReview()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1105
        else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1106
          let resultBuffer=s:CVSReview(a:1)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1107
        endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1108
      finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1109
        call s:CVSOverrideOption("CVSCommandEdit")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1110
        call s:CVSOverrideOption("CVSCommandSplit")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1111
      endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1112
      if resultBuffer < 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1113
        echomsg "Can't open current CVS revision"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1114
        return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1115
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1116
      let b:CVSCommand = 'vimdiff'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1117
      diffthis
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1118
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1119
      if !exists('s:vimDiffBufferCount')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1120
        " New instance of vimdiff.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1121
        let s:vimDiffBufferCount = 2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1122
        let s:vimDiffScratchList = '{' . resultBuffer . '}'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1123
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1124
        " This could have been invoked on a CVS result buffer, not the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1125
        " original buffer.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1126
        wincmd W
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1127
        execute 'buffer' originalBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1128
        " Store info for later original buffer restore
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1129
        let s:vimDiffRestoreCmd = 
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1130
              \    "call setbufvar(".originalBuffer.", \"&diff\", ".getbufvar(originalBuffer, '&diff').")"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1131
              \ . "|call setbufvar(".originalBuffer.", \"&foldcolumn\", ".getbufvar(originalBuffer, '&foldcolumn').")"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1132
              \ . "|call setbufvar(".originalBuffer.", \"&foldenable\", ".getbufvar(originalBuffer, '&foldenable').")"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1133
              \ . "|call setbufvar(".originalBuffer.", \"&foldmethod\", '".getbufvar(originalBuffer, '&foldmethod')."')"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1134
              \ . "|call setbufvar(".originalBuffer.", \"&scrollbind\", ".getbufvar(originalBuffer, '&scrollbind').")"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1135
              \ . "|call setbufvar(".originalBuffer.", \"&wrap\", ".getbufvar(originalBuffer, '&wrap').")"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1136
              \ . "|if &foldmethod=='manual'|execute 'normal zE'|endif"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1137
        diffthis
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1138
        wincmd w
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1139
      else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1140
        " Adding a window to an existing vimdiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1141
        let s:vimDiffBufferCount = s:vimDiffBufferCount + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1142
        let s:vimDiffScratchList = s:vimDiffScratchList . '{' . resultBuffer . '}'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1143
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1144
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1145
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1146
    let s:vimDiffSourceBuffer = originalBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1147
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1148
    " Avoid executing the modeline in the current buffer after the autocommand.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1149
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1150
    let currentBuffer = bufnr('%')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1151
    let saveModeline = getbufvar(currentBuffer, '&modeline')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1152
    try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1153
      call setbufvar(currentBuffer, '&modeline', 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1154
      silent do CVSCommand User CVSVimDiffFinish
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1155
    finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1156
      call setbufvar(currentBuffer, '&modeline', saveModeline)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1157
    endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1158
    return resultBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1159
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1160
    let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning - 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1161
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1162
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1163
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1164
" Function: s:CVSWatch(onoff) {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1165
function! s:CVSWatch(onoff)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1166
  if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1167
    echoerr "Argument to CVSWatch must be one of [on|off|add|remove]"
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1168
    return -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1169
  end
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1170
  return s:CVSDoCommand('watch ' . tolower(a:onoff), 'cvswatch', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1171
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1172
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1173
" Function: s:CVSWatchers() {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1174
function! s:CVSWatchers()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1175
  return s:CVSDoCommand('watchers', 'cvswatchers', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1176
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1177
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1178
" Section: Command definitions {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1179
" Section: Primary commands {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1180
com! CVSAdd call s:CVSAdd()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1181
com! -nargs=? CVSAnnotate call s:CVSAnnotate(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1182
com! -bang -nargs=? CVSCommit call s:CVSCommit(<q-bang>, <q-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1183
com! -nargs=* CVSDiff call s:CVSDiff(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1184
com! CVSEdit call s:CVSEdit()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1185
com! CVSEditors call s:CVSEditors()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1186
com! -bang CVSGotoOriginal call s:CVSGotoOriginal(<q-bang>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1187
com! -nargs=? CVSLog call s:CVSLog(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1188
com! CVSRevert call s:CVSRevert()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1189
com! -nargs=? CVSReview call s:CVSReview(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1190
com! CVSStatus call s:CVSStatus()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1191
com! CVSUnedit call s:CVSUnedit()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1192
com! CVSUpdate call s:CVSUpdate()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1193
com! -nargs=* CVSVimDiff call s:CVSVimDiff(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1194
com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1195
com! CVSWatchAdd call s:CVSWatch('add')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1196
com! CVSWatchOn call s:CVSWatch('on')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1197
com! CVSWatchOff call s:CVSWatch('off')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1198
com! CVSWatchRemove call s:CVSWatch('remove')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1199
com! CVSWatchers call s:CVSWatchers()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1200
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1201
" Section: CVS buffer management commands {{{2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1202
com! CVSDisableBufferSetup call CVSDisableBufferSetup()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1203
com! CVSEnableBufferSetup call CVSEnableBufferSetup()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1204
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1205
" Allow reloading cvscommand.vim
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1206
com! CVSReload unlet! loaded_cvscommand | runtime plugin/cvscommand.vim
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1207
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1208
" Section: Plugin command mappings {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1209
nnoremap <silent> <Plug>CVSAdd :CVSAdd<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1210
nnoremap <silent> <Plug>CVSAnnotate :CVSAnnotate<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1211
nnoremap <silent> <Plug>CVSCommit :CVSCommit<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1212
nnoremap <silent> <Plug>CVSDiff :CVSDiff<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1213
nnoremap <silent> <Plug>CVSEdit :CVSEdit<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1214
nnoremap <silent> <Plug>CVSEditors :CVSEditors<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1215
nnoremap <silent> <Plug>CVSGotoOriginal :CVSGotoOriginal<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1216
nnoremap <silent> <Plug>CVSClearAndGotoOriginal :CVSGotoOriginal!<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1217
nnoremap <silent> <Plug>CVSLog :CVSLog<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1218
nnoremap <silent> <Plug>CVSRevert :CVSRevert<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1219
nnoremap <silent> <Plug>CVSReview :CVSReview<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1220
nnoremap <silent> <Plug>CVSStatus :CVSStatus<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1221
nnoremap <silent> <Plug>CVSUnedit :CVSUnedit<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1222
nnoremap <silent> <Plug>CVSUpdate :CVSUpdate<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1223
nnoremap <silent> <Plug>CVSVimDiff :CVSVimDiff<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1224
nnoremap <silent> <Plug>CVSWatchers :CVSWatchers<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1225
nnoremap <silent> <Plug>CVSWatchAdd :CVSWatchAdd<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1226
nnoremap <silent> <Plug>CVSWatchOn :CVSWatchOn<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1227
nnoremap <silent> <Plug>CVSWatchOff :CVSWatchOff<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1228
nnoremap <silent> <Plug>CVSWatchRemove :CVSWatchRemove<CR>
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1229
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1230
" Section: Default mappings {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1231
if !hasmapto('<Plug>CVSAdd')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1232
  nmap <unique> <Leader>ca <Plug>CVSAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1233
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1234
if !hasmapto('<Plug>CVSAnnotate')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1235
  nmap <unique> <Leader>cn <Plug>CVSAnnotate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1236
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1237
if !hasmapto('<Plug>CVSClearAndGotoOriginal')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1238
  nmap <unique> <Leader>cG <Plug>CVSClearAndGotoOriginal
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1239
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1240
if !hasmapto('<Plug>CVSCommit')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1241
  nmap <unique> <Leader>cc <Plug>CVSCommit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1242
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1243
if !hasmapto('<Plug>CVSDiff')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1244
  nmap <unique> <Leader>cd <Plug>CVSDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1245
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1246
if !hasmapto('<Plug>CVSEdit')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1247
  nmap <unique> <Leader>ce <Plug>CVSEdit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1248
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1249
if !hasmapto('<Plug>CVSEditors')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1250
  nmap <unique> <Leader>ci <Plug>CVSEditors
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1251
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1252
if !hasmapto('<Plug>CVSGotoOriginal')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1253
  nmap <unique> <Leader>cg <Plug>CVSGotoOriginal
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1254
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1255
if !hasmapto('<Plug>CVSLog')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1256
  nmap <unique> <Leader>cl <Plug>CVSLog
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1257
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1258
if !hasmapto('<Plug>CVSRevert')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1259
  nmap <unique> <Leader>cq <Plug>CVSRevert
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1260
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1261
if !hasmapto('<Plug>CVSReview')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1262
  nmap <unique> <Leader>cr <Plug>CVSReview
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1263
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1264
if !hasmapto('<Plug>CVSStatus')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1265
  nmap <unique> <Leader>cs <Plug>CVSStatus
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1266
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1267
if !hasmapto('<Plug>CVSUnedit')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1268
  nmap <unique> <Leader>ct <Plug>CVSUnedit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1269
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1270
if !hasmapto('<Plug>CVSUpdate')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1271
  nmap <unique> <Leader>cu <Plug>CVSUpdate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1272
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1273
if !hasmapto('<Plug>CVSVimDiff')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1274
  nmap <unique> <Leader>cv <Plug>CVSVimDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1275
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1276
if !hasmapto('<Plug>CVSWatchers')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1277
  nmap <unique> <Leader>cwv <Plug>CVSWatchers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1278
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1279
if !hasmapto('<Plug>CVSWatchAdd')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1280
  nmap <unique> <Leader>cwa <Plug>CVSWatchAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1281
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1282
if !hasmapto('<Plug>CVSWatchOn')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1283
  nmap <unique> <Leader>cwn <Plug>CVSWatchOn
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1284
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1285
if !hasmapto('<Plug>CVSWatchOff')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1286
  nmap <unique> <Leader>cwf <Plug>CVSWatchOff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1287
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1288
if !hasmapto('<Plug>CVSWatchRemove')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1289
  nmap <unique> <Leader>cwr <Plug>CVSWatchRemove
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1290
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1291
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1292
" Section: Menu items {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1293
silent! aunmenu Plugin.CVS
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1294
amenu <silent> &Plugin.CVS.&Add        <Plug>CVSAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1295
amenu <silent> &Plugin.CVS.A&nnotate   <Plug>CVSAnnotate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1296
amenu <silent> &Plugin.CVS.&Commit     <Plug>CVSCommit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1297
amenu <silent> &Plugin.CVS.&Diff       <Plug>CVSDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1298
amenu <silent> &Plugin.CVS.&Edit       <Plug>CVSEdit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1299
amenu <silent> &Plugin.CVS.Ed&itors    <Plug>CVSEditors
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1300
amenu <silent> &Plugin.CVS.&Log        <Plug>CVSLog
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1301
amenu <silent> &Plugin.CVS.Revert      <Plug>CVSRevert
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1302
amenu <silent> &Plugin.CVS.&Review     <Plug>CVSReview
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1303
amenu <silent> &Plugin.CVS.&Status     <Plug>CVSStatus
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1304
amenu <silent> &Plugin.CVS.Unedi&t     <Plug>CVSUnedit
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1305
amenu <silent> &Plugin.CVS.&Update     <Plug>CVSUpdate
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1306
amenu <silent> &Plugin.CVS.&VimDiff    <Plug>CVSVimDiff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1307
amenu <silent> &Plugin.CVS.&Watchers   <Plug>CVSWatchers
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1308
amenu <silent> &Plugin.CVS.WatchAdd    <Plug>CVSWatchAdd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1309
amenu <silent> &Plugin.CVS.WatchOn     <Plug>CVSWatchOn
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1310
amenu <silent> &Plugin.CVS.WatchOff    <Plug>CVSWatchOff
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1311
amenu <silent> &Plugin.CVS.WatchRemove <Plug>CVSWatchRemove
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1312
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1313
" Section: Autocommands to restore vimdiff state {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1314
function! s:CVSVimDiffRestore(vimDiffBuff)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1315
  let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1316
  try
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1317
    if exists("s:vimDiffSourceBuffer")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1318
      if a:vimDiffBuff == s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1319
        " Original file is being removed.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1320
        unlet! s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1321
        unlet! s:vimDiffBufferCount
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1322
        unlet! s:vimDiffRestoreCmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1323
        unlet! s:vimDiffScratchList
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1324
      elseif match(s:vimDiffScratchList, '{' . a:vimDiffBuff . '}') >= 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1325
        let s:vimDiffScratchList = substitute(s:vimDiffScratchList, '{' . a:vimDiffBuff . '}', '', '')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1326
        let s:vimDiffBufferCount = s:vimDiffBufferCount - 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1327
        if s:vimDiffBufferCount == 1 && exists('s:vimDiffRestoreCmd')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1328
          " All scratch buffers are gone, reset the original.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1329
          " Only restore if the source buffer is still in Diff mode
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1330
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1331
          let sourceWinNR=bufwinnr(s:vimDiffSourceBuffer)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1332
          if sourceWinNR != -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1333
            " The buffer is visible in at least one window
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1334
            let currentWinNR = winnr()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1335
            while winbufnr(sourceWinNR) != -1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1336
              if winbufnr(sourceWinNR) == s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1337
                execute sourceWinNR . 'wincmd w'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1338
                if getwinvar('', "&diff")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1339
                  execute s:vimDiffRestoreCmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1340
                endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1341
              endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1342
              let sourceWinNR = sourceWinNR + 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1343
            endwhile
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1344
            execute currentWinNR . 'wincmd w'
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1345
          else
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1346
            " The buffer is hidden.  It must be visible in order to set the
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1347
            " diff option.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1348
            let currentBufNR = bufnr('')
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1349
            execute "hide buffer" s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1350
            if getwinvar('', "&diff")
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1351
              execute s:vimDiffRestoreCmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1352
            endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1353
            execute "hide buffer" currentBufNR
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1354
          endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1355
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1356
          unlet s:vimDiffRestoreCmd
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1357
          unlet s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1358
          unlet s:vimDiffBufferCount
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1359
          unlet s:vimDiffScratchList
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1360
        elseif s:vimDiffBufferCount == 0
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1361
          " All buffers are gone.
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1362
          unlet s:vimDiffSourceBuffer
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1363
          unlet s:vimDiffBufferCount
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1364
          unlet s:vimDiffScratchList
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1365
        endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1366
      endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1367
    endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1368
  finally
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1369
    let s:CVSCommandEditFileRunning = s:CVSCommandEditFileRunning - 1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1370
  endtry
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1371
endfunction
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1372
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1373
augroup CVSVimDiffRestore
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1374
  au!
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1375
  au BufUnload * call s:CVSVimDiffRestore(expand("<abuf>"))
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1376
augroup END
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1377
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1378
" Section: Optional activation of buffer management {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1379
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1380
if s:CVSGetOption('CVSCommandEnableBufferSetup', 0)
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1381
  call CVSEnableBufferSetup()
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1382
endif
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1383
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1384
" Section: Plugin completion {{{1
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1385
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1386
let loaded_cvscommand=2
61f2008cd6bf Addition of CVScommand vim script as a base for HGcommand
"Mathieu Clabaut <mathieu.clabaut@gmail.com>"
parents:
diff changeset
  1387
silent do CVSCommand User CVSPluginFinish