Mercurial > CVu-Mercurial
annotate 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 |
rev | line source |
---|---|
0 | 1 Inside a distributed version control system |
2 =========================================== | |
3 | |
4 Grinton Lodge is a Youth Hostel that sits on an exposed hillside just | |
5 above the small hamlet of Grinton in Swaledale, in the Yorkshire Dales | |
6 National Park. A former Victorian shooting lodge, it now welcomes | |
7 walkers and other travellers from around the world. | |
8 | |
9 Tonight, a Wednesday in mid-November, is not one of its busiest | |
10 nights. Kat, the duty staff member, tells me that there is a small | |
11 corporate team-building group in the annex. There's no sign of them at | |
12 present. Otherwise, that portion of the world that has beaten a path | |
13 to the door of this grand building today consists of just me. And Kat | |
14 goes home soon. | |
15 | |
16 The November CVu, removed from its wrappers and read yesterday, lies | |
17 in my bag. Taunting me. Go on, it says, if you've ever going to put | |
18 finger to keyboard in the name of CVu, well, tonight you are out of | |
19 excuses. | |
20 | |
21 Bugger. | |
22 | |
23 Let's look into Mercurial | |
24 ------------------------- | |
25 | |
1
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
26 If you're at all interested in version control systems - and any |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
27 software developer not using one daily is a strange beast indeed - |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
28 you'll at least have become vaguely aware in the last few years of the |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
29 growing maturity of the latest group of version control systems |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
30 offering funky new stuff. These are the distributed version control |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
31 systems (DVCS). There is more to them than just their headline |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
32 attributes, being able to check history and do checkins while |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
33 disconnected from a central server, but these are damm useful to start |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
34 with. |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
35 |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
36 When I first heard about DVCS, it wasn't immediately obvious to me (to |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
37 put it mildly) how they would work. After years of using a centralised |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
38 version control system, I had rough mental model of what went on. But |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
39 how do you cope without the central server forcing ordering onto the |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
40 changes? |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
41 |
6
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
42 Since then I've started using Mercurial |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
43 (http://www.selenic.com/mercurial). Mercurial is a DVCS. It's one of |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
44 three DVCSs that have gained significant popularity in the last few |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
45 years, the other two being Git (http://git-scm.com) and Bazaar |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
46 (http://bazaar-vcs.org/). I switched a significant work project over |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
47 to Mercurial (from Subversion) in mid-1997, because a customer site |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
48 required on-site work but could not allow access back to the company |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
49 VPN. I chose Mercurial for a variety of reasons which I won't bore you |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
50 with here. If you must know, see the box. |
0 | 51 |
52 What I want to do in this article is give you an insight into how a | |
53 DVCS works. OK, so specifically I'm going to be talking about | |
54 Mercurial, but Git and Bazaar attack the problem in a similar way. But | |
55 first I'd better give you some idea of how you use Mercurial. | |
56 | |
57 :::: | |
58 Box: OK, if you must know: | |
59 | |
60 o Implementability. I needed the system to work on Windows, Linux and | |
61 AIX. The latter was not one of the directly supported platforms for | |
62 any of the candidates. Git's implementation uses a horde of | |
63 tools. Bazaar requires only Python, but required Python 2.4 while IBM | |
64 stubbornly still supplies only Python 2.3. Mercurial requires Python | |
65 2.3 or greater, and uses some C for speed. | |
66 | |
2
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
67 o Simplicity. My users used Subversion daily, but did not generally |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
68 have much experience with other VCS. From the command line, |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
69 Mercurial's core operations will be familiar to a Subversion |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
70 user. This is also true of Bazaar, but was less true of Git. Git has |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
71 improved in this matter since then, but a Mr Winder of this parish |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
72 tells me that it's still possible to seriously embarass |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
73 yourself. There was also a lack of Windows support for Git at the |
ee7f1e2c01a6
Expand slightly on simplicity section of 'Why Mercurial'.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
1
diff
changeset
|
74 time. |
0 | 75 |
76 o Speed. Mercurial is fast. In the same ballpark as Git. Bazaar | |
77 wasn't, and although it has improved significantly, has, in my | |
78 estimation, added user complexity in the process, and is still off the | |
79 pace for some operations. | |
80 | |
81 o Documentation. At the time, Bryan O'Sullivan's excellent Mercurial | |
82 book (http://hgbook.red-bean.com) was a clear winner for best | |
83 documentation. | |
84 :::: | |
85 | |
86 The 5 minute Mercurial overview | |
87 ------------------------------- | |
88 | |
89 I think it unlikely that someone possessing the taste and discernment | |
90 to be reading CVu would not be familiar with at least one version | |
91 control system. So, while I want to give you a flavour of what it's | |
92 like to use, I'm not going to hang about. If you'd like a proper | |
93 introduction, or you don't follow something, I thoroughly recommend | |
94 you consult the Mercurial book. | |
95 | |
96 To start using Mercurial to keep track of a project. | |
97 | |
98 $ hg init | |
99 $ | |
100 | |
101 This creates the repository root in the current directory. | |
102 | |
6
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
103 Like CVS (http://www.nongnu.org/cvs/) with its CVS directory and |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
104 Subversion (http://subversion.tigris.org/) with its .svn directory, |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
105 Mercurial keeps its private data in a directory. Mercifully there is |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
106 only one of these, in the top level of your project. And rather than |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
107 holding details of where the actual repository is to be found, the .hg |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
108 directory holds the entire repository. |
0 | 109 |
110 Next you need to specify the files you want Mercurial to track. | |
111 | |
112 $ echo "There was a gibbon one morning" > pome.txt | |
113 $ hg add pome.txt | |
114 $ | |
115 | |
116 As you might expect, this marks the files as to be added. And as you | |
117 might also expect, you need to commit to record the added files in the | |
118 repository. The commit comment can be supplied on the command line; if | |
119 you don't supply a comment, you'll be dropped into an editor to | |
120 provide one. | |
121 | |
122 There is a suggested format for these messages - a one line summary | |
123 followed by any more required detail on following lines. By default | |
124 Mercurial will only display the first line of commit messages when | |
125 listing changes. In these examples I'll stick to terse messages, and | |
126 I'll enter them from the command line. | |
127 | |
128 $ hg commit -m "My Pome" -u "Jim Hague <jim.hague@acm.org>" | |
129 $ | |
130 | |
131 Mercurial records the user making the change as part of the change | |
132 information. It is usual to give your name and email address as I've | |
133 done here. You can imagine, though, that constantly having to repeat | |
134 this is a bit tedious, so you can set a default user name in a | |
135 configuration file. Mercurial keeps global, user and repository | |
136 configurations, and it can go in any of those. | |
137 | |
138 As with Subversion, after further edits you see how your working copy | |
139 differs from the repository. | |
140 | |
141 $ hg status | |
142 M pome.txt | |
143 $ hg diff | |
144 diff -r 33596ef855c1 pome.txt | |
145 --- a/pome.txt Wed Apr 23 22:36:33 2008 +0100 | |
146 +++ b/pome.txt Wed Apr 23 22:48:01 2008 +0100 | |
147 @@ -1,1 +1,2 @@ There was a gibbon one morning | |
148 There was a gibbon one morning | |
149 +said "I think I will fly to the moon". | |
150 $ hg commit -m "A great second line" | |
151 $ | |
152 | |
153 And look through a log of changes. | |
154 | |
155 $ hg log | |
156 changeset: 1:3d65e7a57890 | |
157 tag: tip | |
158 user: Jim Hague <jim.hague@acm.org> | |
159 date: Wed Apr 23 22:49:10 2008 +0100 | |
160 summary: A great second line | |
161 | |
162 changeset: 0:33596ef855c1 | |
163 user: Jim Hague <jim.hague@acm.org> | |
164 date: Wed Apr 23 22:36:33 2008 +0100 | |
165 summary: My Pome | |
166 | |
167 $ | |
168 | |
169 There are some items here that need an explanation. | |
170 | |
171 The changeset identifer is in fact two identifiers separated by a | |
172 colon. The first is the sequence number of the changeset in the | |
173 repository, and is directly comparable to the change number in a | |
174 Subversion repository. The second is a globally unique identifier for | |
175 that change. As the change is copied from one repository to another | |
176 (this is a distributed system, remember, even if we haven't come to | |
177 that bit yet), its sequence number in any particular repository will | |
178 change, but the global identifier will always remain the same. | |
179 | |
180 'tip' is a Mercurial term. It means simply the most recent change. | |
181 | |
182 Want to rename a file? | |
183 | |
184 $ hg mv pome.txt poem.txt | |
185 $ hg status | |
186 A poem.txt | |
187 R pome.txt | |
188 $ hg commit -m "Rename my file" | |
189 $ | |
190 | |
191 (The command to rename a file is actually 'hg rename', but Mercurial | |
192 saves Unix-trained fingers from typing embarrassment.) | |
193 | |
194 At this point you may be wondering about directories. 'hg mkdir' | |
195 perhaps? Well, no. Mercurial only tracks files. To be sure, the | |
196 directory a file occupies is tracked, but effectively only as a | |
197 component of the file name. This has the slightly unexpected result | |
198 that you can't record an empty directory in your repository. | |
1
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
199 |
0 | 200 (Footnote: I tripped over this converting a work Subversion |
201 repository. One possibility is to create a placemaker file in the | |
202 directory. In the event I created the directory (which receives build | |
203 products) as part of the build instead.) | |
204 | |
205 Given this, and the status output above that suggests strongly that | |
206 Mercurial treats a rename as a copy followed by a delete, you may be | |
207 worried that Mercurial won't cope at all well with rearranging your | |
208 repository. Relax. Mercurial does store the details of the rename as | |
209 part of the changeset, and copes very well with rearrangements. | |
210 | |
211 (Footnote: The Mercurial designers justify not dealing with | |
212 directories as first class objects by pointing out that provided you | |
213 can correctly move files about in the tree, the other reasons for | |
214 tracking directories are uncommon and do not in their opinion justify | |
215 the considerable added complexity. So far I've found no reason to | |
216 doubt that judgement.) | |
217 | |
218 Want to rewind the working copy to a previous revision? | |
219 | |
220 $ hg update -r 1 | |
221 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
222 $ | |
223 | |
224 'hg update' updates the working files. In this case I'm specifying | |
225 that I want to go back to local changeset 1. I could also have typed | |
226 '-r 3d65e7a57890', or even '-r 3d'; when specifying the global change | |
227 identifier you only need to type enough digits to make it unique. | |
228 | |
229 This is all very well, but it's not exactly distributed, is it? | |
230 | |
231 Copy an existing repository: | |
232 | |
233 elsewhere$ hg clone ssh://jim.home.net/Poem Jim-Poem | |
234 updating working directory | |
235 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
236 | |
237 (You can access other repositories via the file system, over http or | |
238 over ssh). | |
239 | |
240 elsewhere$ cd Jim-Poem | |
241 elsewhere$ hg log | |
242 changeset: 3:a065eb26e6b9 | |
243 tag: tip | |
244 user: Jim Hague <jim.hague@acm.org> | |
245 date: Thu Apr 24 18:52:31 2008 +0100 | |
246 summary: Rename my file | |
247 | |
248 changeset: 2:ff97668b7422 | |
249 user: Jim Hague <jim.hague@acm.org> | |
250 date: Thu Apr 24 18:50:22 2008 +0100 | |
251 summary: Finished first verse | |
252 | |
253 changeset: 1:3d65e7a57890 | |
254 user: Jim Hague <jim.hague@acm.org> | |
255 date: Wed Apr 23 22:49:10 2008 +0100 | |
256 summary: A great second line | |
257 | |
258 changeset: 0:33596ef855c1 | |
259 user: Jim Hague <jim.hague@acm.org> | |
260 date: Wed Apr 23 22:36:33 2008 +0100 | |
261 summary: My Pome | |
262 | |
263 'hg clone' is aptly named. It creates a new repository that contains | |
264 exactly the same changes as the source repository. You can make a | |
265 clone just by copying your project directory, if you're confident | |
266 nothing else will access it during the copy. 'hg clone' saves you this | |
267 worry, and sets the default push/pull location in the new repo to the | |
268 cloned repo. | |
269 | |
270 From that point, you use 'hg pull' to collect changes from other | |
271 places into your repo (though note it does not by default update your | |
272 working copy), and, as you might guess, 'hg push' shoves your changes | |
273 into a foreign repository. By default these will act on the repository | |
274 you cloned from, but you can specify any other repository. | |
275 | |
276 More on those in a moment. First, though, I want to show you something | |
277 you can't do in Subversion. Start with the repository with 4 changes | |
1
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
278 we just cloned. I want to focus on the first couple of lines, so I'll |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
279 wind the working copy back to the point where only those lines exist. |
0 | 280 |
281 $ hg update -r 1 | |
282 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
283 | |
284 And make a change. | |
285 | |
286 $ hg diff | |
287 diff -r 3d65e7a57890 pome.txt | |
288 --- a/pome.txt Wed Apr 23 22:49:10 2008 +0100 | |
289 +++ b/pome.txt Thu Apr 24 19:13:14 2008 +0100 | |
290 @@ -1,2 +1,2 @@ There was a gibbon one morning | |
291 -There was a gibbon one morning | |
292 -said "I think I will fly to the moon". | |
293 +There was a baboon who one afternoon | |
294 +said "I think I will fly to the sun". | |
295 $ hg commit -m "Better first two lines" | |
296 $ | |
297 | |
298 The alert among you will have sat up at that. Well done! Yes, there's | |
299 something very worrying. How can I commit a change at an old point? | |
300 If you try this in Subversion, it will complain mightily about your | |
301 file being out of date. But Mercurial just went ahead and did | |
302 something. The Bazaar experts among you will know that in Bazaar, if | |
303 you use 'bzr revert -r' to bring the working copy to a past revision, | |
304 make a change and commit, then your latest version will be the past | |
305 revision plus your change. Perhaps that's what Mercurial did? | |
306 | |
307 No. What Mercurial did is central to Mercurial's view of the | |
308 world. You took your working copy back to an old changeset, and the | |
309 committed a fresh change based at that changeset. Mercurial actually | |
310 did just what you asked it to do, no more and no less. Let's see the | |
311 initial evidence. | |
312 | |
313 $ hg heads | |
314 changeset: 4:267d32f158b3 | |
315 tag: tip | |
316 parent: 1:3d65e7a57890 | |
317 user: Jim Hague <jim.hague@acm.org> | |
318 date: Thu Apr 24 19:13:59 2008 +0100 | |
319 summary: Better first two lines | |
320 | |
321 changeset: 3:a065eb26e6b9 | |
322 user: Jim Hague <jim.hague@acm.org> | |
323 date: Thu Apr 24 18:52:31 2008 +0100 | |
324 summary: Rename my file | |
325 | |
326 $ | |
327 | |
328 Time for some more Mercurial terminology. You can think of a 'head' in | |
329 Mercurial as the most recent change on a branch. In Mercurial, a | |
330 branch is simply what happens when you commit a change that has as its | |
331 parent a change that already has a child. Mercurial has a standard | |
332 extension 'hg glog' which uses some ASCII art to show the current | |
333 state: | |
334 | |
335 $ hg glog | |
336 @ changeset: 4:267d32f158b3 | |
337 | tag: tip | |
338 | parent: 1:3d65e7a57890 | |
339 | user: Jim Hague <jim.hague@acm.org> | |
340 | date: Thu Apr 24 19:13:59 2008 +0100 | |
341 | summary: Better first two lines | |
342 | | |
343 | o changeset: 3:a065eb26e6b9 | |
344 | | user: Jim Hague <jim.hague@acm.org> | |
345 | | date: Thu Apr 24 18:52:31 2008 +0100 | |
346 | | summary: Rename my file | |
347 | | | |
348 | o changeset: 2:ff97668b7422 | |
349 |/ user: Jim Hague <jim.hague@acm.org> | |
350 | date: Thu Apr 24 18:50:22 2008 +0100 | |
351 | summary: Finished first verse | |
352 | | |
353 o changeset: 1:3d65e7a57890 | |
354 | user: Jim Hague <jim.hague@acm.org> | |
355 | date: Wed Apr 23 22:49:10 2008 +0100 | |
356 | summary: A great second line | |
357 | | |
358 o changeset: 0:33596ef855c1 | |
359 user: Jim Hague <jim.hague@acm.org> | |
360 date: Wed Apr 23 22:36:33 2008 +0100 | |
361 summary: My Pome | |
362 | |
363 $ | |
364 | |
365 'hg view' shows a nicer graphical view. (Footnote: Though, being | |
366 Tcl/Tk based, not that much nicer.) | |
367 | |
368 So the change is in there. It's the latest change, and is simply on a | |
369 different branch to the other changes. | |
370 | |
371 Almost invariably, you will want to bring everything back together and | |
372 merge the branches. A merge is a change that combines two heads back | |
373 into one. It prepares an updated working directory with the merged | |
374 contents of the two heads for you to review and, if satisfactory, commit. | |
375 | |
376 $ hg merge | |
377 merging pome.txt and poem.txt | |
378 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
379 (branch merge, don't forget to commit) | |
380 $ cat poem.txt | |
381 There was a baboon who one afternoon | |
382 said "I think I will fly to the sun". | |
383 So with two great palms strapped to his arms, | |
384 he started his takeoff run. | |
385 $ hg commit -m "Merge first line branch" | |
386 $ | |
387 | |
388 (Footnote: I'm no poet. The poem is, of course, 'Silly Old Baboon' by | |
1
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
389 the late, great, Spike Milligan. From 'A Book of Milliganimals', |
608947872f72
Add intro and some minor edits.
Jim Hague <jim.hague@acm.org>
parents:
0
diff
changeset
|
390 Puffin, 1971.) |
0 | 391 |
392 Here's the ASCII art again showing what just happened. Oh, and notice | |
3
175493e0e457
Minor edit pointing better to rename handling.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
2
diff
changeset
|
393 in the above that Mercurial has done the right thing with regard to |
175493e0e457
Minor edit pointing better to rename handling.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
2
diff
changeset
|
394 the rename. |
0 | 395 |
396 $ hg glog | |
397 @ changeset: 5:792ab970fc80 | |
398 |\ tag: tip | |
399 | | parent: 4:267d32f158b3 | |
400 | | parent: 3:a065eb26e6b9 | |
401 | | user: Jim Hague <jim.hague@acm.org> | |
402 | | date: Thu Apr 24 19:29:53 2008 +0100 | |
403 | | summary: Merge first line branch | |
404 | | | |
405 | o changeset: 4:267d32f158b3 | |
406 | | parent: 1:3d65e7a57890 | |
407 | | user: Jim Hague <jim.hague@acm.org> | |
408 | | date: Thu Apr 24 19:13:59 2008 +0100 | |
409 | | summary: Better first two lines | |
410 | | | |
411 o | changeset: 3:a065eb26e6b9 | |
412 | | user: Jim Hague <jim.hague@acm.org> | |
413 | | date: Thu Apr 24 18:52:31 2008 +0100 | |
414 | | summary: Rename my file | |
415 | | | |
416 o | changeset: 2:ff97668b7422 | |
417 |/ user: Jim Hague <jim.hague@acm.org> | |
418 | date: Thu Apr 24 18:50:22 2008 +0100 | |
419 | summary: Finished first verse | |
420 | | |
421 o changeset: 1:3d65e7a57890 | |
422 | user: Jim Hague <jim.hague@acm.org> | |
423 | date: Wed Apr 23 22:49:10 2008 +0100 | |
424 | summary: A great second line | |
425 | | |
426 o changeset: 0:33596ef855c1 | |
427 user: Jim Hague <jim.hague@acm.org> | |
428 date: Wed Apr 23 22:36:33 2008 +0100 | |
429 summary: My Pome | |
430 | |
431 $ | |
432 | |
433 So, our little branch change has now been merged back, and we have a | |
434 single line of development again. Notice that unlike the other | |
435 changesets, changeset 5 has two parent changesets, indicating it is a | |
436 merge changeset. You can only merge two branches in one operation; or | |
437 putting it another way, a changeset can have a maximum of two parents. | |
438 | |
439 This behaviour is absolutely central to Mercurial's philosophy. If a | |
440 change is committed that takes as its starting point a change that | |
441 already has a child, then a branch gets created. Working with | |
442 Mercurial, branches get created frequently, and equally frequently | |
443 merged back. As befits any frequent operation, both are easy to do. | |
444 | |
445 You're probably thinking at this point that this making a commit onto | |
446 an old version is a slightly strange thing to do, and you'd be right. | |
447 But that's exactly what's going to happen the moment you go | |
448 distributed. Two people working independently with their own | |
449 repositories are going to make commits based, typically, on the latest | |
450 changes they happen to have incorporated into their tree. To be | |
451 Distributed, a DVCS has to deal with this. Mercurial faces it head-on. | |
452 When you pull changes into your repo (or someone else pushes them), if | |
453 any of the changes overlap - are both based on the same base change - | |
454 you get extra heads, and it's up to you to let these extra heads live | |
455 or merge, as you please. | |
456 | |
457 In practice this is more manageable then you might think. Consider a | |
458 typical Mercurial usage, where the 'master' repo sits on a known | |
459 server, and everyone pulls changes from the master and pushes their | |
460 own efforts the master. But default Mercurial won't let you push if | |
461 the receiving repo will gain an extra head as a result, so you | |
462 typically pull (and do any required merging) just before | |
463 pushing. Subversion users will recognised this pattern. Subversion | |
464 won't let you commit a change if your working copy is not at the very | |
465 latest revision, so the Subversion user will update, and merge if | |
466 necessary, just before committing. | |
467 | |
468 What, then, about a branch in the conventional sense of '1.0 | |
469 maintenance branch'? Typically in Mercurial you'd handle this by | |
470 keeping a separate cloned repository for those changes. Cloning is | |
471 fast, and if local uses hard links where possible on filesystems that | |
472 support them, so isn't necessarily extravagant on disc space. You can, | |
473 if you prefer, handle them all in a single repo with 'named | |
474 branches', but cloning is definitely simpler. | |
475 | |
476 OK, so now you know the basics of using Mercurial. We can proceed to | |
477 looking at how this magic is achieved. In particular, where does this | |
478 magic globally unique identifier for a change come from? | |
479 | |
480 Inside the Mercurial repo | |
481 ------------------------- | |
482 | |
483 The way Mercurial handles its repo is really quite simple. | |
484 | |
485 That's simple, as in 'most things are simple once you know the | |
486 answer'. I found the explanation helpful, so this section attempts | |
487 the 10,000ft (FL100 if you prefer) view of Mercurial. | |
488 | |
489 (Foornote: Bryan O'Sullivan's excellent Mercurial book has a chapter | |
490 on the subject, and the Mercurial website has a fair amount of detail | |
491 too. This is 'research', OK?) | |
492 | |
493 First remember that any file or component can only have one or two | |
494 parents. You can't merge more than one other branch at once. | |
495 | |
496 We start with the basic building block, which Mercurial calls a | |
497 revlog. A revlog is a thing that holds a file and all the changes in | |
498 the file history. (Footnote: For any non-trivial file, this will | |
499 actually be two files on the disc, a data file and an index). The | |
5
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
500 revlog stores the differences between successive versions |
0 | 501 of the file, though it will periodically store a complete version of |
502 the file instead of a difference, so that the content of any | |
503 particular file version can always be reconstructed without excessive | |
504 effort. | |
505 | |
506 Under the secret-squirrel Mercurial .hg directory at the top of your | |
5
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
507 project is a store which holds a revlog for each file in your |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
508 project. So you have the complete history of the project locally. No |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
509 more round trips to the server. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
510 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
511 Both the differences between successive versions and the periodic |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
512 complete versions of a file are compressed before storing. This is |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
513 surprisingly effective at minimising the storage requirements this |
6
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
514 entire history of your project. I have a small Java project handy, |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
515 comprising a little over 300 source modules. There are 5 branches plus |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
516 the mainline, and some 1920 commits in all. A Subversion checkout of |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
517 the current mainline takes 51Mb. Converting the project to Mercurial |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
518 yields a Mercurial repository that takes 60Mb, so a little |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
519 bigger. Remember, though, that the Mercurial repository includes not |
a942bf7bc2ab
Add links for Git/Bzr etc. and figures for repository size.
Jim Hague <jim.hague@acm.org>
parents:
5
diff
changeset
|
520 just the working copy, but also the entire history of the project. |
0 | 521 |
522 Any point in the evolution of a revlog can be uniquely identified with | |
523 a nodeid. This is simply the SHA1 hash of the current file contents | |
524 concatenated with the nodeids of one or both parents of the current | |
525 revision. Note that this way, two file states are identical if and | |
526 only if the file contents are the same *and* the file has the | |
527 same history. | |
528 | |
529 Here's a dump of a revlog index: | |
530 | |
531 $ hg debugindex .hg/store/data/pome.txt.i | |
532 rev offset length base linkrev nodeid p1 p2 | |
533 0 0 32 0 0 6bbbd5d6cc53 000000000000 000000000000 | |
534 1 32 51 0 1 83d266583303 6bbbd5d6cc53 000000000000 | |
535 2 83 84 0 2 14a54ec34bb6 83d266583303 000000000000 | |
536 3 167 76 3 4 dc4df776b38b 83d266583303 000000000000 | |
537 $ | |
538 | |
539 Note here that a file state can have two parents. If both the parent | |
540 nodeids are non-null, the file state has two parents, and the state is | |
541 therefore the result of a merge. | |
542 | |
543 Let's dump out a revlog at a particular revision: | |
544 | |
545 $ hg debugdata .hg/store/data/pome.txt.i 2 | |
546 There was a gibbon one morning | |
547 said "I think I will fly to the moon". | |
548 So with two great palms strapped to his arms, | |
549 he started his takeoff run. | |
550 $ | |
551 | |
552 The next component is the manifest. This is simply a list of all the | |
553 files in the project, together with their current nodeids. The | |
554 manifest is a file, held in a revlog. The nodeid of the manifest, | |
555 therefore, identifies the project filesystem at a particular point. | |
556 | |
557 $ hg debugdata .hg/store/00manifest.i 5 | |
558 poem.txt5168b1a5e2f44aa4e0f164e170820845183f50c8 | |
559 $ | |
560 | |
561 Finally we have the changeset. This is the atomic collection of | |
562 changes to a repository that leads to a new revision. The changeset | |
563 info includes the nodeid of the corresponding manifest, the timestamp | |
564 and committer ID, a list of changed files and a comment. The changeset | |
565 also includes the nodeid of the parent changeset, or the two parents | |
566 if the change is a merge. The changeset description is held in a | |
567 revlog, the changelog. | |
568 | |
569 $ hg debugdata .hg/store/00changelog.i 5 | |
570 1ccc11b6f7308cc8fa1573c2f3811a4710c91e3e | |
571 Jim Hague <jim.hague@acm.org> | |
572 1209061793 -3600 | |
573 poem.txt | |
574 pome.txt | |
575 | |
576 Merge first line branch | |
577 $ | |
578 | |
579 The nodeid of the changeset, therefore, gives us a globally unique | |
580 identifier for any particular change. Changesets have a | |
581 Subversion-like incrementing change number, but it is peculiar to that | |
582 repository. The nodeid, however, is global. | |
583 | |
584 One more detail remains to complete the picture. How do we get back | |
585 from a particular file change to find the responsible changeset? Each | |
586 revlog change has a linkrev entry that does just this. | |
587 | |
588 So, now we have a repository with a history of the changes applied to | |
589 that repository. Each change has a unique identifier. If we find that | |
590 change in another repository, it means that at the point in the other | |
591 repository we have exactly the same state; the file contents and | |
592 history are identical. | |
593 | |
594 At this point we can see how pulling changes from another repository | |
595 works. Mercurial has to determine which changesets in the source | |
596 repository are missing in the target repository. To do this, for each | |
597 head in the source repo it has to find the most recent change in that | |
598 head that it already present in the target repo, and get any remaining | |
599 changes after that point. These changes are then copied over and | |
600 applied. | |
601 | |
4
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
602 The Mercurial revlog format has proved remarkably durable. Since the |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
603 first release of Mercurial in April 2005, these have been a total of 5 |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
604 changes to the file format. However, of those, all but one have been |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
605 changes to the handling of file names. The most recent change, in |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
606 October 2008, and its predecessor in December 2006, were both |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
607 introduced purely to cope with Windows specific issues. The one change |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
608 that touched the datastructures described above was in April 2006. The |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
609 format introduced, RevLogNG, changed only the details of index data |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
610 held, not the overall design. The chief Mercurial developer, Matt |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
611 Mackall, notes that the code in present-day Mercurial devoted to |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
612 reading the old format comprises 28 lines of Python. Compared with, |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
613 say, the early tribulations of Subversion and the switch from bdfs to |
561edf852797
More detail on file format changes, from post by MM to mercurial.general.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
3
diff
changeset
|
614 fsfs, this is an impressive record. |
5
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
615 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
616 Reflections on going distributed |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
617 -------------------------------- |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
618 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
619 It's nearly traditional at this stage in an introduction to DVCS to |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
620 demonstrate several differenet workflow scanarios that you can build |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
621 with a DVCS. Which makes the important point that a DVCS can be |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
622 adapted to your workflow in a way that is at best unwieldy with a |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
623 CVCS. I intend, though, to break with tradition here. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
624 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
625 By this stage, I hope you can see that distributing version control |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
626 works by introducing branches where development takes place in |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
627 parallel. Mercurial treats these branches as arising naturally from |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
628 the commits made and transferred between repositories. Both Git and |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
629 Bazaar take a slightly different viewpoint, and explicitly generate a |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
630 fresh branch for work in a particular repositories. But in both cases |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
631 the underlying principle of identifying changes by a globally unique |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
632 identifier and resolving parallel development by merges between |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
633 overlapping changes is the same. And all three can be used in a truly |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
634 distributed manner, with full history and the ability to commit being |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
635 available locally. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
636 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
637 I want now to reflect on the consequences all this has for that |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
638 all-important question of whether a DVCS is a suitable vehicle for |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
639 your data. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
640 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
641 The first is a minor and rather obvious point. If you want to store |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
642 files that are both very large and which change often in your DVCS, |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
643 then all the compression in the world is unlikely to stop the storage |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
644 requirements for the full project history from becoming |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
645 uncomfortably large. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
646 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
647 The second, and main, point is that there is an important question you |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
648 need to ask about your data. We've seen that a DVCS relies on |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
649 branching and merging to weave its magic. So take a close look at your |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
650 data, and ask: |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
651 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
652 Will It Merge? |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
653 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
654 The subset of plain old text which comprises program source |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
655 code requires some human oversight, but will merge automatically |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
656 well enough for the process to be well within the bounds of the |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
657 possible. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
658 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
659 Unfortunately when we move further afield mergeability becomes a rarer |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
660 commodity. I nearly began the previous paragraph by stating that |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
661 plain old text will merge well enough. Then Doubt set in - what about |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
662 XML? Or BASE64 encoded content? |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
663 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
664 Of course, merge doesn't necessarily have to be textual merge. I am |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
665 told that Word can be used to diff and merge two Word .doc files, a |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
666 data format notorious for its binary impenetrability. As long as some |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
667 suitable merge agent is available, and the DVCS can be configured to |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
668 use it for data of a particular type (Footnote: Mercurial can have the |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
669 merge and diff tools specified with reference to the file extension on |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
670 which they operate - I assume Bazaar and Git are similar.), then there |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
671 is no bar to successful DVCS use. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
672 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
673 Before this reliance on mergeability causes you to dismiss DVCS out of |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
674 hand, reflect. A CVCS can only handle non-mergeable data by acting as |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
675 a versioned file store; in other words, having as the only available |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
676 merge option the use of one or other of the merge candidates in its |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
677 entireity. Useful though a versioned file store can be, it cannot be |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
678 considered a full-featured version control system. By treating the |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
679 offending unmergeable files as external to the DVCS, or with careful |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
680 workflow - disabling the distributed and mergeable potentials - a DVCS |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
681 can deal with these files, but only at a cost of its distributedness |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
682 or its version control system-ness. In this it differs little from a |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
683 CVCS. |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
684 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
685 So, for all data you want to version control, let your battle cry be |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
686 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
687 Will It Merge? |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
688 |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
689 At this point, I have an urge to don lab coat and safety goggles and |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
690 be videoed attempting to mechanically merge data in a variety of |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
691 different formats. Frankly, this is unlike to be as exciting at |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
692 blending iPhones (Ref: www.willitblend.com), but from a system |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
693 development point of view it's rather more important. And, I think |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
694 gives us a large clue as to one of the reasons for the continuing |
2ec53c0ed5d8
Musings on Merging and Mergeability.
Jim Hague <jim.hague@icc-atcsolutions.com>
parents:
4
diff
changeset
|
695 popularity of Plain Old Text as a source code representation mechanism. |