diff options
| author | Chong Yidong | 2008-10-31 22:00:48 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-10-31 22:00:48 +0000 |
| commit | ccac97df942328c923699546c7c3ec5249d519a9 (patch) | |
| tree | a1207726f59d22c5910c9ee2c4ca9f1f9a61ddb0 /doc | |
| parent | 05c5ad632b7293330f3d60a93591359728471b5f (diff) | |
| download | emacs-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.texi | 1501 |
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} | |||
| 1164 | than the name you specify. Setting @code{find-file-visit-truename} also | 1162 | than the name you specify. Setting @code{find-file-visit-truename} also |
| 1165 | implies the effect of @code{find-file-existing-other-name}. | 1163 | implies 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 | ||
| 1172 | versions of a source file, storing information such as the creation | ||
| 1173 | time of each version, who created it, and a description of what was | ||
| 1174 | changed in that version. | ||
| 1175 | |||
| 1176 | The Emacs version control interface is called VC. Its commands work | ||
| 1177 | with several different version control systems; currently, it supports | ||
| 1178 | GNU Arch, Bazaar, CVS, Git, Mercurial, Monotone, RCS, SCCS/CSSC, and | ||
| 1179 | Subversion. Of these, the GNU project distributes CVS, GNU Arch, RCS, | ||
| 1180 | and Bazaar. | ||
| 1181 | |||
| 1182 | VC is enabled automatically whenever you visit a file that is | ||
| 1183 | governed by a version control system. To disable VC entirely, set the | ||
| 1184 | customizable 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, | ||
| 1213 | integrating the version control operations smoothly with editing. | ||
| 1214 | Though VC cannot completely bridge the gaps between version control | ||
| 1215 | systems with widely differing capabilities, it does provide a uniform | ||
| 1216 | interface to many version control operations. Regardless of which | ||
| 1217 | version control system is in use, you will be able to do basic | ||
| 1218 | operations in much the same way. | ||
| 1219 | |||
| 1220 | This section provides a general overview of version control, and | ||
| 1221 | describes the version control systems that VC supports. You can skip | ||
| 1222 | this section if you are already familiar with the version control system | ||
| 1223 | you 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 | ||
| 1236 | capabilities: | ||
| 1237 | |||
| 1238 | @itemize @bullet | ||
| 1239 | @item | ||
| 1240 | @dfn{Reversibility}: the ability to back up to a previous state if you | ||
| 1241 | discover 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 | ||
| 1245 | collection of files knowing that conflicting modifications can be | ||
| 1246 | detected and resolved. | ||
| 1247 | |||
| 1248 | @item | ||
| 1249 | @dfn{History}: the ability to attach historical data to your data, | ||
| 1250 | such as explanatory comments about the intention behind each change to | ||
| 1251 | it. Even for a programmer working solo, change histories are an | ||
| 1252 | important aid to memory; for a multi-person project, they are a | ||
| 1253 | vitally 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 | ||
| 1267 | SCCS was the first version control system ever built, and was long ago | ||
| 1268 | superseded by more advanced ones. VC compensates for certain features | ||
| 1269 | missing in SCCS (e.g., tag names for releases) by implementing them | ||
| 1270 | itself. Other VC features, such as multiple branches, are simply | ||
| 1271 | unavailable. Since SCCS is non-free, we recommend avoiding it. | ||
| 1272 | |||
| 1273 | @cindex CSSC | ||
| 1274 | @item | ||
| 1275 | CSSC is a free replacement for SCCS. You should use CSSC only if, for | ||
| 1276 | some reason, you cannot use a more recent and better-designed version | ||
| 1277 | control system. | ||
| 1278 | |||
| 1279 | @cindex RCS | ||
| 1280 | @item | ||
| 1281 | RCS is the free version control system around which VC was initially | ||
| 1282 | built. Almost everything you can do with RCS can be done through VC. | ||
| 1283 | However, you cannot use RCS over the network, and it only works at the | ||
| 1284 | level of individual files rather than projects. | ||
| 1285 | |||
| 1286 | @cindex CVS | ||
| 1287 | @item | ||
| 1288 | CVS is the free version control system that was, until recently (circa | ||
| 1289 | 2008), used by the majority of free software projects. Nowadays, it | ||
| 1290 | is slowly being superseded by newer systems. CVS allows concurrent | ||
| 1291 | multi-user development either locally or over the network. It lacks | ||
| 1292 | support for atomic commits or file moving/renaming. VC supports all | ||
| 1293 | basic editing operations under CVS. For some less common tasks, you | ||
| 1294 | still need to call CVS from the command line. Note also that before | ||
| 1295 | using CVS you must set up a repository, which is a subject too complex | ||
| 1296 | to treat here. | ||
| 1297 | |||
| 1298 | @cindex SVN | ||
| 1299 | @cindex Subversion | ||
| 1300 | @item | ||
| 1301 | Subversion (SVN) is a free version control system designed to be | ||
| 1302 | similar to CVS but without its problems. It supports atomic commits | ||
| 1303 | of filesets, and versioning of directories, symbolic links, meta-data, | ||
| 1304 | renames, copies, and deletes. | ||
| 1305 | |||
| 1306 | @cindex GNU Arch | ||
| 1307 | @cindex Arch | ||
| 1308 | @item | ||
| 1309 | GNU Arch is a version control system designed for distributed work. | ||
| 1310 | It differs in many ways from older systems like CVS and RCS. It | ||
| 1311 | provides different methods for interoperating between users, support | ||
| 1312 | for offline operations, and good branching and merging features. It | ||
| 1313 | also supports atomic commits of filesets and file moving/renaming. VC | ||
| 1314 | does not support all operations provided by GNU Arch, so you must | ||
| 1315 | sometimes invoke it from the command line. | ||
| 1316 | |||
| 1317 | @cindex git | ||
| 1318 | @item | ||
| 1319 | Git is a distributed version control system invented by Linus Torvalds to support | ||
| 1320 | Linux kernel development. It supports atomic commits of filesets and | ||
| 1321 | file moving/renaming. One significant feature of git is that it | ||
| 1322 | largely abolishes the notion of a single centralized repository; | ||
| 1323 | instead, each working copy of a git project is its own repository and | ||
| 1324 | coordination is done through repository-sync operations. VC supports | ||
| 1325 | most git operations, with the exception of news merges and repository | ||
| 1326 | syncing; these must be done from the command line. | ||
| 1327 | |||
| 1328 | @cindex hg | ||
| 1329 | @cindex Mercurial | ||
| 1330 | @item | ||
| 1331 | Mercurial (hg) is a distributed version control system broadly | ||
| 1332 | resembling GNU Arch and git, with atomic fileset commits and file | ||
| 1333 | moving/renaming. Like git, it is fully decentralized. VC supports | ||
| 1334 | most Mercurial commands, with the exception of repository sync | ||
| 1335 | operations; this needs to be done from the command line. | ||
| 1336 | |||
| 1337 | @cindex bzr | ||
| 1338 | @cindex Bazaar | ||
| 1339 | @item | ||
| 1340 | Bazaar (bzr) is a distributed version control system that supports both | ||
| 1341 | repository-based and distributed versioning, with atomic fileset | ||
| 1342 | commits and file moving/renaming. VC supports most basic editing | ||
| 1343 | operations under Bazaar. | ||
| 1344 | @end itemize | ||
| 1345 | |||
| 1346 | Previous versions of VC supported a version control system known as | ||
| 1347 | Meta-CVS. This support has been dropped because of limited interest | ||
| 1348 | from 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 | ||
| 1358 | change history---enough to reconstruct the current version or any | ||
| 1359 | earlier version. The repository also contains other information, such | ||
| 1360 | as @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 | ||
| 1365 | file}. You edit the work file and make changes in it, as you would | ||
| 1366 | with 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 | ||
| 1368 | the 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}. | ||
| 1373 | The history of a file is a sequence of revisions. Each revisions is | ||
| 1374 | named by a @dfn{revision ID}. The format of the revision ID depends | ||
| 1375 | on the version control system; in the simplest case, it is just an | ||
| 1376 | integer. | ||
| 1377 | |||
| 1378 | To go beyond these basic concepts, you will need to understand three | ||
| 1379 | ways in which version control systems can differ from each other. | ||
| 1380 | They can be locking-based or merging-based; they can be file-based or | ||
| 1381 | changeset-based; and they can be centralized or decentralized. VC | ||
| 1382 | handles all these choices, but they lead to differing behaviors which | ||
| 1383 | you 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 | ||
| 1387 | between users who want to change the same file. There are two ways to | ||
| 1388 | do this: merging and locking. | ||
| 1389 | |||
| 1390 | In a version control system that uses merging, each user may check | ||
| 1391 | out 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 | ||
| 1393 | been checked in, with the latest changes that others have checked into | ||
| 1394 | the repository. | ||
| 1395 | |||
| 1396 | Older version control systems use a @dfn{locking} scheme instead. | ||
| 1397 | Here, work files are normally read-only. To edit a file, you ask the | ||
| 1398 | version control system to make it writable for you by @dfn{locking} | ||
| 1399 | it; only one user can lock a given file at any given time. This | ||
| 1400 | procedure is analogous to, but different from, the locking that Emacs | ||
| 1401 | uses to detect simultaneous editing of ordinary files | ||
| 1402 | (@pxref{Interlocking}). When you check in your changes, that unlocks | ||
| 1403 | the file, and the work file becomes read-only again. Other users may | ||
| 1404 | then lock the file to make their own changes. | ||
| 1405 | |||
| 1406 | Both locking and merging systems can have problems when multiple | ||
| 1407 | users try to modify the same file at the same time. Locking systems | ||
| 1408 | have @dfn{lock conflicts}; a user may try to check a file out and be | ||
| 1409 | unable to because it is locked. In merging systems, @dfn{merge | ||
| 1410 | conflicts} happen when you check in a change to a file that conflicts | ||
| 1411 | with a change checked in by someone else after your checkout. Both | ||
| 1412 | kinds of conflict have to be resolved by human judgment and | ||
| 1413 | communication. | ||
| 1414 | |||
| 1415 | SCCS always uses locking. RCS is lock-based by default but can be | ||
| 1416 | told to operate in a merging style. CVS and Subversion are | ||
| 1417 | merge-based by default but can be told to operate in a locking mode. | ||
| 1418 | Distributed version control systems, such as GNU Arch, git, and | ||
| 1419 | Mercurial, are exclusively merging-based. Experience has shown that | ||
| 1420 | merging is superior to locking, both in convenience to developers and | ||
| 1421 | in minimizing the number and severity of conflicts that actually | ||
| 1422 | occur. Sometimes, however, newer version control systems may have | ||
| 1423 | locks retrofitted onto them for reasons having nothing to do with | ||
| 1424 | technology@footnote{Usually the control-freak instincts of managers.}. | ||
| 1425 | |||
| 1426 | VC mode supports both locking and merging version control and tries | ||
| 1427 | to 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 | ||
| 1431 | control operations are @dfn{file-based}: each file has its own comment | ||
| 1432 | and revision history separate from that of all other files in the | ||
| 1433 | system. Later systems, beginning with Subversion, are | ||
| 1434 | @dfn{changeset-based}: a checkin may include changes to several files, | ||
| 1435 | and the entire set of changes is treated as a unit by the system. Any | ||
| 1436 | comment associated with the change does not belong to a single file, | ||
| 1437 | but to the changeset itself. | ||
| 1438 | |||
| 1439 | Changeset-based version control is more flexible and powerful than | ||
| 1440 | file-based version control; usually, when a change to multiple files | ||
| 1441 | has to be reversed, it's good to be able to easily identify and remove | ||
| 1442 | all of it. But it took some years for designers to figure that out, | ||
| 1443 | and while file-based systems are passing out of use, there are lots of | ||
| 1444 | legacy 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 | ||
| 1447 | unhappy results when it was used to drive changeset-based | ||
| 1448 | systems---the Subversion support, for example, used to break up | ||
| 1449 | changesets into multiple per-file commits. This has been fixed, but | ||
| 1450 | it has left a mark in VC's terminology. The terms ``checkin'' and | ||
| 1451 | ``checkout'' are associated with file-based and locking-based systems | ||
| 1452 | and 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 | ||
| 1458 | used by all developers. SCCS, RCS, CVS, and Subversion share this | ||
| 1459 | kind of model. One problem with this approach is that a single | ||
| 1460 | repository is a single point of failure---if the repository server is | ||
| 1461 | down, all work stops. | ||
| 1462 | |||
| 1463 | Newer version control systems like GNU Arch, git, Mercurial, and | ||
| 1464 | Bazaar are @dfn{decentralized}. A project may have several different | ||
| 1465 | repositories, and these systems support a sort of super-merge between | ||
| 1466 | repositories that tries to reconcile their change histories. At the | ||
| 1467 | limit, each developer has his/her own repository, and repository | ||
| 1468 | merges replace checkin/commit operations. | ||
| 1469 | |||
| 1470 | VC's job is to help you manage the traffic between your personal | ||
| 1471 | workfiles and a repository. Whether that repository is a single | ||
| 1472 | master or one of a network of peer repositories is not something VC | ||
| 1473 | has to care about. Thus, the difference between a centralized and a | ||
| 1474 | decentralized 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 | ||
| 1483 | for changes. One is the log maintained by the version control system: | ||
| 1484 | each time you check in a change, you fill out a @dfn{log entry} for | ||
| 1485 | the change (@pxref{Log Buffer}). This is called the @dfn{version | ||
| 1486 | control log}. | ||
| 1487 | |||
| 1488 | The other kind of log is the file @file{ChangeLog} (@pxref{Change | ||
| 1489 | Log}). It provides a chronological record of all changes to a large | ||
| 1490 | portion of a program---typically one directory and its subdirectories. | ||
| 1491 | A small program would use one @file{ChangeLog} file; a large program | ||
| 1492 | may 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 | ||
| 1496 | from file-based version control. Changelogs are a GNU convention, | ||
| 1497 | later more widely adopted, that help developers to get a | ||
| 1498 | changeset-based view of a project even when its version control system | ||
| 1499 | has that information split up in multiple file-based logs. | ||
| 1500 | |||
| 1501 | Changeset-based version systems, on the other hand, often maintain a | ||
| 1502 | changeset-based modification log for the entire system that makes | ||
| 1503 | ChangeLogs somewhat redundant. One advantage that ChangeLogs retain | ||
| 1504 | is that it is sometimes useful to be able to view the transaction | ||
| 1505 | history of a single directory separately from those of other | ||
| 1506 | directories. | ||
| 1507 | |||
| 1508 | A project maintained with version control can use just the version | ||
| 1509 | control log, or it can use both kinds of logs. It can handle some | ||
| 1510 | files one way and some files the other way. Each project has its | ||
| 1511 | policy, which you should follow. | ||
| 1512 | |||
| 1513 | When the policy is to use both, you typically want to write an entry | ||
| 1514 | for each change just once, then put it into both logs. You can write | ||
| 1515 | the 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 | ||
| 1517 | you can write the entry in the log buffer while checking in the | ||
| 1518 | change, 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 | ||
| 1531 | this on the mode line. For example, @samp{RCS-1.3} says that RCS is | ||
| 1532 | used for that file, and the current version is 1.3. | ||
| 1533 | |||
| 1534 | The character between the back-end name and the revision ID | ||
| 1535 | indicates the version control status of the file. @samp{-} means that | ||
| 1536 | the work file is not locked (if locking is in use), or not modified (if | ||
| 1537 | locking is not in use). @samp{:} indicates that the file is locked, or | ||
| 1538 | that it is modified. If the file is locked by some other user (for | ||
| 1539 | instance, @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 | ||
| 1542 | indicator to pop up a ``tool-tip'', which displays a more verbose | ||
| 1543 | description of the version control status. Pressing @kbd{Mouse-1} | ||
| 1544 | over the indicator pops up a menu of VC commands. This menu is | ||
| 1545 | identical to the @samp{Version Control} menu item, which can be found | ||
| 1546 | in 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 | ||
| 1550 | under version control, it updates the version control information in | ||
| 1551 | the mode line. However, Auto Revert mode may not properly update this | ||
| 1552 | information if the version control status changes without changes to | ||
| 1553 | the 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 | ||
| 1555 | the version control status information every | ||
| 1556 | @code{auto-revert-interval} seconds, even if the work file itself is | ||
| 1557 | unchanged. The resulting CPU usage depends on the version control | ||
| 1558 | system, 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 | ||
| 1565 | group of one or more files that are treated as a unit, for the | ||
| 1566 | purposes of version control. | ||
| 1567 | |||
| 1568 | If you are visiting a version-controlled file in the current | ||
| 1569 | buffer, the VC fileset is simply that one file. If you are visiting a | ||
| 1570 | VC directory buffer, and some files in it are marked, the VC fileset | ||
| 1571 | consists 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 | ||
| 1575 | check-in on the current VC fileset, depending on the situation. You | ||
| 1576 | can call @kbd{C-x v v} from a version-controlled file, or from the VC | ||
| 1577 | Directory buffer. | ||
| 1578 | |||
| 1579 | @table @kbd | ||
| 1580 | @itemx C-x v v | ||
| 1581 | Perform 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 | ||
| 1587 | fileset, and whether the version control system uses locking or | ||
| 1588 | merging. This is described in detail in the subsequent sections. | ||
| 1589 | |||
| 1590 | VC filesets are the way that VC mode bridges the gap between | ||
| 1591 | file-based and changeset-based version control systems. They are, | ||
| 1592 | essentially, a way to pass multiple file arguments as a group to | ||
| 1593 | version control commands. For example, on Subversion, a checkin with | ||
| 1594 | a multi-file VC fileset becomes a joint commit, as though you had | ||
| 1595 | typed @command{svn commit} with those file arguments at the shell | ||
| 1596 | command line. All files in a VC fileset must be under the same | ||
| 1597 | version control system; if they are not, Emacs signals an error when | ||
| 1598 | you attempt to execute a command on the fileset. | ||
| 1599 | |||
| 1600 | If you are accustomed to previous versions of VC, most of the | ||
| 1601 | changes to VC in Emacs 23 are found in VC directory mode (@pxref{VC | ||
| 1602 | Directory Mode}). When multiple files are marked in the VC directory | ||
| 1603 | buffer, they are treated as a VC fileset; typing @kbd{C-x v v} in the | ||
| 1604 | VC directory buffer passes them to the version control backends as a | ||
| 1605 | single unit. Other commands in VC directory mode now act on the VC | ||
| 1606 | fileset, rather than the file on the current line. These changes | ||
| 1607 | allow VC to interoperate correctly with changeset-based version | ||
| 1608 | control systems. | ||
| 1609 | |||
| 1610 | VC filesets are distinct from the ``named filesets'' used for | ||
| 1611 | viewing and visiting files in functional groups (@pxref{Filesets}). | ||
| 1612 | Unlike named filesets, VC filesets are not named and don't persist | ||
| 1613 | across 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 | ||
| 1626 | CVS and all newer version control systems), work files are always | ||
| 1627 | writable; you need not do anything special to begin editing a file. | ||
| 1628 | The status indicator on the mode line is @samp{-} if the file is | ||
| 1629 | unmodified; 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 | ||
| 1636 | If the work file is the same as in the repository, it does nothing. | ||
| 1637 | |||
| 1638 | @item | ||
| 1639 | If you have not changed the work file, but some other user has checked | ||
| 1640 | in changes to the repository, @kbd{C-x v v} merges those changes into | ||
| 1641 | the work file. | ||
| 1642 | |||
| 1643 | @item | ||
| 1644 | If you have made modifications to the work file, @kbd{C-x v v} | ||
| 1645 | attempts to check in your changes. To do this, Emacs first reads the | ||
| 1646 | log entry for the new revision (@pxref{Log Buffer}). If some other | ||
| 1647 | user has checked in changes to the repository since you last checked | ||
| 1648 | it out, the checkin fails. In that case, type @kbd{C-x v v} again to | ||
| 1649 | merge those changes into your own work file; this puts the work file | ||
| 1650 | into 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 | ||
| 1652 | modified, and you can try to check it in again. | ||
| 1653 | |||
| 1654 | To pick up any recent changes from the repository @emph{without} | ||
| 1655 | trying 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, | ||
| 1660 | except that changes will not be automatically merged from the | ||
| 1661 | repository. Nothing informs you if another user has checked in | ||
| 1662 | changes in the same file since you began editing it; when you check in | ||
| 1663 | your revision, his changes are removed (however, they remain in the | ||
| 1664 | repository and are thus not irrevocably lost). Therefore, you must | ||
| 1665 | verify that the current revision is unchanged before checking in your | ||
| 1666 | changes. 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 | ||
| 1668 | with 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 | ||
| 1674 | in its default mode), @kbd{C-x v v} does the following: | ||
| 1675 | |||
| 1676 | @itemize @bullet | ||
| 1677 | @item | ||
| 1678 | If the file is not locked, @kbd{C-x v v} locks it, and makes it | ||
| 1679 | writable so that you can change it. | ||
| 1680 | |||
| 1681 | @item | ||
| 1682 | If the file is locked by you, and contains changes, @kbd{C-x v v} | ||
| 1683 | checks in the changes. In order to do this, it first reads the log | ||
| 1684 | entry for the new revision. @xref{Log Buffer}. | ||
| 1685 | |||
| 1686 | @item | ||
| 1687 | If the file is locked by you, but you have not changed it since you | ||
| 1688 | locked it, @kbd{C-x v v} releases the lock and makes the file | ||
| 1689 | read-only again. | ||
| 1690 | |||
| 1691 | @item | ||
| 1692 | If the file is locked by some other user, @kbd{C-x v v} asks you whether | ||
| 1693 | you want to ``steal the lock'' from that user. If you say yes, the file | ||
| 1694 | becomes locked by you, but a message is sent to the person who had | ||
| 1695 | formerly 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 | ||
| 1699 | that 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 | ||
| 1706 | C-x v v}), it still performs the next logical version control | ||
| 1707 | operation, but accepts additional arguments to specify precisely how | ||
| 1708 | to do the operation. | ||
| 1709 | |||
| 1710 | @itemize @bullet | ||
| 1711 | @item | ||
| 1712 | If the file is modified (or locked), you can specify the revision ID | ||
| 1713 | to use for the new version that you check in. This is one way | ||
| 1714 | to create a new branch (@pxref{Branches}). | ||
| 1715 | |||
| 1716 | @item | ||
| 1717 | If the file is not modified (and unlocked), you can specify the | ||
| 1718 | revision to select; this lets you start working from an older | ||
| 1719 | revision, or on another branch. If you do not enter any revision, | ||
| 1720 | that takes you to the highest (``head'') revision on the current | ||
| 1721 | branch; therefore @kbd{C-u C-x v v @key{RET}} is a convenient way to | ||
| 1722 | get the latest version of a file from the repository. | ||
| 1723 | |||
| 1724 | @item | ||
| 1725 | @cindex specific version control system | ||
| 1726 | Instead of the revision ID, you can also specify the name of a | ||
| 1727 | version control system. This is useful when one file is being managed | ||
| 1728 | with two version control systems at the same time | ||
| 1729 | @iftex | ||
| 1730 | (@pxref{Local Version Control,,,emacs-xtra, Specialized Emacs | ||
| 1731 | Features}). | ||
| 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} | ||
| 1746 | to 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 | ||
| 1752 | fileset you are committing. If you called @kbd{C-x v v} directly from | ||
| 1753 | a work file, the VC fileset consists of that single file, so this | ||
| 1754 | command is not very useful. If you called @kbd{C-x v v} from a VC | ||
| 1755 | directory 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 | ||
| 1760 | the changes you have made (i.e., the differences between the work file | ||
| 1761 | and the repository revision from which you started editing the file). | ||
| 1762 | The 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 | ||
| 1766 | Log}), type @kbd{C-c C-a} (@code{log-edit-insert-changelog}) to pull | ||
| 1767 | it 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, | ||
| 1769 | this command searches that item for entries that match the file(s) to | ||
| 1770 | be 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 | ||
| 1777 | for the opposite way of working---generating ChangeLog entries from | ||
| 1778 | the revision control log. | ||
| 1779 | |||
| 1780 | To abort a check-in, just @strong{don't} type @kbd{C-c C-c} in that | ||
| 1781 | buffer. You can switch buffers and do other editing. As long as you | ||
| 1782 | don't try to check in another file, the entry you were editing remains | ||
| 1783 | in the @samp{*VC-Log*} buffer, and you can go back to that buffer at | ||
| 1784 | any time to complete the check-in. | ||
| 1785 | |||
| 1786 | If you change several source files for the same reason, it is often | ||
| 1787 | convenient to specify the same log entry for many of the files. (This | ||
| 1788 | is the normal way to do things on a changeset-oriented system, where | ||
| 1789 | comments are attached to changesets rather than the history of | ||
| 1790 | individual files.) The most convenient way to do this is to mark all | ||
| 1791 | the files in VC Directory Mode and check in from there; the log buffer | ||
| 1792 | will carry the fileset information with it and do a group commit when | ||
| 1793 | you type @kbd{C-c C-c}. | ||
| 1794 | |||
| 1795 | You can also browse the history of previous log entries to duplicate | ||
| 1796 | a checkin comment. This can be useful when you want several files to | ||
| 1797 | have checkin comments that vary only slightly from each other. The | ||
| 1798 | commands @kbd{M-n}, @kbd{M-p}, @kbd{M-s} and @kbd{M-r} for doing this | ||
| 1799 | work just like the minibuffer history commands (except that these | ||
| 1800 | versions 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 | ||
| 1804 | Log Edit mode, which involves running two hooks: @code{text-mode-hook} | ||
| 1805 | and @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 | ||
| 1811 | to examine any revision of a file, or compare two revisions. | ||
| 1812 | |||
| 1813 | @table @kbd | ||
| 1814 | @item C-x v ~ @var{revision} @key{RET} | ||
| 1815 | Examine revision @var{revision} of the visited file, in a buffer of its | ||
| 1816 | own. | ||
| 1817 | |||
| 1818 | @item C-x v = | ||
| 1819 | Compare the buffer contents associated with the current | ||
| 1820 | fileset 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} | ||
| 1823 | Compare the specified two repository revisions of the current fileset. | ||
| 1824 | |||
| 1825 | @item C-x v g | ||
| 1826 | Display an annotated version of the file: for each line, show the | ||
| 1827 | latest 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 | ||
| 1835 | Concepts}), 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 | ||
| 1842 | This command puts the text of the old revision in a file named | ||
| 1843 | @file{@var{filename}.~@var{revision}~}, and visits it in its own | ||
| 1844 | buffer 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 | ||
| 1849 | of each file in the current VC fileset (saving them if necessary) with | ||
| 1850 | the repository revision from which you started editing. Note that the | ||
| 1851 | latter may or may not be the latest revision of the file(s). The diff | ||
| 1852 | is displayed in a special buffer in another window. @xref{Comparing | ||
| 1853 | Files}. | ||
| 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 | ||
| 1859 | prompts for two revision IDs, using the minibuffer, and displays the | ||
| 1860 | diff in a special buffer in another window. Instead of providing a | ||
| 1861 | revision ID, you can give an empty input, which specifies the current | ||
| 1862 | contents 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 | ||
| 1869 | If your version control system is file-based (e.g. CVS) rather than | ||
| 1870 | changeset-based (Subversion, GNU Arch, git, Mercurial), supplying a | ||
| 1871 | revision ID for a multi-file fileset (as opposed to a symbolic tag | ||
| 1872 | name) is unlikely to return diffs that are connected in any meaningful | ||
| 1873 | way. | ||
| 1874 | |||
| 1875 | If you invoke @kbd{C-x v =} or @kbd{C-u C-x v =} from a buffer that | ||
| 1876 | is neither visiting a version-controlled file nor a VC directory | ||
| 1877 | buffer, these commands generate a diff of all registered files in the | ||
| 1878 | current 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 | ||
| 1883 | designed to work with the version control system in use. When you | ||
| 1884 | invoke @code{diff} this way, in addition to the options specified by | ||
| 1885 | @code{diff-switches} (@pxref{Comparing Files}), it receives those | ||
| 1886 | specified by @code{vc-diff-switches}, plus those specified for the | ||
| 1887 | specific back end by @code{vc-@var{backend}-diff-switches}. For | ||
| 1888 | instance, when the version control back end is CVS, @code{diff} uses | ||
| 1889 | the 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 | ||
| 1893 | Compilation 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 | ||
| 1895 | find the corresponding locations in the current work file. (Older | ||
| 1896 | revisions 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 | ||
| 1901 | per-line revision information, by typing @kbd{C-x v g} | ||
| 1902 | (@code{vc-annotate}). This creates a new buffer (the ``annotate | ||
| 1903 | buffer'') displaying the file's text, with each part colored to show | ||
| 1904 | how old it is. Text colored red is new, blue means old, and | ||
| 1905 | intermediate colors indicate intermediate ages. By default, the color | ||
| 1906 | is scaled over the full range of ages, such that the oldest changes | ||
| 1907 | are blue, and the newest changes are red. | ||
| 1908 | |||
| 1909 | When you give a prefix argument to this command, Emacs reads two | ||
| 1910 | arguments using the minibuffer: the ID of which revision to display and | ||
| 1911 | annotate (instead of the current file contents), and the time span in | ||
| 1912 | days the color range should cover. | ||
| 1913 | |||
| 1914 | From the annotate buffer, these and other color scaling options are | ||
| 1915 | available from the @samp{VC-Annotate} menu. In this buffer, you can | ||
| 1916 | also use the following keys to browse the annotations of past revisions, | ||
| 1917 | view diffs, or view log entries: | ||
| 1918 | |||
| 1919 | @table @kbd | ||
| 1920 | @item p | ||
| 1921 | Annotate the previous revision, that is to say, the revision before | ||
| 1922 | the one currently annotated. A numeric prefix argument is a repeat | ||
| 1923 | count, so @kbd{C-u 10 p} would take you back 10 revisions. | ||
| 1924 | |||
| 1925 | @item n | ||
| 1926 | Annotate the next revision---the one after the revision currently | ||
| 1927 | annotated. A numeric prefix argument is a repeat count. | ||
| 1928 | |||
| 1929 | @item j | ||
| 1930 | Annotate the revision indicated by the current line. | ||
| 1931 | |||
| 1932 | @item a | ||
| 1933 | Annotate the revision before the one indicated by the current line. | ||
| 1934 | This is useful to see the state the file was in before the change on | ||
| 1935 | the current line was made. | ||
| 1936 | |||
| 1937 | @item f | ||
| 1938 | Show in a buffer the file revision indicated by the current line. | ||
| 1939 | |||
| 1940 | @item d | ||
| 1941 | Display the diff between the current line's revision and the previous | ||
| 1942 | revision. This is useful to see what the current line's revision | ||
| 1943 | actually changed in the file. | ||
| 1944 | |||
| 1945 | @item D | ||
| 1946 | Display the diff between the current line's revision and the previous | ||
| 1947 | revision for all files in the changeset (for VC systems that support | ||
| 1948 | changesets). This is useful to see what the current line's revision | ||
| 1949 | actually changed in the tree. | ||
| 1950 | |||
| 1951 | @item l | ||
| 1952 | Show the log of the current line's revision. This is useful to see | ||
| 1953 | the author's description of the changes in the revision on the current | ||
| 1954 | line. | ||
| 1955 | |||
| 1956 | @item w | ||
| 1957 | Annotate 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 | ||
| 1959 | return to your working revision. | ||
| 1960 | |||
| 1961 | @item v | ||
| 1962 | Toggle the annotation visibility. This is useful for looking just at | ||
| 1963 | the 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 | ||
| 1983 | then typing @w{@kbd{C-x v i}} (@code{vc-register}). | ||
| 1984 | |||
| 1985 | @table @kbd | ||
| 1986 | @item C-x v i | ||
| 1987 | Register the visited file for version control. | ||
| 1988 | @end table | ||
| 1989 | |||
| 1990 | To register the file, Emacs must choose which version control system | ||
| 1991 | to use for it. If the file's directory already contains files | ||
| 1992 | registered in a version control system, Emacs uses that system. If | ||
| 1993 | there is more than one system in use for a directory, Emacs uses the | ||
| 1994 | one 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 | ||
| 2001 | On the other hand, if there are no files already registered, Emacs uses | ||
| 2002 | the first system from @code{vc-handled-backends} that could register | ||
| 2003 | the file (for example, you cannot register a file under CVS if its | ||
| 2004 | directory is not already part of a CVS tree); with the default value | ||
| 2005 | of @code{vc-handled-backends}, this means that Emacs uses RCS in this | ||
| 2006 | situation. | ||
| 2007 | |||
| 2008 | If locking is in use, @kbd{C-x v i} leaves the file unlocked and | ||
| 2009 | read-only. Type @kbd{C-x v v} if you wish to start editing it. After | ||
| 2010 | registering a file with CVS, you must subsequently commit the initial | ||
| 2011 | revision by typing @kbd{C-x v v}. Until you do that, the revision ID | ||
| 2012 | appears 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 | ||
| 2017 | varies by what VCS you are using; normally it will be 1.1 on VCSes | ||
| 2018 | that use dot-pair revision IDs and 1 on VCSes that use monotonic IDs. | ||
| 2019 | You 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 | ||
| 2021 | numeric argument; then it reads the initial revision ID for this | ||
| 2022 | particular 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 | ||
| 2026 | initial comment to describe the purpose of this source file. Reading | ||
| 2027 | the 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 | ||
| 2034 | Display 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, | ||
| 2040 | type @kbd{C-x v l} (@code{vc-print-log}). This pops up a special | ||
| 2041 | buffer named @samp{*vc-change-log*}, in a new window, that displays | ||
| 2042 | the history of changes to the current file, including the text of the | ||
| 2043 | log entries. The point is centered at the revision of the file that | ||
| 2044 | is currently being visited. | ||
| 2045 | |||
| 2046 | In the @samp{*vc-change-log*} buffer, you can use the following keys | ||
| 2047 | to move between the logs of revisions and of files, to view past | ||
| 2048 | revisions, to modify change comments, to view annotations and to view | ||
| 2049 | diffs: | ||
| 2050 | |||
| 2051 | @table @kbd | ||
| 2052 | @item p | ||
| 2053 | Move to the previous revision-item in the buffer. (Revision entries in the log | ||
| 2054 | buffer are usually in reverse-chronological order, so the previous | ||
| 2055 | revision-item usually corresponds to a newer revision.) A numeric | ||
| 2056 | prefix argument is a repeat count. | ||
| 2057 | |||
| 2058 | @item n | ||
| 2059 | Move to the next revision-item (which most often corresponds to the | ||
| 2060 | previous revision of the file). A numeric prefix argument is a repeat | ||
| 2061 | count. | ||
| 2062 | |||
| 2063 | @item P | ||
| 2064 | Move to the log of the previous file, when the logs of multiple files | ||
| 2065 | are in the log buffer (@pxref{VC Directory Mode}). Otherwise, just | ||
| 2066 | move to the beginning of the log. A numeric prefix argument is a | ||
| 2067 | repeat count, so @kbd{C-u 10 P} would move backward 10 files. | ||
| 2068 | |||
| 2069 | @item N | ||
| 2070 | Move to the log of the next file, when the logs of multiple files are | ||
| 2071 | in the log buffer (@pxref{VC Directory Mode}). It also takes a | ||
| 2072 | numeric prefix argument as a repeat count. | ||
| 2073 | |||
| 2074 | @item a | ||
| 2075 | Annotate the revision indicated by the current line. | ||
| 2076 | |||
| 2077 | @item e | ||
| 2078 | Modify the change comment displayed at point. Note that not all VC | ||
| 2079 | systems support modifying change comments. | ||
| 2080 | |||
| 2081 | @item f | ||
| 2082 | Visit the revision indicated at the current line, like typing @kbd{C-x | ||
| 2083 | v ~} and specifying this revision's ID (@pxref{Old Revisions}). | ||
| 2084 | |||
| 2085 | @item d | ||
| 2086 | Display the diff (@pxref{Comparing Files}) between the revision | ||
| 2087 | indicated at the current line and the next earlier revision. This is | ||
| 2088 | useful to see what actually changed in the file when the revision | ||
| 2089 | indicated on the current line was committed. | ||
| 2090 | |||
| 2091 | @item D | ||
| 2092 | Display the changeset diff (@pxref{Comparing Files}) between the | ||
| 2093 | revision indicated at the current line and the next earlier revision. | ||
| 2094 | This is useful to see all the changes to all files that the revision | ||
| 2095 | indicated 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 | ||
| 2103 | Revert the buffer and the file to the working revision from which you started | ||
| 2104 | editing the file. | ||
| 2105 | |||
| 2106 | @item C-x v c | ||
| 2107 | Remove the last-entered change from the master for the visited file. | ||
| 2108 | This 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 | ||
| 2114 | working revision from which you started editing the file, use @kbd{C-x | ||
| 2115 | v u} (@code{vc-revert-buffer}). If the version control system is | ||
| 2116 | locking-based, this leaves the file unlocked, and you must lock it | ||
| 2117 | again before making new changes. @kbd{C-x v u} requires confirmation, | ||
| 2118 | unless it sees that you haven't made any changes with respect to the | ||
| 2119 | master 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 | ||
| 2122 | then 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 | ||
| 2128 | recent checked-in revision, but only if your work file corresponds to | ||
| 2129 | that revision---you cannot use @kbd{C-x v c} to cancel a revision that | ||
| 2130 | is not the latest on its branch. Note that many version control | ||
| 2131 | systems do not support rollback at all; this command is something of a | ||
| 2132 | historical 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 | ||
| 2140 | out which files have changed within an entire directory tree, or to | ||
| 2141 | view the status of all files under version control at once, and to | ||
| 2142 | perform version control operations on collections of files. You can | ||
| 2143 | use the command @kbd{C-x v d} (@code{vc-dir}) to make a directory | ||
| 2144 | listing that includes only files relevant for version control. This | ||
| 2145 | creates a @dfn{VC Directory buffer} and displays it in a separate | ||
| 2146 | window. | ||
| 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 | ||
| 2152 | control systems that VC supports. Another more powerful facility, | ||
| 2153 | designed specifically for CVS, is called PCL-CVS. @xref{Top, , About | ||
| 2154 | PCL-CVS, pcl-cvs, PCL-CVS --- The Emacs Front-End to CVS}. | ||
| 2155 | |||
| 2156 | The VC Directory buffer contains a list of version-controlled files | ||
| 2157 | in the current directory and its subdirectories. Files which are | ||
| 2158 | up-to-date (have no local differences from the repository copy) are | ||
| 2159 | omitted; if all files in a directory are up-to-date, the directory is | ||
| 2160 | omitted as well. (However, the directory in which @code{vc-dir} was | ||
| 2161 | run will always be shown as @file{./}.) There is an exception to this | ||
| 2162 | rule: if VC mode detects that a file has changed to an up-to-date | ||
| 2163 | state 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 | ||
| 2166 | select 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 | ||
| 2170 | the file. Under RCS and SCCS, the name of the user locking the file | ||
| 2171 | is shown; under CVS, an abbreviated version of the @samp{cvs status} | ||
| 2172 | output 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 | ||
| 2184 | In this example, @samp{file1.c} is modified with respect to the | ||
| 2185 | repository, and @samp{file2.c} is not. @samp{file3.c} is modified, | ||
| 2186 | but other changes have also been checked in to the repository---you | ||
| 2187 | need 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 | ||
| 2192 | contacts it when the variable @code{vc-stay-local} (or | ||
| 2193 | @code{vc-cvs-stay-local}) is nil (@pxref{CVS Options}). This is | ||
| 2194 | because access to the repository may be slow, or you may be working | ||
| 2195 | offline and not have access to the repository at all. As a | ||
| 2196 | consequence, VC would not be able to tell you that @samp{file3.c} is | ||
| 2197 | in the ``merge'' state; you would learn that only when you try to | ||
| 2198 | check-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 | ||
| 2202 | consistently whenever it arises. In VC, you'll simply get prompted to | ||
| 2203 | merge the remote changes into your work file first. The benefits of | ||
| 2204 | less network communication usually outweigh the disadvantage of not | ||
| 2205 | seeing remote changes immediately. | ||
| 2206 | |||
| 2207 | @vindex vc-directory-exclusion-list | ||
| 2208 | When a VC directory displays subdirectories it omits some that | ||
| 2209 | should never contain any files under version control. By default, | ||
| 2210 | this 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 | ||
| 2222 | for picking out filesets. Some of these are also available in a | ||
| 2223 | context 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 | ||
| 2226 | move vertically as in other list-browsing modes. @key{SPC} and | ||
| 2227 | @key{TAB} behave like down-arrow, and @key{BackTab} behaves like | ||
| 2228 | up-arrow. | ||
| 2229 | |||
| 2230 | Both @kbd{C-m} and @kbd{f} visit the file on the current | ||
| 2231 | line. @kbd{o} visits that file in another window. @kbd{q} dismisses | ||
| 2232 | the 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 | ||
| 2237 | region is active, @kbd{m} marks all the files in the region. There | ||
| 2238 | are some restrictions when marking: a file cannot be marked if any of | ||
| 2239 | its parent directories are marked, and a directory cannot be marked if | ||
| 2240 | any 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 | ||
| 2243 | file if the cursor is on a file. If the cursor is on a directory, it | ||
| 2244 | marks all child files. With a prefix argument: marks all files and | ||
| 2245 | directories. | ||
| 2246 | |||
| 2247 | @kbd{u} unmarks the file or directory on the current line. If the | ||
| 2248 | region 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 | ||
| 2251 | if the cursor is on a file. If the cursor is on a directory, it | ||
| 2252 | unmarks all child files. With a prefix argument: unmarks all marked | ||
| 2253 | files and directories. | ||
| 2254 | |||
| 2255 | It is possible to do search, search and replace, incremental search, | ||
| 2256 | and incremental regexp search on multiple files. These commands will | ||
| 2257 | work on all the marked files or the current file if nothing is marked. | ||
| 2258 | If a directory is marked, the files in that directory shown in the VC | ||
| 2259 | directory 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 | ||
| 2270 | backends use the VC-dir menu to make available extra backend specific | ||
| 2271 | commands. | ||
| 2272 | |||
| 2273 | Normal VC commands with the @kbd{C-x v} prefix work in VC directory | ||
| 2274 | buffers. 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 | ||
| 2279 | marked files, so that you can check in several files at once. | ||
| 2280 | If the underlying VC supports atomic commits of multiple-file | ||
| 2281 | changesets, @kbd{C-x v v} with a selected set of modified but not | ||
| 2282 | committed 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, | ||
| 2285 | it requires that all of those files must be either in the same state or | ||
| 2286 | in compatible states; otherwise it will throw an error (added, | ||
| 2287 | modified and removed states are considered compatible). Note that this | ||
| 2288 | differs from the behavior of older versions of VC, which did not have | ||
| 2289 | fileset operations and simply did @code{vc-next-action} on each file | ||
| 2290 | individually. | ||
| 2291 | |||
| 2292 | If any files are in a state that calls for commit, @kbd{C-x v v} reads a | ||
| 2293 | single log entry and uses it for the changeset as a whole. If the | ||
| 2294 | underling VCS is file- rather than changeset-oriented, the log entry | ||
| 2295 | will 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'' | ||
| 2303 | revisions of a file. For example, you might have different revisions of a | ||
| 2304 | program in which you are gradually adding various unfinished new | ||
| 2305 | features. Each such independent line of development is called a | ||
| 2306 | @dfn{branch}. VC allows you to create branches, switch between | ||
| 2307 | different branches, and merge changes from one branch to another. | ||
| 2308 | Please note, however, that branches are not supported for SCCS. | ||
| 2309 | |||
| 2310 | A file's main line of development is usually called the @dfn{trunk}. | ||
| 2311 | You can create multiple branches from the trunk. How the difference | ||
| 2312 | between trunk and branch is made visible is dependent on whether the | ||
| 2313 | VCS uses dot-pair or monotonic version IDs. | ||
| 2314 | |||
| 2315 | In VCSes with dot-pair revision IDs, the revisions on the trunk are | ||
| 2316 | normally IDed 1.1, 1.2, 1.3, etc. At any such revision, you can | ||
| 2317 | start an independent branch. A branch starting at revision 1.2 would | ||
| 2318 | have revision ID 1.2.1.1, and consecutive revisions on this branch | ||
| 2319 | would have IDs 1.2.1.2, 1.2.1.3, 1.2.1.4, and so on. If there is | ||
| 2320 | a second branch also starting at revision 1.2, it would consist of | ||
| 2321 | revisions 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 | ||
| 2324 | 1, 2, 3, etc. A branch from (say) revision 2 might start with 2.1 and | ||
| 2325 | continue through 2.2, 2.3, etc. But naming conventions for branches | ||
| 2326 | and subbranches vary widely on these systems, and some (like | ||
| 2327 | Mercurial) never depart from the monotonic integer sequence at all. | ||
| 2328 | Consult 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 | ||
| 2333 | branch---the @dfn{head revision} of that branch. The branches in the | ||
| 2334 | dot-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 | ||
| 2348 | revision ID you want to select. On a locking-based system, this | ||
| 2349 | version is then visited @emph{unlocked} (write-protected), so you can | ||
| 2350 | examine it before locking it. Switching branches in this way is allowed | ||
| 2351 | only when the file is not locked. | ||
| 2352 | |||
| 2353 | On a VCS with dot-pair IDs, you can omit the minor part, thus giving | ||
| 2354 | only the branch ID; this takes you to the head version on the | ||
| 2355 | chosen branch. If you only type @key{RET}, Emacs goes to the highest | ||
| 2356 | version on the trunk. | ||
| 2357 | |||
| 2358 | After you have switched to any branch (including the main branch), you | ||
| 2359 | stay on it for subsequent VC commands, until you explicitly select some | ||
| 2360 | other 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 | ||
| 2366 | the branch that contains it), first select that revision if necessary, | ||
| 2367 | lock it with @kbd{C-x v v}, and make whatever changes you want. Then, | ||
| 2368 | when you check in the changes, use @kbd{C-u C-x v v}. This lets you | ||
| 2369 | specify the revision ID for the new revision. You should specify a | ||
| 2370 | suitable branch ID for a branch starting at the current revision. | ||
| 2371 | For example, if the current revision is 2.5, the branch ID should be | ||
| 2372 | 2.5.1, 2.5.2, and so on, depending on the number of existing branches at | ||
| 2373 | that point. | ||
| 2374 | |||
| 2375 | To create a new branch at an older revision (one that is no longer the | ||
| 2376 | head of a branch), first select that revision (@pxref{Switching | ||
| 2377 | Branches}). Your procedure will then differ depending on whether you | ||
| 2378 | are 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 | ||
| 2382 | revision, that you really mean to create a new branch---if you say no, | ||
| 2383 | you'll be offered a chance to lock the latest revision instead. On | ||
| 2384 | a 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 | ||
| 2387 | revision. This automatically creates a new branch starting from the | ||
| 2388 | selected revision. You need not specially request a new branch, because | ||
| 2389 | that's the only way to add a new revision at a point that is not the head | ||
| 2390 | of a branch. | ||
| 2391 | |||
| 2392 | After the branch is created, you ``stay'' on it. That means that | ||
| 2393 | subsequent check-ins create new revisions on that branch. To leave the | ||
| 2394 | branch, you must explicitly select a different revision with @kbd{C-u C-x | ||
| 2395 | v v}. To transfer changes from one branch to another, use the merge | ||
| 2396 | command, 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 | ||
| 2403 | often want to incorporate them into the file's main line of development | ||
| 2404 | (the trunk). This is not a trivial operation, because development might | ||
| 2405 | also have proceeded on the trunk, so that you must @dfn{merge} the | ||
| 2406 | changes into a file that has already been changed otherwise. VC allows | ||
| 2407 | you to do this (and other things) with the @code{vc-merge} command. | ||
| 2408 | |||
| 2409 | @table @kbd | ||
| 2410 | @item C-x v m (vc-merge) | ||
| 2411 | Merge 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 | ||
| 2417 | into the current version of the work file. It firsts asks you in the | ||
| 2418 | minibuffer where the changes should come from. If you just type | ||
| 2419 | @key{RET}, Emacs merges any changes that were made on the same branch | ||
| 2420 | since you checked the file out (we call this @dfn{merging the news}). | ||
| 2421 | This is the common way to pick up recent changes from the repository, | ||
| 2422 | regardless 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 | ||
| 2425 | the minibuffer. Then @kbd{C-x v m} finds the changes from that | ||
| 2426 | branch, or the differences between the two revisions you specified, and | ||
| 2427 | merges them into the current revision of the current file. | ||
| 2428 | |||
| 2429 | As an example, suppose that you have finished a certain feature on | ||
| 2430 | branch 1.3.1. In the meantime, development on the trunk has proceeded | ||
| 2431 | to revision 1.5. To merge the changes from the branch to the trunk, | ||
| 2432 | first 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, | ||
| 2434 | type @kbd{C-x v v} to lock revision 1.5 so that you can change it. Next, | ||
| 2435 | type @kbd{C-x v m 1.3.1 @key{RET}}. This takes the entire set of changes on | ||
| 2436 | branch 1.3.1 (relative to revision 1.3, where the branch started, up to | ||
| 2437 | the last revision on the branch) and merges it into the current revision | ||
| 2438 | of the work file. You can now check in the changed file, thus creating | ||
| 2439 | revision 1.6 containing the changes from the branch. | ||
| 2440 | |||
| 2441 | It is possible to do further editing after merging the branch, before | ||
| 2442 | the next check-in. But it is usually wiser to check in the merged | ||
| 2443 | revision, then lock it and make the further changes. This will keep | ||
| 2444 | a 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 | ||
| 2449 | changes might overlap. We call this situation a @dfn{conflict}, and | ||
| 2450 | reconciling the conflicting changes is called @dfn{resolving a | ||
| 2451 | conflict}. | ||
| 2452 | |||
| 2453 | Whenever conflicts occur during merging, VC detects them, tells you | ||
| 2454 | about them in the echo area, and asks whether you want help in merging. | ||
| 2455 | If you say yes, it starts an Ediff session (@pxref{Top, | ||
| 2456 | Ediff, Ediff, ediff, The Ediff Manual}). | ||
| 2457 | |||
| 2458 | If you say no, the conflicting changes are both inserted into the | ||
| 2459 | file, surrounded by @dfn{conflict markers}. The example below shows how | ||
| 2460 | a conflict region looks; the file is called @samp{name} and the current | ||
| 2461 | master 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 | ||
| 2476 | you can type @code{M-x vc-resolve-conflicts} after visiting the file. | ||
| 2477 | This starts an Ediff session, as described above. Don't forget to | ||
| 2478 | check 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 | ||
| 2484 | different branches of a file. CVS and later systems allow this by | ||
| 2485 | default; for RCS, it is possible if you create multiple source | ||
| 2486 | directories. Each source directory should have a link named | ||
| 2487 | @file{RCS} which points to a common directory of RCS master files. | ||
| 2488 | Then each source directory can have its own choice of selected | ||
| 2489 | revisions, but all share the same common RCS records. | ||
| 2490 | |||
| 2491 | This technique works reliably and automatically, provided that the | ||
| 2492 | source 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 | ||
| 2499 | The headers enable Emacs to be sure, at all times, which revision | ||
| 2500 | ID is present in the work file. | ||
| 2501 | |||
| 2502 | If the files do not have version headers, you must instead tell Emacs | ||
| 2503 | explicitly in each session which branch you are working on. To do this, | ||
| 2504 | first find the file, then type @kbd{C-u C-x v v} and specify the correct | ||
| 2505 | branch ID. This ensures that Emacs knows which branch it is using | ||
| 2506 | during 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 | |||
| 2989 | need these programs to look at the archive table of contents, only to | 1642 | need these programs to look at the archive table of contents, only to |
| 2990 | extract or manipulate the subfiles in the archive. | 1643 | extract 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 | |||
| 3001 | DocView mode is a document viewer for Emacs (@code{doc-view-mode}). | ||
| 3002 | It's capable of displaying PDF, PS and DVI files inside an Emacs buffer | ||
| 3003 | and provides some convenience features like slicing, zooming and | ||
| 3004 | searching inside the document. | ||
| 3005 | |||
| 3006 | @vindex doc-view-cache-directory | ||
| 3007 | This is done by using @command{gs} (GhostScript) to convert the document | ||
| 3008 | to a set of PNG images which are then displayed. In order to omit | ||
| 3009 | double 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 | ||
| 3014 | By default Emacs opens all pdf and dvi files using DocView mode. You'll | ||
| 3015 | be greeted with a welcome screen and as soon as the first page's | ||
| 3016 | conversion finished, it'll be displayed. PostScript files are opened | ||
| 3017 | with @code{ps-mode} by default, but additionally | ||
| 3018 | @code{doc-view-minor-mode} is enabled, which adds the binding @kbd{C-c | ||
| 3019 | C-c} (@code{doc-view-toggle-display}) and toggles between the editing | ||
| 3020 | mode (@code{ps-mode} in case of PS files, @code{fundamental-mode} in | ||
| 3021 | case of PDF or DVI files) and DocView mode. | ||
| 3022 | |||
| 3023 | @findex doc-view-enlarge | ||
| 3024 | @findex doc-view-shrink | ||
| 3025 | You can enlarge or shrink the document with @kbd{+} | ||
| 3026 | (@code{doc-view-enlarge}) and @kbd{-} (@code{doc-view-shrink}). | ||
| 3027 | |||
| 3028 | The 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 | |||
| 3040 | Inside DocView mode you can scroll the current page using the usual | ||
| 3041 | Emacs 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 | ||
| 3046 | To 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 | ||
| 3052 | While reading a document it's convenient to scroll the current page and | ||
| 3053 | switch to the next one if it's already scrolled to the bottom. This | ||
| 3054 | functionality is bound to @kbd{@key{SPC}} | ||
| 3055 | (@code{doc-view-scroll-up-or-next-page}). @kbd{@key{DEL}} will do the | ||
| 3056 | same 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 | ||
| 3061 | To go to the first page use @kbd{M-<} (@code{doc-view-first-page}), to | ||
| 3062 | go to the last one use @kbd{M->} (@code{doc-view-last-page}). | ||
| 3063 | |||
| 3064 | @findex doc-view-goto-page | ||
| 3065 | To 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 | |||
| 3071 | It's possible to search for a regular expression (@pxref{Regexps}) | ||
| 3072 | inside documents. In order to do that, the document file will be | ||
| 3073 | converted to text and the search will be performed in the text file. | ||
| 3074 | The interface to searching is inspired by @code{isearch} | ||
| 3075 | (@pxref{Incremental Search}). | ||
| 3076 | |||
| 3077 | @findex doc-view-search | ||
| 3078 | @findex doc-view-search-backward | ||
| 3079 | To 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 | ||
| 3081 | expression and after hitting @kbd{@key{RET}} the number of matches will | ||
| 3082 | be echoed. Navigation between the matches is done by pressing @kbd{C-s} | ||
| 3083 | and @kbd{C-r} again. | ||
| 3084 | |||
| 3085 | @findex doc-view-show-tooltip | ||
| 3086 | Since there's no possibility to show the match inside the image itself, | ||
| 3087 | a tooltip will be shown at the mouse position which lists all matching | ||
| 3088 | lines of the current page. You can force the tooltip to be shown with | ||
| 3089 | @kbd{C-t} (@code{doc-view-show-tooltip}). | ||
| 3090 | |||
| 3091 | To initiate a new search call @code{doc-view-search} with a prefix | ||
| 3092 | argument, 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 | |||
| 3097 | Quite often documents have huge margins for printing. These are | ||
| 3098 | annoying when reading the document on a computer, because they use up | ||
| 3099 | screen space and thus can force inconvenient scrolling. | ||
| 3100 | |||
| 3101 | @findex doc-view-set-slice | ||
| 3102 | @findex doc-view-set-slice-using-mouse | ||
| 3103 | To prevent you from that DocView lets you select the slice of the pages | ||
| 3104 | you'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 | ||
| 3106 | slice'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 | ||
| 3108 | mouse to select the slice. | ||
| 3109 | |||
| 3110 | @findex doc-view-reset-slice | ||
| 3111 | To reset the selected slice use @kbd{s r} (@code{doc-view-reset-slice}). | ||
| 3112 | |||
| 3113 | @node Conversion | ||
| 3114 | @subsection Conversion | ||
| 3115 | |||
| 3116 | As said before DocView mode will automatically convert the document | ||
| 3117 | files when visiting them unless @code{doc-view-cache-directory} already | ||
| 3118 | contains the converted PNG images. In that case it'll use the cached | ||
| 3119 | files. | ||
| 3120 | |||
| 3121 | @findex doc-view-clear-cache | ||
| 3122 | You can clean up the cache directory with @code{M-x | ||
| 3123 | doc-view-clear-cache}. | ||
| 3124 | |||
| 3125 | If a document has changed, it'll be converted anew when visiting it. | ||
| 3126 | DocView recognizes documents by the md5 sum of their contents. | ||
| 3127 | |||
| 3128 | @findex doc-view-kill-proc | ||
| 3129 | @findex doc-view-kill-proc-and-buffer | ||
| 3130 | To force a reconversion of the currently viewed document hit @kbd{r} or | ||
| 3131 | @kbd{g} (@code{revert-buffer}). Killing the converter process | ||
| 3132 | associated 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 | ||
| 3134 | additionally kill the DocView buffer | ||
| 3135 | (@code{doc-view-kill-proc-and-buffer}). | ||
| 3136 | |||
| 3137 | The zoom commands @kbd{+} (@code{doc-view-enlarge}) and @kbd{-} | ||
| 3138 | (@code{doc-view-shrink}) will also reconvert the current document using | ||
| 3139 | another resolution. The current page will be converted first. | ||
| 3140 | |||
| 3141 | @vindex doc-view-resolution | ||
| 3142 | The 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 | ||