Emacs VC Mode and Mercurial

Note: the Emacs VC mode described here ships with Emacs 22.3 and higher. It has not been ported to other Emacs variants yet, and is distinct from the mercurial.el package that ships with Mercurial itself.

Emacs VC mode is a GNU Emacs facility for performing version-control actions from within Emacs. It aims to support all open-source VCSes with a single, common set of keystroke commands. It was originally written in the early 1990s for file-oriented version-control systems like SCCS and RCS, and was unable to treat operations on multiple-file changesets as single operations in the way that Mercurial and other modern version-control systems require. This changed in mid-2007; a complete rewrite of the mode is now in Emacs. New VC includes full support for Mercurial.

Here is a summary of the most important VC-mode commands intended to convey the style of the VC interface. More commands and more details can be found in the Emacs documentation.

* C-x v d -- List version-controlled files in the current directory in the style of a Dired buffer. The VC-Dired listing will include information on the file's modified/unmodified status. Marking files defines a "selection set", which other VC-mode commands will operate upon. (Alternatively, if you invoke a VC command while visiting a file buffer, the selection set for the command will consist of that single file).

* C-x v l -- Capture into a visible log buffer the output of hg log on the current selection set. Various interesting commands become available within the log buffer; for example, d will pop up a buffer displaying the diff corresponding to whatever log entry your Emacs cursor is touching.

* C-x v = -- Show differences between your working copy and the currently selected revision (usually the tip of the currently selected named branch).

* C-x v u -- Perform hg revert on the selected fileset.

* C-x v v -- Do the right thing on the selection set. On a selection set of files not under Mercurial control, it will perform an hg add. On a selection set of files all under Mercurial's control, it will pop up a buffer to accept a change comment. When you close that buffer with C-c C-c, it will perform an hg commit on all working-copy modifications on the files in the selection set. You may have more than one pending commit in progress at a time, as each commit buffer remembers the changeset associated with it. To abort a commit, simply delete the log buffer.

The mode line of a file under Mercurial's control will display Hg: followed by the local revision number of the revision you are viewing.

The push or pull operations VC provides are broken in Emacs 23.2.1. Consider using mercurial.el which is distributed with mercurial, or ahg

EmacsVcMode (last edited 2011-07-20 07:36:11 by adsl)