hgbook
diff en/ch01-intro.xml @ 553:863a82f13901
Basic progress on XML.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu Feb 05 22:45:48 2009 -0800 (2009-02-05) |
parents | en/ch01-intro.tex@f72b7e6cbe90 |
children | 8631da51309b |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/en/ch01-intro.xml Thu Feb 05 22:45:48 2009 -0800 1.3 @@ -0,0 +1,680 @@ 1.4 +<!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : --> 1.5 + 1.6 +<chapter> 1.7 + <title>Introduction</title> 1.8 + <para>\label{chap:intro}</para> 1.9 + 1.10 + <sect1> 1.11 + <title>About revision control</title> 1.12 + 1.13 + <para>Revision control is the process of managing multiple 1.14 + versions of a piece of information. In its simplest form, this 1.15 + is something that many people do by hand: every time you modify 1.16 + a file, save it under a new name that contains a number, each 1.17 + one higher than the number of the preceding version.</para> 1.18 + 1.19 + <para>Manually managing multiple versions of even a single file is 1.20 + an error-prone task, though, so software tools to help automate 1.21 + this process have long been available. The earliest automated 1.22 + revision control tools were intended to help a single user to 1.23 + manage revisions of a single file. Over the past few decades, 1.24 + the scope of revision control tools has expanded greatly; they 1.25 + now manage multiple files, and help multiple people to work 1.26 + together. The best modern revision control tools have no 1.27 + problem coping with thousands of people working together on 1.28 + projects that consist of hundreds of thousands of files.</para> 1.29 + 1.30 + <sect2> 1.31 + <title>Why use revision control?</title> 1.32 + 1.33 + <para>There are a number of reasons why you or your team might 1.34 + want to use an automated revision control tool for a 1.35 + project.</para> 1.36 + <itemizedlist> 1.37 + <listitem><para>It will track the history and evolution of 1.38 + your project, so you don't have to. For every change, 1.39 + you'll have a log of <emphasis>who</emphasis> made it; 1.40 + <emphasis>why</emphasis> they made it; 1.41 + <emphasis>when</emphasis> they made it; and 1.42 + <emphasis>what</emphasis> the change 1.43 + was.</para></listitem> 1.44 + <listitem><para>When you're working with other people, 1.45 + revision control software makes it easier for you to 1.46 + collaborate. For example, when people more or less 1.47 + simultaneously make potentially incompatible changes, the 1.48 + software will help you to identify and resolve those 1.49 + conflicts.</para></listitem> 1.50 + <listitem><para>It can help you to recover from mistakes. If 1.51 + you make a change that later turns out to be in error, you 1.52 + can revert to an earlier version of one or more files. In 1.53 + fact, a <emphasis>really</emphasis> good revision control 1.54 + tool will even help you to efficiently figure out exactly 1.55 + when a problem was introduced (see section <xref 1.56 + id="sec:undo:bisect"/> for details).</para></listitem> 1.57 + <listitem><para>It will help you to work simultaneously on, 1.58 + and manage the drift between, multiple versions of your 1.59 + project.</para></listitem></itemizedlist> 1.60 + <para>Most of these reasons are equally valid---at least in 1.61 + theory---whether you're working on a project by yourself, or 1.62 + with a hundred other people.</para> 1.63 + 1.64 + <para>A key question about the practicality of revision control 1.65 + at these two different scales (<quote>lone hacker</quote> and 1.66 + <quote>huge team</quote>) is how its 1.67 + <emphasis>benefits</emphasis> compare to its 1.68 + <emphasis>costs</emphasis>. A revision control tool that's 1.69 + difficult to understand or use is going to impose a high 1.70 + cost.</para> 1.71 + 1.72 + <para>A five-hundred-person project is likely to collapse under 1.73 + its own weight almost immediately without a revision control 1.74 + tool and process. In this case, the cost of using revision 1.75 + control might hardly seem worth considering, since 1.76 + <emphasis>without</emphasis> it, failure is almost 1.77 + guaranteed.</para> 1.78 + 1.79 + <para>On the other hand, a one-person <quote>quick hack</quote> 1.80 + might seem like a poor place to use a revision control tool, 1.81 + because surely the cost of using one must be close to the 1.82 + overall cost of the project. Right?</para> 1.83 + 1.84 + <para>Mercurial uniquely supports <emphasis>both</emphasis> of 1.85 + these scales of development. You can learn the basics in just 1.86 + a few minutes, and due to its low overhead, you can apply 1.87 + revision control to the smallest of projects with ease. Its 1.88 + simplicity means you won't have a lot of abstruse concepts or 1.89 + command sequences competing for mental space with whatever 1.90 + you're <emphasis>really</emphasis> trying to do. At the same 1.91 + time, Mercurial's high performance and peer-to-peer nature let 1.92 + you scale painlessly to handle large projects.</para> 1.93 + 1.94 + <para>No revision control tool can rescue a poorly run project, 1.95 + but a good choice of tools can make a huge difference to the 1.96 + fluidity with which you can work on a project.</para> 1.97 + 1.98 + </sect2> 1.99 + <sect2> 1.100 + <title>The many names of revision control</title> 1.101 + 1.102 + <para>Revision control is a diverse field, so much so that it 1.103 + doesn't actually have a single name or acronym. Here are a 1.104 + few of the more common names and acronyms you'll 1.105 + encounter:</para> 1.106 + <itemizedlist> 1.107 + <listitem><para>Revision control (RCS)</para></listitem> 1.108 + <listitem><para>Software configuration management (SCM), or 1.109 + configuration management</para></listitem> 1.110 + <listitem><para>Source code management</para></listitem> 1.111 + <listitem><para>Source code control, or source 1.112 + control</para></listitem> 1.113 + <listitem><para>Version control 1.114 + (VCS)</para></listitem></itemizedlist> 1.115 + <para>Some people claim that these terms actually have different 1.116 + meanings, but in practice they overlap so much that there's no 1.117 + agreed or even useful way to tease them apart.</para> 1.118 + 1.119 + </sect2> 1.120 + </sect1> 1.121 + <sect1> 1.122 + <title>A short history of revision control</title> 1.123 + 1.124 + <para>The best known of the old-time revision control tools is 1.125 + SCCS (Source Code Control System), which Marc Rochkind wrote at 1.126 + Bell Labs, in the early 1970s. SCCS operated on individual 1.127 + files, and required every person working on a project to have 1.128 + access to a shared workspace on a single system. Only one 1.129 + person could modify a file at any time; arbitration for access 1.130 + to files was via locks. It was common for people to lock files, 1.131 + and later forget to unlock them, preventing anyone else from 1.132 + modifying those files without the help of an 1.133 + administrator.</para> 1.134 + 1.135 + <para>Walter Tichy developed a free alternative to SCCS in the 1.136 + early 1980s; he called his program RCS (Revison Control System). 1.137 + Like SCCS, RCS required developers to work in a single shared 1.138 + workspace, and to lock files to prevent multiple people from 1.139 + modifying them simultaneously.</para> 1.140 + 1.141 + <para>Later in the 1980s, Dick Grune used RCS as a building block 1.142 + for a set of shell scripts he initially called cmt, but then 1.143 + renamed to CVS (Concurrent Versions System). The big innovation 1.144 + of CVS was that it let developers work simultaneously and 1.145 + somewhat independently in their own personal workspaces. The 1.146 + personal workspaces prevented developers from stepping on each 1.147 + other's toes all the time, as was common with SCCS and RCS. Each 1.148 + developer had a copy of every project file, and could modify 1.149 + their copies independently. They had to merge their edits prior 1.150 + to committing changes to the central repository.</para> 1.151 + 1.152 + <para>Brian Berliner took Grune's original scripts and rewrote 1.153 + them in C, releasing in 1989 the code that has since developed 1.154 + into the modern version of CVS. CVS subsequently acquired the 1.155 + ability to operate over a network connection, giving it a 1.156 + client/server architecture. CVS's architecture is centralised; 1.157 + only the server has a copy of the history of the project. Client 1.158 + workspaces just contain copies of recent versions of the 1.159 + project's files, and a little metadata to tell them where the 1.160 + server is. CVS has been enormously successful; it is probably 1.161 + the world's most widely used revision control system.</para> 1.162 + 1.163 + <para>In the early 1990s, Sun Microsystems developed an early 1.164 + distributed revision control system, called TeamWare. A 1.165 + TeamWare workspace contains a complete copy of the project's 1.166 + history. TeamWare has no notion of a central repository. (CVS 1.167 + relied upon RCS for its history storage; TeamWare used 1.168 + SCCS.)</para> 1.169 + 1.170 + <para>As the 1990s progressed, awareness grew of a number of 1.171 + problems with CVS. It records simultaneous changes to multiple 1.172 + files individually, instead of grouping them together as a 1.173 + single logically atomic operation. It does not manage its file 1.174 + hierarchy well; it is easy to make a mess of a repository by 1.175 + renaming files and directories. Worse, its source code is 1.176 + difficult to read and maintain, which made the <quote>pain 1.177 + level</quote> of fixing these architectural problems 1.178 + prohibitive.</para> 1.179 + 1.180 + <para>In 2001, Jim Blandy and Karl Fogel, two developers who had 1.181 + worked on CVS, started a project to replace it with a tool that 1.182 + would have a better architecture and cleaner code. The result, 1.183 + Subversion, does not stray from CVS's centralised client/server 1.184 + model, but it adds multi-file atomic commits, better namespace 1.185 + management, and a number of other features that make it a 1.186 + generally better tool than CVS. Since its initial release, it 1.187 + has rapidly grown in popularity.</para> 1.188 + 1.189 + <para>More or less simultaneously, Graydon Hoare began working on 1.190 + an ambitious distributed revision control system that he named 1.191 + Monotone. While Monotone addresses many of CVS's design flaws 1.192 + and has a peer-to-peer architecture, it goes beyond earlier (and 1.193 + subsequent) revision control tools in a number of innovative 1.194 + ways. It uses cryptographic hashes as identifiers, and has an 1.195 + integral notion of <quote>trust</quote> for code from different 1.196 + sources.</para> 1.197 + 1.198 + <para>Mercurial began life in 2005. While a few aspects of its 1.199 + design are influenced by Monotone, Mercurial focuses on ease of 1.200 + use, high performance, and scalability to very large 1.201 + projects.</para> 1.202 + 1.203 + </sect1> 1.204 + <sect1> 1.205 + <title>Trends in revision control</title> 1.206 + 1.207 + <para>There has been an unmistakable trend in the development and 1.208 + use of revision control tools over the past four decades, as 1.209 + people have become familiar with the capabilities of their tools 1.210 + and constrained by their limitations.</para> 1.211 + 1.212 + <para>The first generation began by managing single files on 1.213 + individual computers. Although these tools represented a huge 1.214 + advance over ad-hoc manual revision control, their locking model 1.215 + and reliance on a single computer limited them to small, 1.216 + tightly-knit teams.</para> 1.217 + 1.218 + <para>The second generation loosened these constraints by moving 1.219 + to network-centered architectures, and managing entire projects 1.220 + at a time. As projects grew larger, they ran into new problems. 1.221 + With clients needing to talk to servers very frequently, server 1.222 + scaling became an issue for large projects. An unreliable 1.223 + network connection could prevent remote users from being able to 1.224 + talk to the server at all. As open source projects started 1.225 + making read-only access available anonymously to anyone, people 1.226 + without commit privileges found that they could not use the 1.227 + tools to interact with a project in a natural way, as they could 1.228 + not record their changes.</para> 1.229 + 1.230 + <para>The current generation of revision control tools is 1.231 + peer-to-peer in nature. All of these systems have dropped the 1.232 + dependency on a single central server, and allow people to 1.233 + distribute their revision control data to where it's actually 1.234 + needed. Collaboration over the Internet has moved from 1.235 + constrained by technology to a matter of choice and consensus. 1.236 + Modern tools can operate offline indefinitely and autonomously, 1.237 + with a network connection only needed when syncing changes with 1.238 + another repository.</para> 1.239 + 1.240 + </sect1> 1.241 + <sect1> 1.242 + <title>A few of the advantages of distributed revision 1.243 + control</title> 1.244 + 1.245 + <para>Even though distributed revision control tools have for 1.246 + several years been as robust and usable as their 1.247 + previous-generation counterparts, people using older tools have 1.248 + not yet necessarily woken up to their advantages. There are a 1.249 + number of ways in which distributed tools shine relative to 1.250 + centralised ones.</para> 1.251 + 1.252 + <para>For an individual developer, distributed tools are almost 1.253 + always much faster than centralised tools. This is for a simple 1.254 + reason: a centralised tool needs to talk over the network for 1.255 + many common operations, because most metadata is stored in a 1.256 + single copy on the central server. A distributed tool stores 1.257 + all of its metadata locally. All else being equal, talking over 1.258 + the network adds overhead to a centralised tool. Don't 1.259 + underestimate the value of a snappy, responsive tool: you're 1.260 + going to spend a lot of time interacting with your revision 1.261 + control software.</para> 1.262 + 1.263 + <para>Distributed tools are indifferent to the vagaries of your 1.264 + server infrastructure, again because they replicate metadata to 1.265 + so many locations. If you use a centralised system and your 1.266 + server catches fire, you'd better hope that your backup media 1.267 + are reliable, and that your last backup was recent and actually 1.268 + worked. With a distributed tool, you have many backups 1.269 + available on every contributor's computer.</para> 1.270 + 1.271 + <para>The reliability of your network will affect distributed 1.272 + tools far less than it will centralised tools. You can't even 1.273 + use a centralised tool without a network connection, except for 1.274 + a few highly constrained commands. With a distributed tool, if 1.275 + your network connection goes down while you're working, you may 1.276 + not even notice. The only thing you won't be able to do is talk 1.277 + to repositories on other computers, something that is relatively 1.278 + rare compared with local operations. If you have a far-flung 1.279 + team of collaborators, this may be significant.</para> 1.280 + 1.281 + <sect2> 1.282 + <title>Advantages for open source projects</title> 1.283 + 1.284 + <para>If you take a shine to an open source project and decide 1.285 + that you would like to start hacking on it, and that project 1.286 + uses a distributed revision control tool, you are at once a 1.287 + peer with the people who consider themselves the 1.288 + <quote>core</quote> of that project. If they publish their 1.289 + repositories, you can immediately copy their project history, 1.290 + start making changes, and record your work, using the same 1.291 + tools in the same ways as insiders. By contrast, with a 1.292 + centralised tool, you must use the software in a <quote>read 1.293 + only</quote> mode unless someone grants you permission to 1.294 + commit changes to their central server. Until then, you won't 1.295 + be able to record changes, and your local modifications will 1.296 + be at risk of corruption any time you try to update your 1.297 + client's view of the repository.</para> 1.298 + 1.299 + <sect3> 1.300 + <title>The forking non-problem</title> 1.301 + 1.302 + <para>It has been suggested that distributed revision control 1.303 + tools pose some sort of risk to open source projects because 1.304 + they make it easy to <quote>fork</quote> the development of 1.305 + a project. A fork happens when there are differences in 1.306 + opinion or attitude between groups of developers that cause 1.307 + them to decide that they can't work together any longer. 1.308 + Each side takes a more or less complete copy of the 1.309 + project's source code, and goes off in its own 1.310 + direction.</para> 1.311 + 1.312 + <para>Sometimes the camps in a fork decide to reconcile their 1.313 + differences. With a centralised revision control system, the 1.314 + <emphasis>technical</emphasis> process of reconciliation is 1.315 + painful, and has to be performed largely by hand. You have 1.316 + to decide whose revision history is going to 1.317 + <quote>win</quote>, and graft the other team's changes into 1.318 + the tree somehow. This usually loses some or all of one 1.319 + side's revision history.</para> 1.320 + 1.321 + <para>What distributed tools do with respect to forking is 1.322 + they make forking the <emphasis>only</emphasis> way to 1.323 + develop a project. Every single change that you make is 1.324 + potentially a fork point. The great strength of this 1.325 + approach is that a distributed revision control tool has to 1.326 + be really good at <emphasis>merging</emphasis> forks, 1.327 + because forks are absolutely fundamental: they happen all 1.328 + the time.</para> 1.329 + 1.330 + <para>If every piece of work that everybody does, all the 1.331 + time, is framed in terms of forking and merging, then what 1.332 + the open source world refers to as a <quote>fork</quote> 1.333 + becomes <emphasis>purely</emphasis> a social issue. If 1.334 + anything, distributed tools <emphasis>lower</emphasis> the 1.335 + likelihood of a fork:</para> 1.336 + <itemizedlist> 1.337 + <listitem><para>They eliminate the social distinction that 1.338 + centralised tools impose: that between insiders (people 1.339 + with commit access) and outsiders (people 1.340 + without).</para></listitem> 1.341 + <listitem><para>They make it easier to reconcile after a 1.342 + social fork, because all that's involved from the 1.343 + perspective of the revision control software is just 1.344 + another merge.</para></listitem></itemizedlist> 1.345 + 1.346 + <para>Some people resist distributed tools because they want 1.347 + to retain tight control over their projects, and they 1.348 + believe that centralised tools give them this control. 1.349 + However, if you're of this belief, and you publish your CVS 1.350 + or Subversion repositories publically, there are plenty of 1.351 + tools available that can pull out your entire project's 1.352 + history (albeit slowly) and recreate it somewhere that you 1.353 + don't control. So while your control in this case is 1.354 + illusory, you are forgoing the ability to fluidly 1.355 + collaborate with whatever people feel compelled to mirror 1.356 + and fork your history.</para> 1.357 + 1.358 + </sect3> 1.359 + </sect2> 1.360 + <sect2> 1.361 + <title>Advantages for commercial projects</title> 1.362 + 1.363 + <para>Many commercial projects are undertaken by teams that are 1.364 + scattered across the globe. Contributors who are far from a 1.365 + central server will see slower command execution and perhaps 1.366 + less reliability. Commercial revision control systems attempt 1.367 + to ameliorate these problems with remote-site replication 1.368 + add-ons that are typically expensive to buy and cantankerous 1.369 + to administer. A distributed system doesn't suffer from these 1.370 + problems in the first place. Better yet, you can easily set 1.371 + up multiple authoritative servers, say one per site, so that 1.372 + there's no redundant communication between repositories over 1.373 + expensive long-haul network links.</para> 1.374 + 1.375 + <para>Centralised revision control systems tend to have 1.376 + relatively low scalability. It's not unusual for an expensive 1.377 + centralised system to fall over under the combined load of 1.378 + just a few dozen concurrent users. Once again, the typical 1.379 + response tends to be an expensive and clunky replication 1.380 + facility. Since the load on a central server---if you have 1.381 + one at all---is many times lower with a distributed tool 1.382 + (because all of the data is replicated everywhere), a single 1.383 + cheap server can handle the needs of a much larger team, and 1.384 + replication to balance load becomes a simple matter of 1.385 + scripting.</para> 1.386 + 1.387 + <para>If you have an employee in the field, troubleshooting a 1.388 + problem at a customer's site, they'll benefit from distributed 1.389 + revision control. The tool will let them generate custom 1.390 + builds, try different fixes in isolation from each other, and 1.391 + search efficiently through history for the sources of bugs and 1.392 + regressions in the customer's environment, all without needing 1.393 + to connect to your company's network.</para> 1.394 + 1.395 + </sect2> 1.396 + </sect1> 1.397 + <sect1> 1.398 + <title>Why choose Mercurial?</title> 1.399 + 1.400 + <para>Mercurial has a unique set of properties that make it a 1.401 + particularly good choice as a revision control system.</para> 1.402 + <itemizedlist> 1.403 + <listitem><para>It is easy to learn and use.</para></listitem> 1.404 + <listitem><para>It is lightweight.</para></listitem> 1.405 + <listitem><para>It scales excellently.</para></listitem> 1.406 + <listitem><para>It is easy to 1.407 + customise.</para></listitem></itemizedlist> 1.408 + 1.409 + <para>If you are at all familiar with revision control systems, 1.410 + you should be able to get up and running with Mercurial in less 1.411 + than five minutes. Even if not, it will take no more than a few 1.412 + minutes longer. Mercurial's command and feature sets are 1.413 + generally uniform and consistent, so you can keep track of a few 1.414 + general rules instead of a host of exceptions.</para> 1.415 + 1.416 + <para>On a small project, you can start working with Mercurial in 1.417 + moments. Creating new changes and branches; transferring changes 1.418 + around (whether locally or over a network); and history and 1.419 + status operations are all fast. Mercurial attempts to stay 1.420 + nimble and largely out of your way by combining low cognitive 1.421 + overhead with blazingly fast operations.</para> 1.422 + 1.423 + <para>The usefulness of Mercurial is not limited to small 1.424 + projects: it is used by projects with hundreds to thousands of 1.425 + contributors, each containing tens of thousands of files and 1.426 + hundreds of megabytes of source code.</para> 1.427 + 1.428 + <para>If the core functionality of Mercurial is not enough for 1.429 + you, it's easy to build on. Mercurial is well suited to 1.430 + scripting tasks, and its clean internals and implementation in 1.431 + Python make it easy to add features in the form of extensions. 1.432 + There are a number of popular and useful extensions already 1.433 + available, ranging from helping to identify bugs to improving 1.434 + performance.</para> 1.435 + 1.436 + </sect1> 1.437 + <sect1> 1.438 + <title>Mercurial compared with other tools</title> 1.439 + 1.440 + <para>Before you read on, please understand that this section 1.441 + necessarily reflects my own experiences, interests, and (dare I 1.442 + say it) biases. I have used every one of the revision control 1.443 + tools listed below, in most cases for several years at a 1.444 + time.</para> 1.445 + 1.446 + 1.447 + <sect2> 1.448 + <title>Subversion</title> 1.449 + 1.450 + <para>Subversion is a popular revision control tool, developed 1.451 + to replace CVS. It has a centralised client/server 1.452 + architecture.</para> 1.453 + 1.454 + <para>Subversion and Mercurial have similarly named commands for 1.455 + performing the same operations, so if you're familiar with 1.456 + one, it is easy to learn to use the other. Both tools are 1.457 + portable to all popular operating systems.</para> 1.458 + 1.459 + <para>Prior to version 1.5, Subversion had no useful support for 1.460 + merges. At the time of writing, its merge tracking capability 1.461 + is new, and known to be <ulink 1.462 + url="http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced.html#svn.branchmerge.advanced.finalword">complicated 1.463 + and buggy</ulink>.</para> 1.464 + 1.465 + <para>Mercurial has a substantial performance advantage over 1.466 + Subversion on every revision control operation I have 1.467 + benchmarked. I have measured its advantage as ranging from a 1.468 + factor of two to a factor of six when compared with Subversion 1.469 + 1.4.3's <emphasis>ra_local</emphasis> file store, which is the 1.470 + fastest access method available. In more realistic 1.471 + deployments involving a network-based store, Subversion will 1.472 + be at a substantially larger disadvantage. Because many 1.473 + Subversion commands must talk to the server and Subversion 1.474 + does not have useful replication facilities, server capacity 1.475 + and network bandwidth become bottlenecks for modestly large 1.476 + projects.</para> 1.477 + 1.478 + <para>Additionally, Subversion incurs substantial storage 1.479 + overhead to avoid network transactions for a few common 1.480 + operations, such as finding modified files 1.481 + (<literal>status</literal>) and displaying modifications 1.482 + against the current revision (<literal>diff</literal>). As a 1.483 + result, a Subversion working copy is often the same size as, 1.484 + or larger than, a Mercurial repository and working directory, 1.485 + even though the Mercurial repository contains a complete 1.486 + history of the project.</para> 1.487 + 1.488 + <para>Subversion is widely supported by third party tools. 1.489 + Mercurial currently lags considerably in this area. This gap 1.490 + is closing, however, and indeed some of Mercurial's GUI tools 1.491 + now outshine their Subversion equivalents. Like Mercurial, 1.492 + Subversion has an excellent user manual.</para> 1.493 + 1.494 + <para>Because Subversion doesn't store revision history on the 1.495 + client, it is well suited to managing projects that deal with 1.496 + lots of large, opaque binary files. If you check in fifty 1.497 + revisions to an incompressible 10MB file, Subversion's 1.498 + client-side space usage stays constant The space used by any 1.499 + distributed SCM will grow rapidly in proportion to the number 1.500 + of revisions, because the differences between each revision 1.501 + are large.</para> 1.502 + 1.503 + <para>In addition, it's often difficult or, more usually, 1.504 + impossible to merge different versions of a binary file. 1.505 + Subversion's ability to let a user lock a file, so that they 1.506 + temporarily have the exclusive right to commit changes to it, 1.507 + can be a significant advantage to a project where binary files 1.508 + are widely used.</para> 1.509 + 1.510 + <para>Mercurial can import revision history from a Subversion 1.511 + repository. It can also export revision history to a 1.512 + Subversion repository. This makes it easy to <quote>test the 1.513 + waters</quote> and use Mercurial and Subversion in parallel 1.514 + before deciding to switch. History conversion is incremental, 1.515 + so you can perform an initial conversion, then small 1.516 + additional conversions afterwards to bring in new 1.517 + changes.</para> 1.518 + 1.519 + 1.520 + </sect2> 1.521 + <sect2> 1.522 + <title>Git</title> 1.523 + 1.524 + <para>Git is a distributed revision control tool that was 1.525 + developed for managing the Linux kernel source tree. Like 1.526 + Mercurial, its early design was somewhat influenced by 1.527 + Monotone.</para> 1.528 + 1.529 + <para>Git has a very large command set, with version 1.5.0 1.530 + providing 139 individual commands. It has something of a 1.531 + reputation for being difficult to learn. Compared to Git, 1.532 + Mercurial has a strong focus on simplicity.</para> 1.533 + 1.534 + <para>In terms of performance, Git is extremely fast. In 1.535 + several cases, it is faster than Mercurial, at least on Linux, 1.536 + while Mercurial performs better on other operations. However, 1.537 + on Windows, the performance and general level of support that 1.538 + Git provides is, at the time of writing, far behind that of 1.539 + Mercurial.</para> 1.540 + 1.541 + <para>While a Mercurial repository needs no maintenance, a Git 1.542 + repository requires frequent manual <quote>repacks</quote> of 1.543 + its metadata. Without these, performance degrades, while 1.544 + space usage grows rapidly. A server that contains many Git 1.545 + repositories that are not rigorously and frequently repacked 1.546 + will become heavily disk-bound during backups, and there have 1.547 + been instances of daily backups taking far longer than 24 1.548 + hours as a result. A freshly packed Git repository is 1.549 + slightly smaller than a Mercurial repository, but an unpacked 1.550 + repository is several orders of magnitude larger.</para> 1.551 + 1.552 + <para>The core of Git is written in C. Many Git commands are 1.553 + implemented as shell or Perl scripts, and the quality of these 1.554 + scripts varies widely. I have encountered several instances 1.555 + where scripts charged along blindly in the presence of errors 1.556 + that should have been fatal.</para> 1.557 + 1.558 + <para>Mercurial can import revision history from a Git 1.559 + repository.</para> 1.560 + 1.561 + 1.562 + </sect2> 1.563 + <sect2> 1.564 + <title>CVS</title> 1.565 + 1.566 + <para>CVS is probably the most widely used revision control tool 1.567 + in the world. Due to its age and internal untidiness, it has 1.568 + been only lightly maintained for many years.</para> 1.569 + 1.570 + <para>It has a centralised client/server architecture. It does 1.571 + not group related file changes into atomic commits, making it 1.572 + easy for people to <quote>break the build</quote>: one person 1.573 + can successfully commit part of a change and then be blocked 1.574 + by the need for a merge, causing other people to see only a 1.575 + portion of the work they intended to do. This also affects 1.576 + how you work with project history. If you want to see all of 1.577 + the modifications someone made as part of a task, you will 1.578 + need to manually inspect the descriptions and timestamps of 1.579 + the changes made to each file involved (if you even know what 1.580 + those files were).</para> 1.581 + 1.582 + <para>CVS has a muddled notion of tags and branches that I will 1.583 + not attempt to even describe. It does not support renaming of 1.584 + files or directories well, making it easy to corrupt a 1.585 + repository. It has almost no internal consistency checking 1.586 + capabilities, so it is usually not even possible to tell 1.587 + whether or how a repository is corrupt. I would not recommend 1.588 + CVS for any project, existing or new.</para> 1.589 + 1.590 + <para>Mercurial can import CVS revision history. However, there 1.591 + are a few caveats that apply; these are true of every other 1.592 + revision control tool's CVS importer, too. Due to CVS's lack 1.593 + of atomic changes and unversioned filesystem hierarchy, it is 1.594 + not possible to reconstruct CVS history completely accurately; 1.595 + some guesswork is involved, and renames will usually not show 1.596 + up. Because a lot of advanced CVS administration has to be 1.597 + done by hand and is hence error-prone, it's common for CVS 1.598 + importers to run into multiple problems with corrupted 1.599 + repositories (completely bogus revision timestamps and files 1.600 + that have remained locked for over a decade are just two of 1.601 + the less interesting problems I can recall from personal 1.602 + experience).</para> 1.603 + 1.604 + <para>Mercurial can import revision history from a CVS 1.605 + repository.</para> 1.606 + 1.607 + 1.608 + </sect2> 1.609 + <sect2> 1.610 + <title>Commercial tools</title> 1.611 + 1.612 + <para>Perforce has a centralised client/server architecture, 1.613 + with no client-side caching of any data. Unlike modern 1.614 + revision control tools, Perforce requires that a user run a 1.615 + command to inform the server about every file they intend to 1.616 + edit.</para> 1.617 + 1.618 + <para>The performance of Perforce is quite good for small teams, 1.619 + but it falls off rapidly as the number of users grows beyond a 1.620 + few dozen. Modestly large Perforce installations require the 1.621 + deployment of proxies to cope with the load their users 1.622 + generate.</para> 1.623 + 1.624 + 1.625 + </sect2> 1.626 + <sect2> 1.627 + <title>Choosing a revision control tool</title> 1.628 + 1.629 + <para>With the exception of CVS, all of the tools listed above 1.630 + have unique strengths that suit them to particular styles of 1.631 + work. There is no single revision control tool that is best 1.632 + in all situations.</para> 1.633 + 1.634 + <para>As an example, Subversion is a good choice for working 1.635 + with frequently edited binary files, due to its centralised 1.636 + nature and support for file locking.</para> 1.637 + 1.638 + <para>I personally find Mercurial's properties of simplicity, 1.639 + performance, and good merge support to be a compelling 1.640 + combination that has served me well for several years.</para> 1.641 + 1.642 + 1.643 + </sect2> 1.644 + </sect1> 1.645 + <sect1> 1.646 + <title>Switching from another tool to Mercurial</title> 1.647 + 1.648 + <para>Mercurial is bundled with an extension named <literal 1.649 + role="hg-ext">convert</literal>, which can incrementally 1.650 + import revision history from several other revision control 1.651 + tools. By <quote>incremental</quote>, I mean that you can 1.652 + convert all of a project's history to date in one go, then rerun 1.653 + the conversion later to obtain new changes that happened after 1.654 + the initial conversion.</para> 1.655 + 1.656 + <para>The revision control tools supported by <literal 1.657 + role="hg-ext">convert</literal> are as follows:</para> 1.658 + <itemizedlist> 1.659 + <listitem><para>Subversion</para></listitem> 1.660 + <listitem><para>CVS</para></listitem> 1.661 + <listitem><para>Git</para></listitem> 1.662 + <listitem><para>Darcs</para></listitem></itemizedlist> 1.663 + 1.664 + <para>In addition, <literal role="hg-ext">convert</literal> can 1.665 + export changes from Mercurial to Subversion. This makes it 1.666 + possible to try Subversion and Mercurial in parallel before 1.667 + committing to a switchover, without risking the loss of any 1.668 + work.</para> 1.669 + 1.670 + <para>The <command role="hg-ext-conver">convert</command> command 1.671 + is easy to use. Simply point it at the path or URL of the 1.672 + source repository, optionally give it the name of the 1.673 + destination repository, and it will start working. After the 1.674 + initial conversion, just run the same command again to import 1.675 + new changes.</para> 1.676 + </sect1> 1.677 +</chapter> 1.678 + 1.679 +<!-- 1.680 +local variables: 1.681 +sgml-parent-document: ("00book.xml" "book" "chapter") 1.682 +end: 1.683 +-->