comparison en/ch04-concepts.xml @ 739:a13813534ccd

Fix all xref to figs
author Dongsheng Song <dongsheng.song@gmail.com>
date Tue, 17 Mar 2009 10:43:45 +0800
parents cfdb601a3c8b
children
comparison
equal deleted inserted replaced
738:1a3d882149fd 739:a13813534ccd
45 small files without much history, the revision data and index 45 small files without much history, the revision data and index
46 are combined in a single <quote><literal>.i</literal></quote> 46 are combined in a single <quote><literal>.i</literal></quote>
47 file. The correspondence between a file in the working 47 file. The correspondence between a file in the working
48 directory and the filelog that tracks its history in the 48 directory and the filelog that tracks its history in the
49 repository is illustrated in figure <xref 49 repository is illustrated in figure <xref
50 endterm="fig.concepts.filelog.caption"
50 linkend="fig.concepts.filelog"/>.</para> 51 linkend="fig.concepts.filelog"/>.</para>
51 52
52 <informalfigure id="fig.concepts.filelog"> 53 <informalfigure id="fig.concepts.filelog">
53 <mediaobject><imageobject><imagedata 54 <mediaobject>
54 fileref="images/filelog.png"/></imageobject><textobject><phrase>XXX 55 <imageobject><imagedata fileref="images/filelog.png"/></imageobject>
55 add text</phrase></textobject> 56 <textobject><phrase>XXX add text</phrase></textobject>
56 <caption><para>Relationships between files in working 57 <caption><para id="fig.concepts.filelog.caption">Relationships between
57 directory and filelogs in 58 files in working directory and filelogs in repository</para>
58 repository</para></caption></mediaobject> 59 </caption>
60 </mediaobject>
59 </informalfigure> 61 </informalfigure>
60 62
61 </sect2> 63 </sect2>
62 <sect2> 64 <sect2>
63 <title>Managing tracked files</title> 65 <title>Managing tracked files</title>
95 revision stored in the changelog. Each revision of the 97 revision stored in the changelog. Each revision of the
96 changelog contains a pointer to a single revision of the 98 changelog contains a pointer to a single revision of the
97 manifest. A revision of the manifest stores a pointer to a 99 manifest. A revision of the manifest stores a pointer to a
98 single revision of each filelog tracked when that changeset 100 single revision of each filelog tracked when that changeset
99 was created. These relationships are illustrated in figure 101 was created. These relationships are illustrated in figure
100 <xref linkend="fig.concepts.metadata"/>.</para> 102 <xref endterm="fig.concepts.metadata.caption"
103 linkend="fig.concepts.metadata"/>.</para>
101 104
102 <informalfigure id="fig.concepts.metadata"> 105 <informalfigure id="fig.concepts.metadata">
103 <mediaobject><imageobject><imagedata 106 <mediaobject>
104 fileref="images/metadata.png"/></imageobject><textobject><phrase>XXX 107 <imageobject><imagedata fileref="images/metadata.png"/></imageobject>
105 add text</phrase></textobject><caption><para>Metadata 108 <textobject><phrase>XXX add text</phrase></textobject>
106 relationships</para></caption> 109 <caption><para id="fig.concepts.metadata.caption">Metadata
107 </mediaobject> 110 relationships</para></caption>
111 </mediaobject>
108 </informalfigure> 112 </informalfigure>
109 113
110 <para>As the illustration shows, there is 114 <para>As the illustration shows, there is
111 <emphasis>not</emphasis> a <quote>one to one</quote> 115 <emphasis>not</emphasis> a <quote>one to one</quote>
112 relationship between revisions in the changelog, manifest, or 116 relationship between revisions in the changelog, manifest, or
183 snapshot and your target revision. The more history that a 187 snapshot and your target revision. The more history that a
184 file accumulates, the more revisions you must read, hence the 188 file accumulates, the more revisions you must read, hence the
185 longer it takes to reconstruct a particular revision.</para> 189 longer it takes to reconstruct a particular revision.</para>
186 190
187 <informalfigure id="fig.concepts.snapshot"> 191 <informalfigure id="fig.concepts.snapshot">
188 <mediaobject><imageobject><imagedata 192 <mediaobject>
189 fileref="images/snapshot.png"/></imageobject><textobject><phrase>XXX 193 <imageobject><imagedata fileref="images/snapshot.png"/></imageobject>
190 add text</phrase></textobject><caption><para>Snapshot of 194 <textobject><phrase>XXX add text</phrase></textobject>
191 a revlog, with incremental 195 <caption><para id="fig.concepts.snapshot.caption">Snapshot of
192 deltas</para></caption></mediaobject> 196 a revlog, with incremental deltas</para></caption>
197 </mediaobject>
193 </informalfigure> 198 </informalfigure>
194 199
195 <para>The innovation that Mercurial applies to this problem is 200 <para>The innovation that Mercurial applies to this problem is
196 simple but effective. Once the cumulative amount of delta 201 simple but effective. Once the cumulative amount of delta
197 information stored since the last snapshot exceeds a fixed 202 information stored since the last snapshot exceeds a fixed
199 instead of another delta. This makes it possible to 204 instead of another delta. This makes it possible to
200 reconstruct <emphasis>any</emphasis> revision of a file 205 reconstruct <emphasis>any</emphasis> revision of a file
201 quickly. This approach works so well that it has since been 206 quickly. This approach works so well that it has since been
202 copied by several other revision control systems.</para> 207 copied by several other revision control systems.</para>
203 208
204 <para>Figure <xref linkend="fig.concepts.snapshot"/> illustrates 209 <para>Figure <xref endterm="fig.concepts.snapshot.caption"
210 linkend="fig.concepts.snapshot"/> illustrates
205 the idea. In an entry in a revlog's index file, Mercurial 211 the idea. In an entry in a revlog's index file, Mercurial
206 stores the range of entries from the data file that it must 212 stores the range of entries from the data file that it must
207 read to reconstruct a particular revision.</para> 213 read to reconstruct a particular revision.</para>
208 214
209 <sect3> 215 <sect3>
271 for not one parent, but two. Mercurial uses a special hash, 277 for not one parent, but two. Mercurial uses a special hash,
272 called the <quote>null ID</quote>, to represent the idea 278 called the <quote>null ID</quote>, to represent the idea
273 <quote>there is no parent here</quote>. This hash is simply a 279 <quote>there is no parent here</quote>. This hash is simply a
274 string of zeroes.</para> 280 string of zeroes.</para>
275 281
276 <para>In figure <xref linkend="fig.concepts.revlog"/>, you can see 282 <para>In figure <xref endterm="fig.concepts.revlog.caption"
283 linkend="fig.concepts.revlog"/>, you can see
277 an example of the conceptual structure of a revlog. Filelogs, 284 an example of the conceptual structure of a revlog. Filelogs,
278 manifests, and changelogs all have this same structure; they 285 manifests, and changelogs all have this same structure; they
279 differ only in the kind of data stored in each delta or 286 differ only in the kind of data stored in each delta or
280 snapshot.</para> 287 snapshot.</para>
281 288
287 two revisions that have the same parent ID are branches. A 294 two revisions that have the same parent ID are branches. A
288 revision that represents a merge between branches has two normal 295 revision that represents a merge between branches has two normal
289 revision IDs in its parent slots.</para> 296 revision IDs in its parent slots.</para>
290 297
291 <informalfigure id="fig.concepts.revlog"> 298 <informalfigure id="fig.concepts.revlog">
292 <mediaobject><imageobject><imagedata 299 <mediaobject>
293 fileref="images/revlog.png"/></imageobject><textobject><phrase>XXX 300 <imageobject><imagedata fileref="images/revlog.png"/></imageobject>
294 add text</phrase></textobject></mediaobject> 301 <textobject><phrase>XXX add text</phrase></textobject>
302 <caption><para id="fig.concepts.revlog.caption">Revision in revlog</para>
303 </caption>
304 </mediaobject>
295 </informalfigure> 305 </informalfigure>
296 306
297 </sect1> 307 </sect1>
298 <sect1> 308 <sect1>
299 <title>The working directory</title> 309 <title>The working directory</title>
336 book-keeping purposes. Mercurial uses the parents of the 346 book-keeping purposes. Mercurial uses the parents of the
337 dirstate as <emphasis>the parents of a new 347 dirstate as <emphasis>the parents of a new
338 changeset</emphasis> when you perform a commit.</para> 348 changeset</emphasis> when you perform a commit.</para>
339 349
340 <informalfigure id="fig.concepts.wdir"> 350 <informalfigure id="fig.concepts.wdir">
341 <mediaobject><imageobject><imagedata 351 <mediaobject>
342 fileref="images/wdir.png"/></imageobject><textobject><phrase>XXX 352 <imageobject><imagedata fileref="images/wdir.png"/></imageobject>
343 add text</phrase></textobject><caption><para>The working 353 <textobject><phrase>XXX add text</phrase></textobject>
344 directory can have two 354 <caption><para id="fig.concepts.wdir.caption">The working
345 parents</para></caption></mediaobject> 355 directory can have two parents</para></caption>
356 </mediaobject>
346 </informalfigure> 357 </informalfigure>
347 358
348 <para>Figure <xref linkend="fig.concepts.wdir"/> shows the 359 <para>Figure <xref endterm="fig.concepts.wdir.caption"
360 linkend="fig.concepts.wdir"/> shows the
349 normal state of the working directory, where it has a single 361 normal state of the working directory, where it has a single
350 changeset as parent. That changeset is the 362 changeset as parent. That changeset is the
351 <emphasis>tip</emphasis>, the newest changeset in the 363 <emphasis>tip</emphasis>, the newest changeset in the
352 repository that has no children.</para> 364 repository that has no children.</para>
353 365
354 <informalfigure id="fig.concepts.wdir-after-commit"> 366 <informalfigure id="fig.concepts.wdir-after-commit">
355 <mediaobject><imageobject><imagedata 367 <mediaobject>
356 fileref="images/wdir-after-commit.png"/></imageobject><textobject><phrase>XXX 368 <imageobject><imagedata fileref="images/wdir-after-commit.png"/>
357 add text</phrase></textobject><caption><para>The working 369 </imageobject>
358 directory gains new parents after a 370 <textobject><phrase>XXX add text</phrase></textobject>
359 commit</para></caption></mediaobject> 371 <caption><para id="fig.concepts.wdir-after-commit.caption">The working
372 directory gains new parents after a commit</para></caption>
373 </mediaobject>
360 </informalfigure> 374 </informalfigure>
361 375
362 <para>It's useful to think of the working directory as 376 <para>It's useful to think of the working directory as
363 <quote>the changeset I'm about to commit</quote>. Any files 377 <quote>the changeset I'm about to commit</quote>. Any files
364 that you tell Mercurial that you've added, removed, renamed, 378 that you tell Mercurial that you've added, removed, renamed,
368 directory as its parents.</para> 382 directory as its parents.</para>
369 383
370 <para>After a commit, Mercurial will update the parents of the 384 <para>After a commit, Mercurial will update the parents of the
371 working directory, so that the first parent is the ID of the 385 working directory, so that the first parent is the ID of the
372 new changeset, and the second is the null ID. This is shown 386 new changeset, and the second is the null ID. This is shown
373 in figure <xref linkend="fig.concepts.wdir-after-commit"/>. 387 in figure <xref endterm="fig.concepts.wdir-after-commit.caption"
388 linkend="fig.concepts.wdir-after-commit"/>.
374 Mercurial 389 Mercurial
375 doesn't touch any of the files in the working directory when 390 doesn't touch any of the files in the working directory when
376 you commit; it just modifies the dirstate to note its new 391 you commit; it just modifies the dirstate to note its new
377 parents.</para> 392 parents.</para>
378 393
387 introduced a bug. In cases like this, the natural thing to do 402 introduced a bug. In cases like this, the natural thing to do
388 is update the working directory to the changeset you're 403 is update the working directory to the changeset you're
389 interested in, and then examine the files in the working 404 interested in, and then examine the files in the working
390 directory directly to see their contents as they were when you 405 directory directly to see their contents as they were when you
391 committed that changeset. The effect of this is shown in 406 committed that changeset. The effect of this is shown in
392 figure <xref linkend="fig.concepts.wdir-pre-branch"/>.</para> 407 figure <xref endterm="fig.concepts.wdir-pre-branch.caption"
408 linkend="fig.concepts.wdir-pre-branch"/>.</para>
393 409
394 <informalfigure id="fig.concepts.wdir-pre-branch"> 410 <informalfigure id="fig.concepts.wdir-pre-branch">
395 <mediaobject><imageobject><imagedata 411 <mediaobject>
396 fileref="images/wdir-pre-branch.png"/></imageobject><textobject><phrase>XXX 412 <imageobject><imagedata fileref="images/wdir-pre-branch.png"/>
397 add text</phrase></textobject><caption><para>The working 413 </imageobject>
398 directory, updated to an older 414 <textobject><phrase>XXX add text</phrase></textobject>
399 changeset</para></caption></mediaobject> 415 <caption><para id="fig.concepts.wdir-pre-branch.caption">The working
416 directory, updated to an older changeset</para></caption>
417 </mediaobject>
400 </informalfigure> 418 </informalfigure>
401 419
402 <para>Having updated the working directory to an older 420 <para>Having updated the working directory to an older
403 changeset, what happens if you make some changes, and then 421 changeset, what happens if you make some changes, and then
404 commit? Mercurial behaves in the same way as I outlined 422 commit? Mercurial behaves in the same way as I outlined
406 parents of the new changeset. This new changeset has no 424 parents of the new changeset. This new changeset has no
407 children, so it becomes the new tip. And the repository now 425 children, so it becomes the new tip. And the repository now
408 contains two changesets that have no children; we call these 426 contains two changesets that have no children; we call these
409 <emphasis>heads</emphasis>. You can see the structure that 427 <emphasis>heads</emphasis>. You can see the structure that
410 this creates in figure <xref 428 this creates in figure <xref
429 endterm="fig.concepts.wdir-branch.caption"
411 linkend="fig.concepts.wdir-branch"/>.</para> 430 linkend="fig.concepts.wdir-branch"/>.</para>
412 431
413 <informalfigure id="fig.concepts.wdir-branch"> 432 <informalfigure id="fig.concepts.wdir-branch">
414 <mediaobject><imageobject><imagedata 433 <mediaobject>
415 fileref="images/wdir-branch.png"/></imageobject><textobject><phrase>XXX 434 <imageobject><imagedata fileref="images/wdir-branch.png"/>
416 add text</phrase></textobject><caption><para>After a 435 </imageobject>
417 commit made while synced to an older 436 <textobject><phrase>XXX add text</phrase></textobject>
418 changeset</para></caption></mediaobject> 437 <caption><para id="fig.concepts.wdir-branch.caption">After a
438 commit made while synced to an older changeset</para></caption>
439 </mediaobject>
419 </informalfigure> 440 </informalfigure>
420 441
421 <note> 442 <note>
422 <para> If you're new to Mercurial, you should keep in mind a 443 <para> If you're new to Mercurial, you should keep in mind a
423 common <quote>error</quote>, which is to use the <command 444 common <quote>error</quote>, which is to use the <command
447 468
448 <para>When you run the <command role="hg-cmd">hg merge</command> 469 <para>When you run the <command role="hg-cmd">hg merge</command>
449 command, Mercurial leaves the first parent of the working 470 command, Mercurial leaves the first parent of the working
450 directory unchanged, and sets the second parent to the 471 directory unchanged, and sets the second parent to the
451 changeset you're merging with, as shown in figure <xref 472 changeset you're merging with, as shown in figure <xref
473 endterm="fig.concepts.wdir-merge.caption"
452 linkend="fig.concepts.wdir-merge"/>.</para> 474 linkend="fig.concepts.wdir-merge"/>.</para>
453 475
454 <informalfigure id="fig.concepts.wdir-merge"> 476 <informalfigure id="fig.concepts.wdir-merge">
455 <mediaobject><imageobject><imagedata 477 <mediaobject>
456 fileref="images/wdir-merge.png"/></imageobject><textobject><phrase>XXX 478 <imageobject><imagedata fileref="images/wdir-merge.png"/>
457 add text</phrase></textobject><caption><para>Merging two 479 </imageobject>
458 heads</para></caption></mediaobject> 480 <textobject><phrase>XXX add text</phrase></textobject>
481 <caption><para id="fig.concepts.wdir-merge.caption">Merging two
482 heads</para></caption>
483 </mediaobject>
459 </informalfigure> 484 </informalfigure>
460 485
461 <para>Mercurial also has to modify the working directory, to 486 <para>Mercurial also has to modify the working directory, to
462 merge the files managed in the two changesets. Simplified a 487 merge the files managed in the two changesets. Simplified a
463 little, the merging process goes like this, for every file in 488 little, the merging process goes like this, for every file in
580 <sect2> 605 <sect2>
581 <title>Read/write ordering and atomicity</title> 606 <title>Read/write ordering and atomicity</title>
582 607
583 <para>Appending to files isn't the whole story when it comes to 608 <para>Appending to files isn't the whole story when it comes to
584 guaranteeing that a reader won't see a partial write. If you 609 guaranteeing that a reader won't see a partial write. If you
585 recall figure <xref linkend="fig.concepts.metadata"/>, 610 recall figure <xref endterm="fig.concepts.metadata.caption"
586 revisions in the 611 linkend="fig.concepts.metadata"/>, revisions in the
587 changelog point to revisions in the manifest, and revisions in 612 changelog point to revisions in the manifest, and revisions in
588 the manifest point to revisions in filelogs. This hierarchy 613 the manifest point to revisions in filelogs. This hierarchy
589 is deliberate.</para> 614 is deliberate.</para>
590 615
591 <para>A writer starts a transaction by writing filelog and 616 <para>A writer starts a transaction by writing filelog and