comparison Hg.txt @ 1:608947872f72

Add intro and some minor edits.
author Jim Hague <jim.hague@acm.org>
date Thu, 11 Dec 2008 11:17:15 +0000
parents 48d338d29ce9
children ee7f1e2c01a6
comparison
equal deleted inserted replaced
0:48d338d29ce9 1:608947872f72
21 Bugger. 21 Bugger.
22 22
23 Let's look into Mercurial 23 Let's look into Mercurial
24 ------------------------- 24 -------------------------
25 25
26 Mercurial is a Distributed Version Control System (DVCS). It's one of a 26 If you're at all interested in version control systems - and any
27 number of DVCSs that have gained significant popularity in the 27 software developer not using one daily is a strange beast indeed -
28 last few years. I switched a significant work project over to Mercurial 28 you'll at least have become vaguely aware in the last few years of the
29 (from Subversion) over a year ago, because a customer site required 29 growing maturity of the latest group of version control systems
30 on-site work but could not allow access back to the company VPN. I 30 offering funky new stuff. These are the distributed version control
31 chose Mercurial for a variety of reasons which I won't bore you with 31 systems (DVCS). There is more to them than just their headline
32 here. If you must know, see the box. 32 attributes, being able to check history and do checkins while
33 disconnected from a central server, but these are damm useful to start
34 with.
35
36 When I first heard about DVCS, it wasn't immediately obvious to me (to
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
39 how do you cope without the central server forcing ordering onto the
40 changes?
41
42 Since then I've started using Mercurial. Mercurial is a DVCS. It's one
43 of three DVCSs that have gained significant popularity in the last few
44 years, the other two being Git and Bazaar. I switched a significant
45 work project over to Mercurial (from Subversion) over a year ago,
46 because a customer site required on-site work but could not allow
47 access back to the company VPN. I chose Mercurial for a variety of
48 reasons which I won't bore you with here. If you must know, see the
49 box.
33 50
34 What I want to do in this article is give you an insight into how a 51 What I want to do in this article is give you an insight into how a
35 DVCS works. OK, so specifically I'm going to be talking about 52 DVCS works. OK, so specifically I'm going to be talking about
36 Mercurial, but Git and Bazaar attack the problem in a similar way. But 53 Mercurial, but Git and Bazaar attack the problem in a similar way. But
37 first I'd better give you some idea of how you use Mercurial. 54 first I'd better give you some idea of how you use Mercurial.
173 At this point you may be wondering about directories. 'hg mkdir' 190 At this point you may be wondering about directories. 'hg mkdir'
174 perhaps? Well, no. Mercurial only tracks files. To be sure, the 191 perhaps? Well, no. Mercurial only tracks files. To be sure, the
175 directory a file occupies is tracked, but effectively only as a 192 directory a file occupies is tracked, but effectively only as a
176 component of the file name. This has the slightly unexpected result 193 component of the file name. This has the slightly unexpected result
177 that you can't record an empty directory in your repository. 194 that you can't record an empty directory in your repository.
195
178 (Footnote: I tripped over this converting a work Subversion 196 (Footnote: I tripped over this converting a work Subversion
179 repository. One possibility is to create a placemaker file in the 197 repository. One possibility is to create a placemaker file in the
180 directory. In the event I created the directory (which receives build 198 directory. In the event I created the directory (which receives build
181 products) as part of the build instead.) 199 products) as part of the build instead.)
182 200
251 into a foreign repository. By default these will act on the repository 269 into a foreign repository. By default these will act on the repository
252 you cloned from, but you can specify any other repository. 270 you cloned from, but you can specify any other repository.
253 271
254 More on those in a moment. First, though, I want to show you something 272 More on those in a moment. First, though, I want to show you something
255 you can't do in Subversion. Start with the repository with 4 changes 273 you can't do in Subversion. Start with the repository with 4 changes
256 we just cloned. Let's focus on the first couple of lines. 274 we just cloned. I want to focus on the first couple of lines, so I'll
275 wind the working copy back to the point where only those lines exist.
257 276
258 $ hg update -r 1 277 $ hg update -r 1
259 1 files updated, 0 files merged, 1 files removed, 0 files unresolved 278 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
260 279
261 And make a change. 280 And make a change.
361 he started his takeoff run. 380 he started his takeoff run.
362 $ hg commit -m "Merge first line branch" 381 $ hg commit -m "Merge first line branch"
363 $ 382 $
364 383
365 (Footnote: I'm no poet. The poem is, of course, 'Silly Old Baboon' by 384 (Footnote: I'm no poet. The poem is, of course, 'Silly Old Baboon' by
366 the late, great, Spike Milligan.) 385 the late, great, Spike Milligan. From 'A Book of Milliganimals',
386 Puffin, 1971.)
367 387
368 Here's the ASCII art again showing what just happened. Oh, and notice 388 Here's the ASCII art again showing what just happened. Oh, and notice
369 that Mercurial has done the right thing with regard to the rename. 389 that Mercurial has done the right thing with regard to the rename.
370 390
371 $ hg glog 391 $ hg glog