As distributed version control systems (DVCS) become widely used, Emacs also start to support them. To support concrete DVCS implementations separate Emacs packages was created. They implement commands, that closely reflect ideology of concrete system, and often these packages use different key bindings and user interface, that match ideology of DVCS.
As was mentioned earlier, in Emacs exists VC package, that was created to support different version control systems (VCS) and provide uniform interface for all of them, including some of DVCS. DVC package has same goal as VC, but intended to support distributed VCS. Some of DVC code is based on the code from the Xtla package, and developed by same developers. You can get more information about DVC from project's site.
DVC has multilayer architecture. At the top layer are functions, that provide automatic version control system detection, and implement functions, common for all DVCS. One layer below, are defined functions, specific for concrete version control system. And at the lowest level, are defined functions, providing common framework for all supported DVCS.
Now, DVC support following version control systems:
|name in DVC||name of VCS|
|xhg||mercurial (aka hg)|
|baz||GNU Arch (tla) and Bazaar 1.x|
Not all supported VCS has full support in DVC. You can find list of supported functions for each of system on project's site.
Installation of package is quite simple — you need to download archive from site, unpack it and setup it with standard commands sequence:
./configure make make install
To be able to use functions, provided by package, you need to add following lines to Emacs initialization file:
(add-to-list 'load-path "path_to_installed_package") (require 'dvc-autoloads)
that will perform registration of autoloads for parts of package, After executing these commands, you can start to work with package, or perform initial customization of it (as this described later, but usually customization is not required, as package define reasonable default values.
User can work with DVC using common knowledge about commands of corresponding version
control system — for all basic VCS's commands DVC provide corresponding functions, those
names started from
Main command, that will be usually used by user is
dvc-status (it also available through
C-x V s keybinding). During execution it creates buffer with a list of modified files,
that looks much like the buffer, created by package PCL-CVS. Name of the buffer depends
from the name of used version control system and looks like
replaced with name of backend for corresponding VCS (names of backends listed in table
After getting buffer with repository's status, user can execute different operations in
it. For this buffer will automatically set
dvc-diff major mode, for which defined some
number of commands. Interface and control keys for this mode very close to interface and
keys that used in PCL-CVS package, so if you had worked with it, then you can easily
switch to work with DVC2. Some operations also available for execution via menus. DVC
add several menus —
DVC-Buffers, and dedicated menu for backend of concrete
VCS, that list commands specific for this backend.
DVC-Buffers contain list of opened
buffers, related to DVC and could be used for work with these buffers.
DVC-Diff menu could
be used for access to commands, common for all VCS — getting changes, addition and
deletion of files, etc.
As in PCL-CVS, some commands could be executed not only for concrete files, but for group
of selected files. For setting mark to file you can use
m key, and for removing it —
key. Besides this, you can use
backspace key for removing mark from previous file.
Usually users use only limited set of operations — look for made changes and commit or revert them, add or remove files, look into change log, etc. For all of these operations DVC provide corresponding commands.
You can view content of a file with
dvc-diff-jump-to-change function (key
function opens the file and move cursor to first modified line. Another function for
viewing source is
o key or middle mouse button). With the function
C-x C-j) you can also open Dired buffer and move to the selected file.
User can revert changes with the command
C-x V f R). But
committing of changes could be done by one of two commands:
C-x V c) opens buffer in which you could enter
commit message, and after this, run function
dvc-log-edit-done (it bind to keys
to do actual commit. Second command —
C-x V a) differ from first
only in the style in which commit messages will presented (like entries in
files). When you stay in status buffer you can also save changes as a file. You can do
this with function
There are several functions, that could be used to view changes. To view changes from the
*VCS-status* buffer you can use functions
= key) and
e key). Second function differ from first only that it run ediff instead
of external diff. To quickly switch between buffer containing diffs and corresponding
element in the status buffer, you could use function
j key) — it
works for both buffers. And with function
v key) you can open
separate buffer with a file and view modified part of the file in this buffer. To see
content of buffer with diffs without switching to it, you can use following functions —
that scroll buffer with diffs up and down.
Besides these functions, exists 3 functions, that could be executed outside of
*VCS-status* buffer and has global key bindings.
dvc-diff function (bind to
=) display changes between current and previous state of repository.
C-x V d) and
C-x V e) functions could be used to display changes for
concrete file, using buffer (with output of external diff) or ediff.
To see log of changes you can use several functions, that defined both for status buffer,
and globally. The
C-x V L) function show list of changes (in short form)
for file of project. For current file in status buffer you can see change log with
l key). Full change log you can see with function
C-x V l). All these functions accept optional prefix parameter, that define how many
last changes you want to see (by default, these functions show all changes).
Users often perform operations with files — add them, delete, etc. DVC provide several
functions for these tasks —
C-x V f a) function add current (or
marked) file(s) to repository. To remove marked files from repository user can use
C-x V f D). There is also additional function
for removing files —
C-x V f X), that remove files from disk without
leaving a backups. As most of modern version control systems provide commands for
renaming files, so DVC also support this functionality with function
C-x V f
To work with files, that already registered in VCS, but doesn't shown in status buffer,
you can use function
C-x V i), that display list of files known by VCS. In
this buffer user can use same commands and key bindings, as in the status buffer.
User can do some manipulations on list of objects (files and directories) in repository.
Usually, in each of VCS exists list of ignored files, that could be edited by user3.
For quick manipulations with this list there are several functions.
i) function put current (or marked) file(s) into list of ignored objects.
# I or
M-I) function also modify this list, but put into it
not full file names, but only their extensions. And if you want to modify this list other
way — remove file from list, or add complex regular expression, then you can use function
# e), that open buffer with list of ignored objects, and allow you
to edit it (please mention, that syntax of this file depends on used version control
If you want to create new repository in current directory, you can use function
C-x V I) that will ask you about which DVCS you want use for it, and after that perform
corresponding command for initialization of repository.
Work with different repositories and branches is very actual task for user of distributed VCS, so DVC provide number of functions for performing these tasks. For all supported VCS exists common set of commands, providing basic functionality. And, as DVC project is successor of Xtla project, then for work with GNU Arch & Bazaar exists more functions — bookmarks for repositories, etc. Backends for other VCSs could also provide additional functions, specific to concrete VCS.
Following commands are common for all supported DVCS:
||show changes in remote repository, not applied to current repository|
||download and apply changes from remote repository|
||download changes from remote repository (not apply them)|
||apply downloaded changes|
||send changes to given e-mail address|
||open buffer with bookmarks to remote repositories|
||clone repository from external one|
||creates new branch|
||switch to another branch|
||show list of existing branches|
Using these commands you can perform most of the tasks affecting other repositories.
To leave status buffer you can use function
q key). And to update
content of status buffer (it doesn't performed automatically) you need to execute
g key) function.
To get help on DVC usage you can use standard Emacs features — when you are in status
C-h m and you get description of current major and minor modes, together
with list of key bindings and names of corresponding commands. List of global key
bindings you can get if you invoke
C-x V C-h. Besides this, package provide number of
tips, that you can open with
dvc-tips-next-tip function, and than use
p keys to
navigate between next and previous tip.
During it work DVC opens number of auxiliary buffers. To make movement between them more
easy DVC define number of functions. When you view several buffers with nested changes,
you can use
^ key) function to move to the main buffer, containing
changes. For each buffer DVC set special variable, that points to the partner buffer, that
also used for perform same task. This allow quickly switch between these buffers with
h key) function.
You can use same approach to view buffers used by DVD internally. The
B L) function opens buffer, that contain all commands,
executed by package. And with
B p) function you can see results
of execution of external commands, executed by package to perform all operations.
Package customization could be done with standard Emacs customization routines.
Corresponding customization group is called
Some modes, implemented by DVC provide to user ability to set buffer parameters from
hooks. For example, the
dvc-status function run
dvc-diff-mode-hook (if it defined) after
it finish initialization of status buffer.
1. Besides this, each backend, implementing support for concrete VCS, define their own
set of functions, corresponding to commands of given VCS. For example, backend,
implementing support for Mercurial define functions with prefix
xhg-, and these
functions could be directly used by user, if there are no corresponding functions with
2. I want to mention that many commands also available outside the
To execute them you can add global prefix
C-x V to their local key binding. In this
text I'll mark them as a global.
3. User can also see ignored files if variable
dvc-status-display-ignored will has
Last change: 05.03.2013 16:54