aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorChong Yidong2008-10-31 22:00:48 +0000
committerChong Yidong2008-10-31 22:00:48 +0000
commitccac97df942328c923699546c7c3ec5249d519a9 (patch)
treea1207726f59d22c5910c9ee2c4ca9f1f9a61ddb0 /doc
parent05c5ad632b7293330f3d60a93591359728471b5f (diff)
downloademacs-ccac97df942328c923699546c7c3ec5249d519a9.tar.gz
emacs-ccac97df942328c923699546c7c3ec5249d519a9.zip
(Version Control): Moved to maintaining.texi. Subnodes moved as well.
(Document Files): Moved to misc.texi.
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/files.texi1501
1 files changed, 0 insertions, 1501 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index b9cad4054ce..10e240e8041 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -30,14 +30,12 @@ on file directories.
30@end ifnottex 30@end ifnottex
31* Auto Save:: Auto Save periodically protects against loss of data. 31* Auto Save:: Auto Save periodically protects against loss of data.
32* File Aliases:: Handling multiple names for one file. 32* File Aliases:: Handling multiple names for one file.
33* Version Control:: Version control systems (RCS, CVS and SCCS).
34* Directories:: Creating, deleting, and listing file directories. 33* Directories:: Creating, deleting, and listing file directories.
35* Comparing Files:: Finding where two files differ. 34* Comparing Files:: Finding where two files differ.
36* Diff Mode:: Mode for editing file differences. 35* Diff Mode:: Mode for editing file differences.
37* Misc File Ops:: Other things you can do on files. 36* Misc File Ops:: Other things you can do on files.
38* Compressed Files:: Accessing compressed files. 37* Compressed Files:: Accessing compressed files.
39* File Archives:: Operating on tar, zip, jar etc. archive files. 38* File Archives:: Operating on tar, zip, jar etc. archive files.
40* Document Files:: Viewing PDF, PS and DVI files.
41* Remote Files:: Accessing files on other sites. 39* Remote Files:: Accessing files on other sites.
42* Quoted File Names:: Quoting special characters in file names. 40* Quoted File Names:: Quoting special characters in file names.
43* File Name Cache:: Completion against a list of files you often use. 41* File Name Cache:: Completion against a list of files you often use.
@@ -1164,1351 +1162,6 @@ then the file name recorded for a buffer is the file's @dfn{truename}
1164than the name you specify. Setting @code{find-file-visit-truename} also 1162than the name you specify. Setting @code{find-file-visit-truename} also
1165implies the effect of @code{find-file-existing-other-name}. 1163implies the effect of @code{find-file-existing-other-name}.
1166 1164
1167@node Version Control
1168@section Version Control
1169@cindex version control
1170
1171 A @dfn{version control system} is a package that can record multiple
1172versions of a source file, storing information such as the creation
1173time of each version, who created it, and a description of what was
1174changed in that version.
1175
1176 The Emacs version control interface is called VC. Its commands work
1177with several different version control systems; currently, it supports
1178GNU Arch, Bazaar, CVS, Git, Mercurial, Monotone, RCS, SCCS/CSSC, and
1179Subversion. Of these, the GNU project distributes CVS, GNU Arch, RCS,
1180and Bazaar.
1181
1182 VC is enabled automatically whenever you visit a file that is
1183governed by a version control system. To disable VC entirely, set the
1184customizable variable @code{vc-handled-backends} to @code{nil}
1185@iftex
1186(@pxref{Customizing VC,,,emacs-xtra, Specialized Emacs Features}).
1187@end iftex
1188@ifnottex
1189(@pxref{Customizing VC}).
1190@end ifnottex
1191
1192
1193@menu
1194* Introduction to VC:: How version control works in general.
1195* VC Mode Line:: How the mode line shows version control status.
1196* Basic VC Editing:: How to edit a file under version control.
1197* Old Revisions:: Examining and comparing old versions.
1198* Secondary VC Commands:: The commands used a little less frequently.
1199* VC Directory Mode:: Listing files managed by version control.
1200* Branches:: Multiple lines of development.
1201@ifnottex
1202* Remote Repositories:: Efficient access to remote CVS servers.
1203* Revision Tags:: Symbolic names for revisions
1204* Miscellaneous VC:: Various other commands and features of VC.
1205* Customizing VC:: Variables that change VC's behavior.
1206@end ifnottex
1207@end menu
1208
1209@node Introduction to VC
1210@subsection Introduction to Version Control
1211
1212 VC allows you to use a version control system from within Emacs,
1213integrating the version control operations smoothly with editing.
1214Though VC cannot completely bridge the gaps between version control
1215systems with widely differing capabilities, it does provide a uniform
1216interface to many version control operations. Regardless of which
1217version control system is in use, you will be able to do basic
1218operations in much the same way.
1219
1220 This section provides a general overview of version control, and
1221describes the version control systems that VC supports. You can skip
1222this section if you are already familiar with the version control system
1223you want to use.
1224
1225@menu
1226* Why Version Control?:: Understanding the problems it addresses
1227* Version Control Systems:: Supported version control back-end systems.
1228* VCS Concepts:: Words and concepts related to version control.
1229* Types of Log File:: The VCS log in contrast to the ChangeLog.
1230@end menu
1231
1232@node Why Version Control?
1233@subsubsection Understanding the problems it addresses
1234
1235 Version control systems provide you with three important
1236capabilities:
1237
1238@itemize @bullet
1239@item
1240@dfn{Reversibility}: the ability to back up to a previous state if you
1241discover that some modification you did was a mistake or a bad idea.
1242
1243@item
1244@dfn{Concurrency}: the ability to have many people modifying the same
1245collection of files knowing that conflicting modifications can be
1246detected and resolved.
1247
1248@item
1249@dfn{History}: the ability to attach historical data to your data,
1250such as explanatory comments about the intention behind each change to
1251it. Even for a programmer working solo, change histories are an
1252important aid to memory; for a multi-person project, they are a
1253vitally important form of communication among developers.
1254@end itemize
1255
1256@node Version Control Systems
1257@subsubsection Supported Version Control Systems
1258
1259@cindex back end (version control)
1260 VC currently works with many different version control systems or
1261@dfn{back ends}:
1262
1263@itemize @bullet
1264
1265@cindex SCCS
1266@item
1267SCCS was the first version control system ever built, and was long ago
1268superseded by more advanced ones. VC compensates for certain features
1269missing in SCCS (e.g., tag names for releases) by implementing them
1270itself. Other VC features, such as multiple branches, are simply
1271unavailable. Since SCCS is non-free, we recommend avoiding it.
1272
1273@cindex CSSC
1274@item
1275CSSC is a free replacement for SCCS. You should use CSSC only if, for
1276some reason, you cannot use a more recent and better-designed version
1277control system.
1278
1279@cindex RCS
1280@item
1281RCS is the free version control system around which VC was initially
1282built. Almost everything you can do with RCS can be done through VC.
1283However, you cannot use RCS over the network, and it only works at the
1284level of individual files rather than projects.
1285
1286@cindex CVS
1287@item
1288CVS is the free version control system that was, until recently (circa
12892008), used by the majority of free software projects. Nowadays, it
1290is slowly being superseded by newer systems. CVS allows concurrent
1291multi-user development either locally or over the network. It lacks
1292support for atomic commits or file moving/renaming. VC supports all
1293basic editing operations under CVS. For some less common tasks, you
1294still need to call CVS from the command line. Note also that before
1295using CVS you must set up a repository, which is a subject too complex
1296to treat here.
1297
1298@cindex SVN
1299@cindex Subversion
1300@item
1301Subversion (SVN) is a free version control system designed to be
1302similar to CVS but without its problems. It supports atomic commits
1303of filesets, and versioning of directories, symbolic links, meta-data,
1304renames, copies, and deletes.
1305
1306@cindex GNU Arch
1307@cindex Arch
1308@item
1309GNU Arch is a version control system designed for distributed work.
1310It differs in many ways from older systems like CVS and RCS. It
1311provides different methods for interoperating between users, support
1312for offline operations, and good branching and merging features. It
1313also supports atomic commits of filesets and file moving/renaming. VC
1314does not support all operations provided by GNU Arch, so you must
1315sometimes invoke it from the command line.
1316
1317@cindex git
1318@item
1319Git is a distributed version control system invented by Linus Torvalds to support
1320Linux kernel development. It supports atomic commits of filesets and
1321file moving/renaming. One significant feature of git is that it
1322largely abolishes the notion of a single centralized repository;
1323instead, each working copy of a git project is its own repository and
1324coordination is done through repository-sync operations. VC supports
1325most git operations, with the exception of news merges and repository
1326syncing; these must be done from the command line.
1327
1328@cindex hg
1329@cindex Mercurial
1330@item
1331Mercurial (hg) is a distributed version control system broadly
1332resembling GNU Arch and git, with atomic fileset commits and file
1333moving/renaming. Like git, it is fully decentralized. VC supports
1334most Mercurial commands, with the exception of repository sync
1335operations; this needs to be done from the command line.
1336
1337@cindex bzr
1338@cindex Bazaar
1339@item
1340Bazaar (bzr) is a distributed version control system that supports both
1341repository-based and distributed versioning, with atomic fileset
1342commits and file moving/renaming. VC supports most basic editing
1343operations under Bazaar.
1344@end itemize
1345
1346 Previous versions of VC supported a version control system known as
1347Meta-CVS. This support has been dropped because of limited interest
1348from users and developers.
1349
1350@node VCS Concepts
1351@subsubsection Concepts of Version Control
1352
1353@cindex repository
1354@cindex registered file
1355 When a file is under version control, we say that it is
1356@dfn{registered} in the version control system. The system has a
1357@dfn{repository} which stores both the file's present state and its
1358change history---enough to reconstruct the current version or any
1359earlier version. The repository also contains other information, such
1360as @dfn{log entries} that describe the changes made to each file.
1361
1362@cindex work file
1363@cindex checking out files
1364 A file @dfn{checked out} of a repository is called the @dfn{work
1365file}. You edit the work file and make changes in it, as you would
1366with an ordinary file. After you are done with a set of changes, you
1367@dfn{check in} or @dfn{commit} the file; this records the changes in
1368the repository, along with a log entry for those changes.
1369
1370@cindex revision
1371@cindex revision ID
1372 A copy of a file stored in a repository is called a @dfn{revision}.
1373The history of a file is a sequence of revisions. Each revisions is
1374named by a @dfn{revision ID}. The format of the revision ID depends
1375on the version control system; in the simplest case, it is just an
1376integer.
1377
1378 To go beyond these basic concepts, you will need to understand three
1379ways in which version control systems can differ from each other.
1380They can be locking-based or merging-based; they can be file-based or
1381changeset-based; and they can be centralized or decentralized. VC
1382handles all these choices, but they lead to differing behaviors which
1383you will need to understand as you use it.
1384
1385@cindex locking versus merging
1386 A version control system typically has some mechanism to coordinate
1387between users who want to change the same file. There are two ways to
1388do this: merging and locking.
1389
1390 In a version control system that uses merging, each user may check
1391out and modify a work file at any time. The system lets you
1392@dfn{merge} your work file, which may contain changes that have not
1393been checked in, with the latest changes that others have checked into
1394the repository.
1395
1396 Older version control systems use a @dfn{locking} scheme instead.
1397Here, work files are normally read-only. To edit a file, you ask the
1398version control system to make it writable for you by @dfn{locking}
1399it; only one user can lock a given file at any given time. This
1400procedure is analogous to, but different from, the locking that Emacs
1401uses to detect simultaneous editing of ordinary files
1402(@pxref{Interlocking}). When you check in your changes, that unlocks
1403the file, and the work file becomes read-only again. Other users may
1404then lock the file to make their own changes.
1405
1406 Both locking and merging systems can have problems when multiple
1407users try to modify the same file at the same time. Locking systems
1408have @dfn{lock conflicts}; a user may try to check a file out and be
1409unable to because it is locked. In merging systems, @dfn{merge
1410conflicts} happen when you check in a change to a file that conflicts
1411with a change checked in by someone else after your checkout. Both
1412kinds of conflict have to be resolved by human judgment and
1413communication.
1414
1415 SCCS always uses locking. RCS is lock-based by default but can be
1416told to operate in a merging style. CVS and Subversion are
1417merge-based by default but can be told to operate in a locking mode.
1418Distributed version control systems, such as GNU Arch, git, and
1419Mercurial, are exclusively merging-based. Experience has shown that
1420merging is superior to locking, both in convenience to developers and
1421in minimizing the number and severity of conflicts that actually
1422occur. Sometimes, however, newer version control systems may have
1423locks retrofitted onto them for reasons having nothing to do with
1424technology@footnote{Usually the control-freak instincts of managers.}.
1425
1426 VC mode supports both locking and merging version control and tries
1427to hide the differences between them as much as possible.
1428
1429@cindex files versus changesets.
1430 On SCCS, RCS, CVS, and other early version control systems, version
1431control operations are @dfn{file-based}: each file has its own comment
1432and revision history separate from that of all other files in the
1433system. Later systems, beginning with Subversion, are
1434@dfn{changeset-based}: a checkin may include changes to several files,
1435and the entire set of changes is treated as a unit by the system. Any
1436comment associated with the change does not belong to a single file,
1437but to the changeset itself.
1438
1439 Changeset-based version control is more flexible and powerful than
1440file-based version control; usually, when a change to multiple files
1441has to be reversed, it's good to be able to easily identify and remove
1442all of it. But it took some years for designers to figure that out,
1443and while file-based systems are passing out of use, there are lots of
1444legacy repositories still to be dealt with as of this writing (2008).
1445
1446 Prior to Emacs 23, VC supported only file-based systems, leading to
1447unhappy results when it was used to drive changeset-based
1448systems---the Subversion support, for example, used to break up
1449changesets into multiple per-file commits. This has been fixed, but
1450it has left a mark in VC's terminology. The terms ``checkin'' and
1451``checkout'' are associated with file-based and locking-based systems
1452and a bit archaic; nowadays those operations are usually called
1453``commit'' and ``update''.
1454
1455@cindex centralized vs. decentralized version control
1456 Early version control systems were designed around a
1457@dfn{centralized} model in which each project has only one repository
1458used by all developers. SCCS, RCS, CVS, and Subversion share this
1459kind of model. One problem with this approach is that a single
1460repository is a single point of failure---if the repository server is
1461down, all work stops.
1462
1463 Newer version control systems like GNU Arch, git, Mercurial, and
1464Bazaar are @dfn{decentralized}. A project may have several different
1465repositories, and these systems support a sort of super-merge between
1466repositories that tries to reconcile their change histories. At the
1467limit, each developer has his/her own repository, and repository
1468merges replace checkin/commit operations.
1469
1470 VC's job is to help you manage the traffic between your personal
1471workfiles and a repository. Whether that repository is a single
1472master or one of a network of peer repositories is not something VC
1473has to care about. Thus, the difference between a centralized and a
1474decentralized version control system is invisible to VC mode.
1475
1476@node Types of Log File
1477@subsubsection Types of Log File
1478@cindex types of log file
1479@cindex log File, types of
1480@cindex version control log
1481
1482 Projects that use a version control system can have two types of log
1483for changes. One is the log maintained by the version control system:
1484each time you check in a change, you fill out a @dfn{log entry} for
1485the change (@pxref{Log Buffer}). This is called the @dfn{version
1486control log}.
1487
1488 The other kind of log is the file @file{ChangeLog} (@pxref{Change
1489Log}). It provides a chronological record of all changes to a large
1490portion of a program---typically one directory and its subdirectories.
1491A small program would use one @file{ChangeLog} file; a large program
1492may have a @file{ChangeLog} file in each major directory.
1493@xref{Change Log}.
1494
1495 Actually, the fact that both kinds of log exist is partly a legacy
1496from file-based version control. Changelogs are a GNU convention,
1497later more widely adopted, that help developers to get a
1498changeset-based view of a project even when its version control system
1499has that information split up in multiple file-based logs.
1500
1501 Changeset-based version systems, on the other hand, often maintain a
1502changeset-based modification log for the entire system that makes
1503ChangeLogs somewhat redundant. One advantage that ChangeLogs retain
1504is that it is sometimes useful to be able to view the transaction
1505history of a single directory separately from those of other
1506directories.
1507
1508 A project maintained with version control can use just the version
1509control log, or it can use both kinds of logs. It can handle some
1510files one way and some files the other way. Each project has its
1511policy, which you should follow.
1512
1513 When the policy is to use both, you typically want to write an entry
1514for each change just once, then put it into both logs. You can write
1515the entry in @file{ChangeLog}, then copy it to the log buffer with
1516@kbd{C-c C-a} when checking in the change (@pxref{Log Buffer}). Or
1517you can write the entry in the log buffer while checking in the
1518change, and later use the @kbd{C-x v a} command to copy it to
1519@file{ChangeLog}
1520@iftex
1521(@pxref{Change Logs and VC,,,emacs-xtra, Specialized Emacs Features}).
1522@end iftex
1523@ifnottex
1524(@pxref{Change Logs and VC}).
1525@end ifnottex
1526
1527@node VC Mode Line
1528@subsection Version Control and the Mode Line
1529
1530 When you visit a file that is under version control, Emacs indicates
1531this on the mode line. For example, @samp{RCS-1.3} says that RCS is
1532used for that file, and the current version is 1.3.
1533
1534 The character between the back-end name and the revision ID
1535indicates the version control status of the file. @samp{-} means that
1536the work file is not locked (if locking is in use), or not modified (if
1537locking is not in use). @samp{:} indicates that the file is locked, or
1538that it is modified. If the file is locked by some other user (for
1539instance, @samp{jim}), that is displayed as @samp{RCS:jim:1.3}.
1540
1541 On a graphical display, you can move the mouse over this mode line
1542indicator to pop up a ``tool-tip'', which displays a more verbose
1543description of the version control status. Pressing @kbd{Mouse-1}
1544over the indicator pops up a menu of VC commands. This menu is
1545identical to the @samp{Version Control} menu item, which can be found
1546in the @samp{Tools} menu on the menu bar.
1547
1548@vindex auto-revert-check-vc-info
1549 When Auto Revert mode (@pxref{Reverting}) reverts a buffer that is
1550under version control, it updates the version control information in
1551the mode line. However, Auto Revert mode may not properly update this
1552information if the version control status changes without changes to
1553the work file, from outside the current Emacs session. If you set
1554@code{auto-revert-check-vc-info} to @code{t}, Auto Revert mode updates
1555the version control status information every
1556@code{auto-revert-interval} seconds, even if the work file itself is
1557unchanged. The resulting CPU usage depends on the version control
1558system, but is usually not excessive.
1559
1560@node Basic VC Editing
1561@subsection Basic Editing under Version Control
1562
1563@cindex filesets
1564 Most VC commands operate on @dfn{VC filesets}. A VC fileset is a
1565group of one or more files that are treated as a unit, for the
1566purposes of version control.
1567
1568 If you are visiting a version-controlled file in the current
1569buffer, the VC fileset is simply that one file. If you are visiting a
1570VC directory buffer, and some files in it are marked, the VC fileset
1571consists of the marked files (@pxref{VC Directory Mode}).
1572
1573 The principal VC command is an all-purpose command, @kbd{C-x v v}
1574(@code{vc-next-action}), that performs either locking, merging or a
1575check-in on the current VC fileset, depending on the situation. You
1576can call @kbd{C-x v v} from a version-controlled file, or from the VC
1577Directory buffer.
1578
1579@table @kbd
1580@itemx C-x v v
1581Perform the next logical version control operation on the VC fileset.
1582@end table
1583
1584@findex vc-next-action
1585@kindex C-x v v
1586 The precise action of @kbd{C-x v v} depends on the state of the VC
1587fileset, and whether the version control system uses locking or
1588merging. This is described in detail in the subsequent sections.
1589
1590 VC filesets are the way that VC mode bridges the gap between
1591file-based and changeset-based version control systems. They are,
1592essentially, a way to pass multiple file arguments as a group to
1593version control commands. For example, on Subversion, a checkin with
1594a multi-file VC fileset becomes a joint commit, as though you had
1595typed @command{svn commit} with those file arguments at the shell
1596command line. All files in a VC fileset must be under the same
1597version control system; if they are not, Emacs signals an error when
1598you attempt to execute a command on the fileset.
1599
1600 If you are accustomed to previous versions of VC, most of the
1601changes to VC in Emacs 23 are found in VC directory mode (@pxref{VC
1602Directory Mode}). When multiple files are marked in the VC directory
1603buffer, they are treated as a VC fileset; typing @kbd{C-x v v} in the
1604VC directory buffer passes them to the version control backends as a
1605single unit. Other commands in VC directory mode now act on the VC
1606fileset, rather than the file on the current line. These changes
1607allow VC to interoperate correctly with changeset-based version
1608control systems.
1609
1610 VC filesets are distinct from the ``named filesets'' used for
1611viewing and visiting files in functional groups (@pxref{Filesets}).
1612Unlike named filesets, VC filesets are not named and don't persist
1613across sessions.
1614
1615@menu
1616* VC With A Merging VCS:: Without locking: default mode for CVS.
1617* VC With A Locking VCS:: RCS in its default mode, SCCS, and optionally CVS.
1618* Advanced C-x v v:: Advanced features available with a prefix argument.
1619* Log Buffer:: Features available in log entry buffers.
1620@end menu
1621
1622@node VC With A Merging VCS
1623@subsubsection Basic Version Control with Merging
1624
1625 When your version control system is merging-based (the default for
1626CVS and all newer version control systems), work files are always
1627writable; you need not do anything special to begin editing a file.
1628The status indicator on the mode line is @samp{-} if the file is
1629unmodified; it flips to @samp{:} as soon as you save any changes
1630(@pxref{VC Mode Line}).
1631
1632 Here is what @kbd{C-x v v} does when using a merging-based system:
1633
1634@itemize @bullet
1635@item
1636If the work file is the same as in the repository, it does nothing.
1637
1638@item
1639If you have not changed the work file, but some other user has checked
1640in changes to the repository, @kbd{C-x v v} merges those changes into
1641the work file.
1642
1643@item
1644If you have made modifications to the work file, @kbd{C-x v v}
1645attempts to check in your changes. To do this, Emacs first reads the
1646log entry for the new revision (@pxref{Log Buffer}). If some other
1647user has checked in changes to the repository since you last checked
1648it out, the checkin fails. In that case, type @kbd{C-x v v} again to
1649merge those changes into your own work file; this puts the work file
1650into a ``conflicted'' state. Type @kbd{C-x v v} to clear the
1651``conflicted'' state; VC then regards the file as up-to-date and
1652modified, and you can try to check it in again.
1653
1654To pick up any recent changes from the repository @emph{without}
1655trying to commit your own changes, type @kbd{C-x v m @key{RET}}.
1656@xref{Merging}.
1657@end itemize
1658
1659 These rules also apply when you use RCS in its ``non-locking'' mode,
1660except that changes will not be automatically merged from the
1661repository. Nothing informs you if another user has checked in
1662changes in the same file since you began editing it; when you check in
1663your revision, his changes are removed (however, they remain in the
1664repository and are thus not irrevocably lost). Therefore, you must
1665verify that the current revision is unchanged before checking in your
1666changes. In addition, locking is possible with RCS even in this mode:
1667@kbd{C-x v v} with an unmodified file locks the file, just as it does
1668with RCS in its normal locking mode (@pxref{VC With A Locking VCS}).
1669
1670@node VC With A Locking VCS
1671@subsubsection Basic Version Control with Locking
1672
1673 Under a locking-based version control system (such as SCCS, and RCS
1674in its default mode), @kbd{C-x v v} does the following:
1675
1676 @itemize @bullet
1677@item
1678If the file is not locked, @kbd{C-x v v} locks it, and makes it
1679writable so that you can change it.
1680
1681@item
1682If the file is locked by you, and contains changes, @kbd{C-x v v}
1683checks in the changes. In order to do this, it first reads the log
1684entry for the new revision. @xref{Log Buffer}.
1685
1686@item
1687If the file is locked by you, but you have not changed it since you
1688locked it, @kbd{C-x v v} releases the lock and makes the file
1689read-only again.
1690
1691@item
1692If the file is locked by some other user, @kbd{C-x v v} asks you whether
1693you want to ``steal the lock'' from that user. If you say yes, the file
1694becomes locked by you, but a message is sent to the person who had
1695formerly locked the file, to inform him of what has happened.
1696@end itemize
1697
1698 These rules also apply when you use CVS in locking mode, except
1699that there is no such thing as stealing a lock.
1700
1701@node Advanced C-x v v
1702@subsubsection Advanced Control in @kbd{C-x v v}
1703
1704@cindex revision ID to check in/out
1705 When you give a prefix argument to @code{vc-next-action} (@kbd{C-u
1706C-x v v}), it still performs the next logical version control
1707operation, but accepts additional arguments to specify precisely how
1708to do the operation.
1709
1710@itemize @bullet
1711@item
1712If the file is modified (or locked), you can specify the revision ID
1713to use for the new version that you check in. This is one way
1714to create a new branch (@pxref{Branches}).
1715
1716@item
1717If the file is not modified (and unlocked), you can specify the
1718revision to select; this lets you start working from an older
1719revision, or on another branch. If you do not enter any revision,
1720that takes you to the highest (``head'') revision on the current
1721branch; therefore @kbd{C-u C-x v v @key{RET}} is a convenient way to
1722get the latest version of a file from the repository.
1723
1724@item
1725@cindex specific version control system
1726Instead of the revision ID, you can also specify the name of a
1727version control system. This is useful when one file is being managed
1728with two version control systems at the same time
1729@iftex
1730(@pxref{Local Version Control,,,emacs-xtra, Specialized Emacs
1731Features}).
1732@end iftex
1733@ifnottex
1734(@pxref{Local Version Control}).
1735@end ifnottex
1736
1737@end itemize
1738
1739@node Log Buffer
1740@subsubsection Features of the Log Entry Buffer
1741
1742 When you check in changes, Emacs pops up a buffer called
1743@samp{*VC-Log*} for you to enter a log entry.
1744
1745 After you have finished editing the log message, type @kbd{C-c C-c}
1746to exit the buffer and commit the change.
1747
1748@findex log-edit-show-files
1749@findex log-edit-show-diff
1750 In the @samp{*VC-Log*} buffer, typing @kbd{C-c C-f}
1751(@code{log-edit-show-files}) displays a list of files in the VC
1752fileset you are committing. If you called @kbd{C-x v v} directly from
1753a work file, the VC fileset consists of that single file, so this
1754command is not very useful. If you called @kbd{C-x v v} from a VC
1755directory buffer, the VC fileset may consist of multiple files
1756(@pxref{VC Directory Mode}).
1757
1758@findex log-edit-insert-changelog
1759 Type @kbd{C-c C-d} (@code{log-edit-show-diff}) to show a ``diff'' of
1760the changes you have made (i.e., the differences between the work file
1761and the repository revision from which you started editing the file).
1762The diff is displayed in a special buffer in another window.
1763@xref{Comparing Files}.
1764
1765 If you have written an entry in the @file{ChangeLog} (@pxref{Change
1766Log}), type @kbd{C-c C-a} (@code{log-edit-insert-changelog}) to pull
1767it into the @samp{*VC-Log*} buffer. If the topmost item in the
1768@file{ChangeLog} was made under your user name on the current date,
1769this command searches that item for entries that match the file(s) to
1770be committed; if found, these entries are inserted.
1771@iftex
1772@xref{Change Logs and VC,,,emacs-xtra, Specialized Emacs Features},
1773@end iftex
1774@ifnottex
1775@xref{Change Logs and VC},
1776@end ifnottex
1777for the opposite way of working---generating ChangeLog entries from
1778the revision control log.
1779
1780 To abort a check-in, just @strong{don't} type @kbd{C-c C-c} in that
1781buffer. You can switch buffers and do other editing. As long as you
1782don't try to check in another file, the entry you were editing remains
1783in the @samp{*VC-Log*} buffer, and you can go back to that buffer at
1784any time to complete the check-in.
1785
1786 If you change several source files for the same reason, it is often
1787convenient to specify the same log entry for many of the files. (This
1788is the normal way to do things on a changeset-oriented system, where
1789comments are attached to changesets rather than the history of
1790individual files.) The most convenient way to do this is to mark all
1791the files in VC Directory Mode and check in from there; the log buffer
1792will carry the fileset information with it and do a group commit when
1793you type @kbd{C-c C-c}.
1794
1795 You can also browse the history of previous log entries to duplicate
1796a checkin comment. This can be useful when you want several files to
1797have checkin comments that vary only slightly from each other. The
1798commands @kbd{M-n}, @kbd{M-p}, @kbd{M-s} and @kbd{M-r} for doing this
1799work just like the minibuffer history commands (except that these
1800versions are used outside the minibuffer).
1801
1802@vindex vc-log-mode-hook
1803 Each time you check in a change, the log entry buffer is put into VC
1804Log Edit mode, which involves running two hooks: @code{text-mode-hook}
1805and @code{vc-log-mode-hook}. @xref{Hooks}.
1806
1807@node Old Revisions
1808@subsection Examining And Comparing Old Revisions
1809
1810 One of the convenient features of version control is the ability
1811to examine any revision of a file, or compare two revisions.
1812
1813@table @kbd
1814@item C-x v ~ @var{revision} @key{RET}
1815Examine revision @var{revision} of the visited file, in a buffer of its
1816own.
1817
1818@item C-x v =
1819Compare the buffer contents associated with the current
1820fileset with the working revision(s) from which you started editing.
1821
1822@item C-u C-x v = @key{RET} @var{oldvers} @key{RET} @var{newvers} @key{RET}
1823Compare the specified two repository revisions of the current fileset.
1824
1825@item C-x v g
1826Display an annotated version of the file: for each line, show the
1827latest revision in which it was modified.
1828@end table
1829
1830@findex vc-revision-other-window
1831@kindex C-x v ~
1832 To examine an old revision, visit the work file and type @kbd{C-x v
1833~ @var{revision} @key{RET}} (@code{vc-revision-other-window}). Here,
1834@var{revision} is either the desired revision ID (@pxref{VCS
1835Concepts}), or the name of a tag or branch
1836@iftex
1837(@pxref{Tags,,,emacs-xtra, Specialized Emacs Features}).
1838@end iftex
1839@ifnottex
1840(@pxref{Tags}).
1841@end ifnottex
1842This command puts the text of the old revision in a file named
1843@file{@var{filename}.~@var{revision}~}, and visits it in its own
1844buffer in a separate window.
1845
1846@findex vc-diff
1847@kindex C-x v =
1848 @kbd{C-x v =} (@code{vc-diff}) compares the current buffer contents
1849of each file in the current VC fileset (saving them if necessary) with
1850the repository revision from which you started editing. Note that the
1851latter may or may not be the latest revision of the file(s). The diff
1852is displayed in a special buffer in another window. @xref{Comparing
1853Files}.
1854
1855@findex vc-diff
1856@kindex C-u C-x v =
1857 To compare two arbitrary revisions of the current VC fileset, call
1858@code{vc-diff} with a prefix argument: @kbd{C-u C-x v =}. This
1859prompts for two revision IDs, using the minibuffer, and displays the
1860diff in a special buffer in another window. Instead of providing a
1861revision ID, you can give an empty input, which specifies the current
1862contents of the work file; or a tag or branch name
1863@iftex
1864(@pxref{Tags,,,emacs-xtra, Specialized Emacs Features}).
1865@end iftex
1866@ifnottex
1867(@pxref{Tags}).
1868@end ifnottex
1869If your version control system is file-based (e.g. CVS) rather than
1870changeset-based (Subversion, GNU Arch, git, Mercurial), supplying a
1871revision ID for a multi-file fileset (as opposed to a symbolic tag
1872name) is unlikely to return diffs that are connected in any meaningful
1873way.
1874
1875 If you invoke @kbd{C-x v =} or @kbd{C-u C-x v =} from a buffer that
1876is neither visiting a version-controlled file nor a VC directory
1877buffer, these commands generate a diff of all registered files in the
1878current directory and its subdirectories.
1879
1880@vindex vc-diff-switches
1881@vindex vc-rcs-diff-switches
1882 @kbd{C-x v =} works by running a variant of the @code{diff} utility
1883designed to work with the version control system in use. When you
1884invoke @code{diff} this way, in addition to the options specified by
1885@code{diff-switches} (@pxref{Comparing Files}), it receives those
1886specified by @code{vc-diff-switches}, plus those specified for the
1887specific back end by @code{vc-@var{backend}-diff-switches}. For
1888instance, when the version control back end is CVS, @code{diff} uses
1889the options in @code{vc-cvs-diff-switches}. The
1890@samp{vc@dots{}diff-switches} variables are @code{nil} by default.
1891
1892 The buffer produced by @kbd{C-x v =} supports the commands of
1893Compilation mode (@pxref{Compilation Mode}), such as @kbd{C-x `} and
1894@kbd{C-c C-c}, in both the ``old'' and ``new'' text, and they always
1895find the corresponding locations in the current work file. (Older
1896revisions are not, in general, present as files on your disk.)
1897
1898@findex vc-annotate
1899@kindex C-x v g
1900 For some back ends, you can display the file @dfn{annotated} with
1901per-line revision information, by typing @kbd{C-x v g}
1902(@code{vc-annotate}). This creates a new buffer (the ``annotate
1903buffer'') displaying the file's text, with each part colored to show
1904how old it is. Text colored red is new, blue means old, and
1905intermediate colors indicate intermediate ages. By default, the color
1906is scaled over the full range of ages, such that the oldest changes
1907are blue, and the newest changes are red.
1908
1909 When you give a prefix argument to this command, Emacs reads two
1910arguments using the minibuffer: the ID of which revision to display and
1911annotate (instead of the current file contents), and the time span in
1912days the color range should cover.
1913
1914 From the annotate buffer, these and other color scaling options are
1915available from the @samp{VC-Annotate} menu. In this buffer, you can
1916also use the following keys to browse the annotations of past revisions,
1917view diffs, or view log entries:
1918
1919@table @kbd
1920@item p
1921Annotate the previous revision, that is to say, the revision before
1922the one currently annotated. A numeric prefix argument is a repeat
1923count, so @kbd{C-u 10 p} would take you back 10 revisions.
1924
1925@item n
1926Annotate the next revision---the one after the revision currently
1927annotated. A numeric prefix argument is a repeat count.
1928
1929@item j
1930Annotate the revision indicated by the current line.
1931
1932@item a
1933Annotate the revision before the one indicated by the current line.
1934This is useful to see the state the file was in before the change on
1935the current line was made.
1936
1937@item f
1938Show in a buffer the file revision indicated by the current line.
1939
1940@item d
1941Display the diff between the current line's revision and the previous
1942revision. This is useful to see what the current line's revision
1943actually changed in the file.
1944
1945@item D
1946Display the diff between the current line's revision and the previous
1947revision for all files in the changeset (for VC systems that support
1948changesets). This is useful to see what the current line's revision
1949actually changed in the tree.
1950
1951@item l
1952Show the log of the current line's revision. This is useful to see
1953the author's description of the changes in the revision on the current
1954line.
1955
1956@item w
1957Annotate the working revision--the one you are editing. If you used
1958@kbd{p} and @kbd{n} to browse to other revisions, use this key to
1959return to your working revision.
1960
1961@item v
1962Toggle the annotation visibility. This is useful for looking just at
1963the file contents without distraction from the annotations.
1964@end table
1965
1966@node Secondary VC Commands
1967@subsection The Secondary Commands of VC
1968
1969 This section explains the secondary commands of VC.
1970
1971@menu
1972* Registering:: Putting a file under version control.
1973* VC Status:: Viewing the VC status of files.
1974* VC Undo:: Canceling changes before or after check-in.
1975@end menu
1976
1977@node Registering
1978@subsubsection Registering a File for Version Control
1979
1980@kindex C-x v i
1981@findex vc-register
1982 You can put any file under version control by simply visiting it, and
1983then typing @w{@kbd{C-x v i}} (@code{vc-register}).
1984
1985@table @kbd
1986@item C-x v i
1987Register the visited file for version control.
1988@end table
1989
1990 To register the file, Emacs must choose which version control system
1991to use for it. If the file's directory already contains files
1992registered in a version control system, Emacs uses that system. If
1993there is more than one system in use for a directory, Emacs uses the
1994one that appears first in @code{vc-handled-backends}
1995@iftex
1996(@pxref{Customizing VC,,,emacs-xtra, Specialized Emacs Features}).
1997@end iftex
1998@ifnottex
1999(@pxref{Customizing VC}).
2000@end ifnottex
2001On the other hand, if there are no files already registered, Emacs uses
2002the first system from @code{vc-handled-backends} that could register
2003the file (for example, you cannot register a file under CVS if its
2004directory is not already part of a CVS tree); with the default value
2005of @code{vc-handled-backends}, this means that Emacs uses RCS in this
2006situation.
2007
2008 If locking is in use, @kbd{C-x v i} leaves the file unlocked and
2009read-only. Type @kbd{C-x v v} if you wish to start editing it. After
2010registering a file with CVS, you must subsequently commit the initial
2011revision by typing @kbd{C-x v v}. Until you do that, the revision ID
2012appears as @samp{@@@@} in the mode line.
2013
2014@vindex vc-default-init-revision
2015@cindex initial revision ID to register
2016 The default initial revision ID for a newly registered file
2017varies by what VCS you are using; normally it will be 1.1 on VCSes
2018that use dot-pair revision IDs and 1 on VCSes that use monotonic IDs.
2019You can specify a different default by setting the variable
2020@code{vc-default-init-revision}, or you can give @kbd{C-x v i} a
2021numeric argument; then it reads the initial revision ID for this
2022particular file using the minibuffer.
2023
2024@vindex vc-initial-comment
2025 If @code{vc-initial-comment} is non-@code{nil}, @kbd{C-x v i} reads an
2026initial comment to describe the purpose of this source file. Reading
2027the initial comment works like reading a log entry (@pxref{Log Buffer}).
2028
2029@node VC Status
2030@subsubsection VC Status Commands
2031
2032@table @kbd
2033@item C-x v l
2034Display revision control state and change history.
2035@end table
2036
2037@kindex C-x v l
2038@findex vc-print-log
2039 To view the detailed revision control status and history of a file,
2040type @kbd{C-x v l} (@code{vc-print-log}). This pops up a special
2041buffer named @samp{*vc-change-log*}, in a new window, that displays
2042the history of changes to the current file, including the text of the
2043log entries. The point is centered at the revision of the file that
2044is currently being visited.
2045
2046 In the @samp{*vc-change-log*} buffer, you can use the following keys
2047to move between the logs of revisions and of files, to view past
2048revisions, to modify change comments, to view annotations and to view
2049diffs:
2050
2051@table @kbd
2052@item p
2053Move to the previous revision-item in the buffer. (Revision entries in the log
2054buffer are usually in reverse-chronological order, so the previous
2055revision-item usually corresponds to a newer revision.) A numeric
2056prefix argument is a repeat count.
2057
2058@item n
2059Move to the next revision-item (which most often corresponds to the
2060previous revision of the file). A numeric prefix argument is a repeat
2061count.
2062
2063@item P
2064Move to the log of the previous file, when the logs of multiple files
2065are in the log buffer (@pxref{VC Directory Mode}). Otherwise, just
2066move to the beginning of the log. A numeric prefix argument is a
2067repeat count, so @kbd{C-u 10 P} would move backward 10 files.
2068
2069@item N
2070Move to the log of the next file, when the logs of multiple files are
2071in the log buffer (@pxref{VC Directory Mode}). It also takes a
2072numeric prefix argument as a repeat count.
2073
2074@item a
2075Annotate the revision indicated by the current line.
2076
2077@item e
2078Modify the change comment displayed at point. Note that not all VC
2079systems support modifying change comments.
2080
2081@item f
2082Visit the revision indicated at the current line, like typing @kbd{C-x
2083v ~} and specifying this revision's ID (@pxref{Old Revisions}).
2084
2085@item d
2086Display the diff (@pxref{Comparing Files}) between the revision
2087indicated at the current line and the next earlier revision. This is
2088useful to see what actually changed in the file when the revision
2089indicated on the current line was committed.
2090
2091@item D
2092Display the changeset diff (@pxref{Comparing Files}) between the
2093revision indicated at the current line and the next earlier revision.
2094This is useful to see all the changes to all files that the revision
2095indicated on the current line did when it was committed.
2096@end table
2097
2098@node VC Undo
2099@subsubsection Undoing Version Control Actions
2100
2101@table @kbd
2102@item C-x v u
2103Revert the buffer and the file to the working revision from which you started
2104editing the file.
2105
2106@item C-x v c
2107Remove the last-entered change from the master for the visited file.
2108This undoes your last check-in.
2109@end table
2110
2111@kindex C-x v u
2112@findex vc-revert-buffer
2113 If you want to discard your current set of changes and revert to the
2114working revision from which you started editing the file, use @kbd{C-x
2115v u} (@code{vc-revert-buffer}). If the version control system is
2116locking-based, this leaves the file unlocked, and you must lock it
2117again before making new changes. @kbd{C-x v u} requires confirmation,
2118unless it sees that you haven't made any changes with respect to the
2119master copy of the working revision.
2120
2121 @kbd{C-x v u} is also the command to unlock a file if you lock it and
2122then decide not to change it.
2123
2124@kindex C-x v c
2125@findex vc-rollback
2126 To cancel a change that you already checked in, use @kbd{C-x v c}
2127(@code{vc-rollback}). This command discards all record of the most
2128recent checked-in revision, but only if your work file corresponds to
2129that revision---you cannot use @kbd{C-x v c} to cancel a revision that
2130is not the latest on its branch. Note that many version control
2131systems do not support rollback at all; this command is something of a
2132historical relic.
2133
2134@node VC Directory Mode
2135@subsection VC Directory Mode
2136
2137@kindex C-x v d
2138@findex vc-dir
2139 When you are working on a large program, it is often useful to find
2140out which files have changed within an entire directory tree, or to
2141view the status of all files under version control at once, and to
2142perform version control operations on collections of files. You can
2143use the command @kbd{C-x v d} (@code{vc-dir}) to make a directory
2144listing that includes only files relevant for version control. This
2145creates a @dfn{VC Directory buffer} and displays it in a separate
2146window.
2147
2148@cindex PCL-CVS
2149@pindex cvs
2150@cindex CVS directory mode
2151 The VC Directory buffer described here works with all the version
2152control systems that VC supports. Another more powerful facility,
2153designed specifically for CVS, is called PCL-CVS. @xref{Top, , About
2154PCL-CVS, pcl-cvs, PCL-CVS --- The Emacs Front-End to CVS}.
2155
2156 The VC Directory buffer contains a list of version-controlled files
2157in the current directory and its subdirectories. Files which are
2158up-to-date (have no local differences from the repository copy) are
2159omitted; if all files in a directory are up-to-date, the directory is
2160omitted as well. (However, the directory in which @code{vc-dir} was
2161run will always be shown as @file{./}.) There is an exception to this
2162rule: if VC mode detects that a file has changed to an up-to-date
2163state since you last looked at it, that file and its state are shown.
2164
2165 If a directory uses more that one version control system, you can
2166select which system to use for the @code{vc-dir} command by invoking
2167@code{vc-dir} with a prefix argument: @kbd{C-u C-x v d}.
2168
2169 The line for an individual file shows the version control state of
2170the file. Under RCS and SCCS, the name of the user locking the file
2171is shown; under CVS, an abbreviated version of the @samp{cvs status}
2172output is used. Here is an example using CVS:
2173
2174@smallexample
2175@group
2176 ./
2177 modified file1.c
2178 needs-update file2.c
2179 needs-merge file3.c
2180@end group
2181@end smallexample
2182
2183@noindent
2184In this example, @samp{file1.c} is modified with respect to the
2185repository, and @samp{file2.c} is not. @samp{file3.c} is modified,
2186but other changes have also been checked in to the repository---you
2187need to merge them with the work file before you can check it in.
2188
2189@vindex vc-stay-local
2190@vindex vc-cvs-stay-local
2191 In the above, if the repository were on a remote machine, VC only
2192contacts it when the variable @code{vc-stay-local} (or
2193@code{vc-cvs-stay-local}) is nil (@pxref{CVS Options}). This is
2194because access to the repository may be slow, or you may be working
2195offline and not have access to the repository at all. As a
2196consequence, VC would not be able to tell you that @samp{file3.c} is
2197in the ``merge'' state; you would learn that only when you try to
2198check-in your modified copy of the file, or use a command such as
2199@kbd{C-x v m}.
2200
2201 In practice, this is not a problem because CVS handles this case
2202consistently whenever it arises. In VC, you'll simply get prompted to
2203merge the remote changes into your work file first. The benefits of
2204less network communication usually outweigh the disadvantage of not
2205seeing remote changes immediately.
2206
2207@vindex vc-directory-exclusion-list
2208 When a VC directory displays subdirectories it omits some that
2209should never contain any files under version control. By default,
2210this includes Version Control subdirectories such as @samp{RCS} and
2211@samp{CVS}; you can customize this by setting the variable
2212@code{vc-directory-exclusion-list}.
2213
2214@menu
2215* VC Directory Commands:: Commands to use in a VC directory buffer.
2216@end menu
2217
2218@node VC Directory Commands
2219@subsubsection VC Directory Commands
2220
2221 VC Directory mode has a full set of navigation and marking commands
2222for picking out filesets. Some of these are also available in a
2223context menu invoked by the @kbd{mouse-2} button.
2224
2225 Up- and down-arrow keys move in the buffer; @kbd{n} and @kbd{p} also
2226move vertically as in other list-browsing modes. @key{SPC} and
2227@key{TAB} behave like down-arrow, and @key{BackTab} behaves like
2228up-arrow.
2229
2230 Both @kbd{C-m} and @kbd{f} visit the file on the current
2231line. @kbd{o} visits that file in another window. @kbd{q} dismisses
2232the directory buffer.
2233
2234 @kbd{x} toggles hiding of up-to-date files.
2235
2236 @kbd{m} marks the file or directory on the current line. If the
2237region is active, @kbd{m} marks all the files in the region. There
2238are some restrictions when marking: a file cannot be marked if any of
2239its parent directories are marked, and a directory cannot be marked if
2240any files in it or in its child directories are marked.
2241
2242 @kbd{M} marks all the files with the same VC state as the current
2243file if the cursor is on a file. If the cursor is on a directory, it
2244marks all child files. With a prefix argument: marks all files and
2245directories.
2246
2247 @kbd{u} unmarks the file or directory on the current line. If the
2248region is active, it unmarks all the files in the region.
2249
2250 @kbd{U} marks all the files with the same VC state as the current file
2251if the cursor is on a file. If the cursor is on a directory, it
2252unmarks all child files. With a prefix argument: unmarks all marked
2253files and directories.
2254
2255 It is possible to do search, search and replace, incremental search,
2256and incremental regexp search on multiple files. These commands will
2257work on all the marked files or the current file if nothing is marked.
2258If a directory is marked, the files in that directory shown in the VC
2259directory buffer will be used.
2260
2261 @kbd{S} searches the marked files.
2262
2263 @kbd{Q} does a query replace on the marked files.
2264
2265 @kbd{M-s a C-s} does an incremental search on the marked files.
2266
2267 @kbd{M-s a C-M-s} does an incremental search on the marked files.
2268
2269 Commands are also accessible from the VC-dir menu. Note that some VC
2270backends use the VC-dir menu to make available extra backend specific
2271commands.
2272
2273 Normal VC commands with the @kbd{C-x v} prefix work in VC directory
2274buffers. Some single-key shortcuts are available as well; @kbd{=},
2275@kbd{+}, @kbd{l}, @kbd{i}, and @kbd{v} behave as through prefixed with
2276@kbd{C-x v}.
2277
2278 The command @kbd{C-x v v} (@code{vc-next-action}) operates on all the
2279marked files, so that you can check in several files at once.
2280If the underlying VC supports atomic commits of multiple-file
2281changesets, @kbd{C-x v v} with a selected set of modified but not
2282committed files will commit all of them at once as a single changeset.
2283
2284 When @kbd{C-x v v} (@code{vc-next-action}) operates on a set of files,
2285it requires that all of those files must be either in the same state or
2286in compatible states; otherwise it will throw an error (added,
2287modified and removed states are considered compatible). Note that this
2288differs from the behavior of older versions of VC, which did not have
2289fileset operations and simply did @code{vc-next-action} on each file
2290individually.
2291
2292 If any files are in a state that calls for commit, @kbd{C-x v v} reads a
2293single log entry and uses it for the changeset as a whole. If the
2294underling VCS is file- rather than changeset-oriented, the log entry
2295will be replicated into the history of each file.
2296
2297@node Branches
2298@subsection Multiple Branches of a File
2299@cindex branch (version control)
2300@cindex trunk (version control)
2301
2302 One use of version control is to maintain multiple ``current''
2303revisions of a file. For example, you might have different revisions of a
2304program in which you are gradually adding various unfinished new
2305features. Each such independent line of development is called a
2306@dfn{branch}. VC allows you to create branches, switch between
2307different branches, and merge changes from one branch to another.
2308Please note, however, that branches are not supported for SCCS.
2309
2310 A file's main line of development is usually called the @dfn{trunk}.
2311You can create multiple branches from the trunk. How the difference
2312between trunk and branch is made visible is dependent on whether the
2313VCS uses dot-pair or monotonic version IDs.
2314
2315 In VCSes with dot-pair revision IDs, the revisions on the trunk are
2316normally IDed 1.1, 1.2, 1.3, etc. At any such revision, you can
2317start an independent branch. A branch starting at revision 1.2 would
2318have revision ID 1.2.1.1, and consecutive revisions on this branch
2319would have IDs 1.2.1.2, 1.2.1.3, 1.2.1.4, and so on. If there is
2320a second branch also starting at revision 1.2, it would consist of
2321revisions 1.2.2.1, 1.2.2.2, 1.2.2.3, etc.
2322
2323 In VCSes with monotonic revision IDs, trunk revisions are IDed as
23241, 2, 3, etc. A branch from (say) revision 2 might start with 2.1 and
2325continue through 2.2, 2.3, etc. But naming conventions for branches
2326and subbranches vary widely on these systems, and some (like
2327Mercurial) never depart from the monotonic integer sequence at all.
2328Consult the documentation of the VCS you are using.
2329
2330@cindex head revision
2331 If you omit the final component of a dot-pair revision ID, that is called a
2332@dfn{branch ID}. It refers to the highest existing revision on that
2333branch---the @dfn{head revision} of that branch. The branches in the
2334dot-pair example above have branch IDs 1.2.1 and 1.2.2.
2335
2336@menu
2337* Switching Branches:: How to get to another existing branch.
2338* Creating Branches:: How to start a new branch.
2339* Merging:: Transferring changes between branches.
2340* Multi-User Branching:: Multiple users working at multiple branches
2341 in parallel.
2342@end menu
2343
2344@node Switching Branches
2345@subsubsection Switching between Branches
2346
2347 To switch between branches, type @kbd{C-u C-x v v} and specify the
2348revision ID you want to select. On a locking-based system, this
2349version is then visited @emph{unlocked} (write-protected), so you can
2350examine it before locking it. Switching branches in this way is allowed
2351only when the file is not locked.
2352
2353 On a VCS with dot-pair IDs, you can omit the minor part, thus giving
2354only the branch ID; this takes you to the head version on the
2355chosen branch. If you only type @key{RET}, Emacs goes to the highest
2356version on the trunk.
2357
2358 After you have switched to any branch (including the main branch), you
2359stay on it for subsequent VC commands, until you explicitly select some
2360other branch.
2361
2362@node Creating Branches
2363@subsubsection Creating New Branches
2364
2365 To create a new branch from a head revision (one that is the latest in
2366the branch that contains it), first select that revision if necessary,
2367lock it with @kbd{C-x v v}, and make whatever changes you want. Then,
2368when you check in the changes, use @kbd{C-u C-x v v}. This lets you
2369specify the revision ID for the new revision. You should specify a
2370suitable branch ID for a branch starting at the current revision.
2371For example, if the current revision is 2.5, the branch ID should be
23722.5.1, 2.5.2, and so on, depending on the number of existing branches at
2373that point.
2374
2375 To create a new branch at an older revision (one that is no longer the
2376head of a branch), first select that revision (@pxref{Switching
2377Branches}). Your procedure will then differ depending on whether you
2378are using a locking or merging-based VCS.
2379
2380 On a locking VCS, you will need to lock the old revision branch with
2381@kbd{C-x v v}. You'll be asked to confirm, when you lock the old
2382revision, that you really mean to create a new branch---if you say no,
2383you'll be offered a chance to lock the latest revision instead. On
2384a merging-based VCS you will skip this step.
2385
2386 Then make your changes and type @kbd{C-x v v} again to check in a new
2387revision. This automatically creates a new branch starting from the
2388selected revision. You need not specially request a new branch, because
2389that's the only way to add a new revision at a point that is not the head
2390of a branch.
2391
2392 After the branch is created, you ``stay'' on it. That means that
2393subsequent check-ins create new revisions on that branch. To leave the
2394branch, you must explicitly select a different revision with @kbd{C-u C-x
2395v v}. To transfer changes from one branch to another, use the merge
2396command, described in the next section.
2397
2398@node Merging
2399@subsubsection Merging Branches
2400
2401@cindex merging changes
2402 When you have finished the changes on a certain branch, you will
2403often want to incorporate them into the file's main line of development
2404(the trunk). This is not a trivial operation, because development might
2405also have proceeded on the trunk, so that you must @dfn{merge} the
2406changes into a file that has already been changed otherwise. VC allows
2407you to do this (and other things) with the @code{vc-merge} command.
2408
2409@table @kbd
2410@item C-x v m (vc-merge)
2411Merge changes into the work file.
2412@end table
2413
2414@kindex C-x v m
2415@findex vc-merge
2416 @kbd{C-x v m} (@code{vc-merge}) takes a set of changes and merges it
2417into the current version of the work file. It firsts asks you in the
2418minibuffer where the changes should come from. If you just type
2419@key{RET}, Emacs merges any changes that were made on the same branch
2420since you checked the file out (we call this @dfn{merging the news}).
2421This is the common way to pick up recent changes from the repository,
2422regardless of whether you have already changed the file yourself.
2423
2424 You can also enter a branch ID or a pair of revision IDs in
2425the minibuffer. Then @kbd{C-x v m} finds the changes from that
2426branch, or the differences between the two revisions you specified, and
2427merges them into the current revision of the current file.
2428
2429 As an example, suppose that you have finished a certain feature on
2430branch 1.3.1. In the meantime, development on the trunk has proceeded
2431to revision 1.5. To merge the changes from the branch to the trunk,
2432first go to the head revision of the trunk, by typing @kbd{C-u C-x v v
2433@key{RET}}. Revision 1.5 is now current. If locking is used for the file,
2434type @kbd{C-x v v} to lock revision 1.5 so that you can change it. Next,
2435type @kbd{C-x v m 1.3.1 @key{RET}}. This takes the entire set of changes on
2436branch 1.3.1 (relative to revision 1.3, where the branch started, up to
2437the last revision on the branch) and merges it into the current revision
2438of the work file. You can now check in the changed file, thus creating
2439revision 1.6 containing the changes from the branch.
2440
2441 It is possible to do further editing after merging the branch, before
2442the next check-in. But it is usually wiser to check in the merged
2443revision, then lock it and make the further changes. This will keep
2444a better record of the history of changes.
2445
2446@cindex conflicts
2447@cindex resolving conflicts
2448 When you merge changes into a file that has itself been modified, the
2449changes might overlap. We call this situation a @dfn{conflict}, and
2450reconciling the conflicting changes is called @dfn{resolving a
2451conflict}.
2452
2453 Whenever conflicts occur during merging, VC detects them, tells you
2454about them in the echo area, and asks whether you want help in merging.
2455If you say yes, it starts an Ediff session (@pxref{Top,
2456Ediff, Ediff, ediff, The Ediff Manual}).
2457
2458 If you say no, the conflicting changes are both inserted into the
2459file, surrounded by @dfn{conflict markers}. The example below shows how
2460a conflict region looks; the file is called @samp{name} and the current
2461master file revision with user B's changes in it is 1.11.
2462
2463@c @w here is so CVS won't think this is a conflict.
2464@smallexample
2465@group
2466@w{<}<<<<<< name
2467 @var{User A's version}
2468=======
2469 @var{User B's version}
2470@w{>}>>>>>> 1.11
2471@end group
2472@end smallexample
2473
2474@cindex vc-resolve-conflicts
2475 Then you can resolve the conflicts by editing the file manually. Or
2476you can type @code{M-x vc-resolve-conflicts} after visiting the file.
2477This starts an Ediff session, as described above. Don't forget to
2478check in the merged version afterwards.
2479
2480@node Multi-User Branching
2481@subsubsection Multi-User Branching
2482
2483 It is often useful for multiple developers to work simultaneously on
2484different branches of a file. CVS and later systems allow this by
2485default; for RCS, it is possible if you create multiple source
2486directories. Each source directory should have a link named
2487@file{RCS} which points to a common directory of RCS master files.
2488Then each source directory can have its own choice of selected
2489revisions, but all share the same common RCS records.
2490
2491 This technique works reliably and automatically, provided that the
2492source files contain RCS version headers
2493@iftex
2494(@pxref{Version Headers,,,emacs-xtra, Specialized Emacs Features}).
2495@end iftex
2496@ifnottex
2497(@pxref{Version Headers}).
2498@end ifnottex
2499The headers enable Emacs to be sure, at all times, which revision
2500ID is present in the work file.
2501
2502 If the files do not have version headers, you must instead tell Emacs
2503explicitly in each session which branch you are working on. To do this,
2504first find the file, then type @kbd{C-u C-x v v} and specify the correct
2505branch ID. This ensures that Emacs knows which branch it is using
2506during this particular editing session.
2507
2508@ifnottex
2509@include vc1-xtra.texi
2510@end ifnottex
2511
2512@node Directories 1165@node Directories
2513@section File Directories 1166@section File Directories
2514 1167
@@ -2989,160 +1642,6 @@ can be set in the @samp{Archive} Customize group. However, you don't
2989need these programs to look at the archive table of contents, only to 1642need these programs to look at the archive table of contents, only to
2990extract or manipulate the subfiles in the archive. 1643extract or manipulate the subfiles in the archive.
2991 1644
2992
2993@node Document Files
2994@section Document Files
2995@cindex mode, pdf, ps, dvi
2996@cindex DocView mode
2997@cindex mode, DocView
2998@cindex document files
2999@findex doc-view-mode
3000
3001DocView mode is a document viewer for Emacs (@code{doc-view-mode}).
3002It's capable of displaying PDF, PS and DVI files inside an Emacs buffer
3003and provides some convenience features like slicing, zooming and
3004searching inside the document.
3005
3006@vindex doc-view-cache-directory
3007This is done by using @command{gs} (GhostScript) to convert the document
3008to a set of PNG images which are then displayed. In order to omit
3009double conversions of documents those images are cached in
3010@code{doc-view-cache-directory}.
3011
3012@findex doc-view-minor-mode
3013@findex doc-view-toggle-display
3014By default Emacs opens all pdf and dvi files using DocView mode. You'll
3015be greeted with a welcome screen and as soon as the first page's
3016conversion finished, it'll be displayed. PostScript files are opened
3017with @code{ps-mode} by default, but additionally
3018@code{doc-view-minor-mode} is enabled, which adds the binding @kbd{C-c
3019C-c} (@code{doc-view-toggle-display}) and toggles between the editing
3020mode (@code{ps-mode} in case of PS files, @code{fundamental-mode} in
3021case of PDF or DVI files) and DocView mode.
3022
3023@findex doc-view-enlarge
3024@findex doc-view-shrink
3025You can enlarge or shrink the document with @kbd{+}
3026(@code{doc-view-enlarge}) and @kbd{-} (@code{doc-view-shrink}).
3027
3028The DocView buffer can be buried with @kbd{q} and killed with @kbd{k}.
3029
3030@menu
3031* Navigation:: Navigation inside DocView buffers.
3032* Searching:: Searching inside documents.
3033* Slicing:: Specifing which part of pages should be displayed.
3034* Conversion:: Influencing and triggering converison.
3035@end menu
3036
3037@node Navigation
3038@subsection Navigation
3039
3040Inside DocView mode you can scroll the current page using the usual
3041Emacs movement keys, that is the arrow keys or @kbd{C-p}, @kbd{C-n},
3042@kbd{C-b} and @kbd{C-f}.
3043
3044@findex doc-view-next-page
3045@findex doc-view-previous-page
3046To go to the next page use @kbd{n}, @kbd{@key{next}} or @kbd{C-x ]}
3047(@code{doc-view-next-page}), to go to the previous page use @kbd{p},
3048@kbd{@key{prior}} or @kbd{C-x [} (@code{doc-view-previous-page}).
3049
3050@findex doc-view-scroll-up-or-next-page
3051@findex doc-view-scroll-down-or-previous-page
3052While reading a document it's convenient to scroll the current page and
3053switch to the next one if it's already scrolled to the bottom. This
3054functionality is bound to @kbd{@key{SPC}}
3055(@code{doc-view-scroll-up-or-next-page}). @kbd{@key{DEL}} will do the
3056same in the other direction
3057(@code{doc-view-scroll-down-or-previous-page}).
3058
3059@findex doc-view-first-page
3060@findex doc-view-last-page
3061To go to the first page use @kbd{M-<} (@code{doc-view-first-page}), to
3062go to the last one use @kbd{M->} (@code{doc-view-last-page}).
3063
3064@findex doc-view-goto-page
3065To jump to a page by its number use @kbd{M-g M-g} or @kbd{M-g g}
3066(@code{doc-view-goto-page}).
3067
3068@node Searching
3069@subsection Searching
3070
3071It's possible to search for a regular expression (@pxref{Regexps})
3072inside documents. In order to do that, the document file will be
3073converted to text and the search will be performed in the text file.
3074The interface to searching is inspired by @code{isearch}
3075(@pxref{Incremental Search}).
3076
3077@findex doc-view-search
3078@findex doc-view-search-backward
3079To initiate a search use @kbd{C-s} (@code{doc-view-search}) or @kbd{C-r}
3080(@code{doc-view-search-backward}). You'll be queried for a regular
3081expression and after hitting @kbd{@key{RET}} the number of matches will
3082be echoed. Navigation between the matches is done by pressing @kbd{C-s}
3083and @kbd{C-r} again.
3084
3085@findex doc-view-show-tooltip
3086Since there's no possibility to show the match inside the image itself,
3087a tooltip will be shown at the mouse position which lists all matching
3088lines of the current page. You can force the tooltip to be shown with
3089@kbd{C-t} (@code{doc-view-show-tooltip}).
3090
3091To initiate a new search call @code{doc-view-search} with a prefix
3092argument, i.e. @kbd{C-u C-s} or @kbd{C-u C-r} for a backward search.
3093
3094@node Slicing
3095@subsection Slicing
3096
3097Quite often documents have huge margins for printing. These are
3098annoying when reading the document on a computer, because they use up
3099screen space and thus can force inconvenient scrolling.
3100
3101@findex doc-view-set-slice
3102@findex doc-view-set-slice-using-mouse
3103To prevent you from that DocView lets you select the slice of the pages
3104you're interested in. To do that hit @kbd{s s}
3105(@code{doc-view-set-slice}) to enter the top left pixel position and the
3106slice's width and height. A more convenient method is provided by
3107@kbd{s m} (@code{doc-view-set-slice-using-mouse}), where you use the
3108mouse to select the slice.
3109
3110@findex doc-view-reset-slice
3111To reset the selected slice use @kbd{s r} (@code{doc-view-reset-slice}).
3112
3113@node Conversion
3114@subsection Conversion
3115
3116As said before DocView mode will automatically convert the document
3117files when visiting them unless @code{doc-view-cache-directory} already
3118contains the converted PNG images. In that case it'll use the cached
3119files.
3120
3121@findex doc-view-clear-cache
3122You can clean up the cache directory with @code{M-x
3123doc-view-clear-cache}.
3124
3125If a document has changed, it'll be converted anew when visiting it.
3126DocView recognizes documents by the md5 sum of their contents.
3127
3128@findex doc-view-kill-proc
3129@findex doc-view-kill-proc-and-buffer
3130To force a reconversion of the currently viewed document hit @kbd{r} or
3131@kbd{g} (@code{revert-buffer}). Killing the converter process
3132associated with the current buffer can be done with @kbd{K}
3133(@code{doc-view-kill-proc}). The key @kbd{k} will do the same and
3134additionally kill the DocView buffer
3135(@code{doc-view-kill-proc-and-buffer}).
3136
3137The zoom commands @kbd{+} (@code{doc-view-enlarge}) and @kbd{-}
3138(@code{doc-view-shrink}) will also reconvert the current document using
3139another resolution. The current page will be converted first.
3140
3141@vindex doc-view-resolution
3142The default resolution for conversion can be customized via the variable
3143@code{doc-view-resolution}.
3144
3145
3146@node Remote Files 1645@node Remote Files
3147@section Remote Files 1646@section Remote Files
3148 1647