comparison Hg.txt @ 6:a942bf7bc2ab

Add links for Git/Bzr etc. and figures for repository size.
author Jim Hague <jim.hague@acm.org>
date Fri, 06 Mar 2009 21:17:07 +0000
parents 2ec53c0ed5d8
children 8660df02d8a9
comparison
equal deleted inserted replaced
5:2ec53c0ed5d8 6:a942bf7bc2ab
37 put it mildly) how they would work. After years of using a centralised 37 put it mildly) how they would work. After years of using a centralised
38 version control system, I had rough mental model of what went on. But 38 version control system, I had rough mental model of what went on. But
39 how do you cope without the central server forcing ordering onto the 39 how do you cope without the central server forcing ordering onto the
40 changes? 40 changes?
41 41
42 Since then I've started using Mercurial. Mercurial is a DVCS. It's one 42 Since then I've started using Mercurial
43 of three DVCSs that have gained significant popularity in the last few 43 (http://www.selenic.com/mercurial). Mercurial is a DVCS. It's one of
44 years, the other two being Git and Bazaar. I switched a significant 44 three DVCSs that have gained significant popularity in the last few
45 work project over to Mercurial (from Subversion) over a year ago, 45 years, the other two being Git (http://git-scm.com) and Bazaar
46 because a customer site required on-site work but could not allow 46 (http://bazaar-vcs.org/). I switched a significant work project over
47 access back to the company VPN. I chose Mercurial for a variety of 47 to Mercurial (from Subversion) in mid-1997, because a customer site
48 reasons which I won't bore you with here. If you must know, see the 48 required on-site work but could not allow access back to the company
49 box. 49 VPN. I chose Mercurial for a variety of reasons which I won't bore you
50 with here. If you must know, see the box.
50 51
51 What I want to do in this article is give you an insight into how a 52 What I want to do in this article is give you an insight into how a
52 DVCS works. OK, so specifically I'm going to be talking about 53 DVCS works. OK, so specifically I'm going to be talking about
53 Mercurial, but Git and Bazaar attack the problem in a similar way. But 54 Mercurial, but Git and Bazaar attack the problem in a similar way. But
54 first I'd better give you some idea of how you use Mercurial. 55 first I'd better give you some idea of how you use Mercurial.
97 $ hg init 98 $ hg init
98 $ 99 $
99 100
100 This creates the repository root in the current directory. 101 This creates the repository root in the current directory.
101 102
102 Like CVS with its CVS directory and Subversion with its .svn 103 Like CVS (http://www.nongnu.org/cvs/) with its CVS directory and
103 directory, Mercurial keeps its private data in a directory. Mercifully 104 Subversion (http://subversion.tigris.org/) with its .svn directory,
104 there is only one of these, in the top level of your project. And 105 Mercurial keeps its private data in a directory. Mercifully there is
105 rather than holding details of where the actual repository is to be 106 only one of these, in the top level of your project. And rather than
106 found, the .hg directory holds the entire repository. 107 holding details of where the actual repository is to be found, the .hg
108 directory holds the entire repository.
107 109
108 Next you need to specify the files you want Mercurial to track. 110 Next you need to specify the files you want Mercurial to track.
109 111
110 $ echo "There was a gibbon one morning" > pome.txt 112 $ echo "There was a gibbon one morning" > pome.txt
111 $ hg add pome.txt 113 $ hg add pome.txt
507 more round trips to the server. 509 more round trips to the server.
508 510
509 Both the differences between successive versions and the periodic 511 Both the differences between successive versions and the periodic
510 complete versions of a file are compressed before storing. This is 512 complete versions of a file are compressed before storing. This is
511 surprisingly effective at minimising the storage requirements this 513 surprisingly effective at minimising the storage requirements this
512 entire history of your project. <!!!Comparison of .svn space 514 entire history of your project. I have a small Java project handy,
513 requirements for Waldo>. 515 comprising a little over 300 source modules. There are 5 branches plus
516 the mainline, and some 1920 commits in all. A Subversion checkout of
517 the current mainline takes 51Mb. Converting the project to Mercurial
518 yields a Mercurial repository that takes 60Mb, so a little
519 bigger. Remember, though, that the Mercurial repository includes not
520 just the working copy, but also the entire history of the project.
514 521
515 Any point in the evolution of a revlog can be uniquely identified with 522 Any point in the evolution of a revlog can be uniquely identified with
516 a nodeid. This is simply the SHA1 hash of the current file contents 523 a nodeid. This is simply the SHA1 hash of the current file contents
517 concatenated with the nodeids of one or both parents of the current 524 concatenated with the nodeids of one or both parents of the current
518 revision. Note that this way, two file states are identical if and 525 revision. Note that this way, two file states are identical if and