# HG changeset patch # User Bryan O'Sullivan # Date 1239519930 25200 # Node ID 3b640272a9663835379f292b699f31767ce2a81e # Parent dbe5f4bb65070ff3085780a392c42d9c48ca5cba Progres on resolve diff -r dbe5f4bb6507 -r 3b640272a966 en/ch01-tour-basic.xml --- a/en/ch01-tour-basic.xml Thu Apr 09 22:54:10 2009 -0700 +++ b/en/ch01-tour-basic.xml Sun Apr 12 00:05:30 2009 -0700 @@ -589,7 +589,7 @@ Creating a Mercurial configuration file - To set a user name, use your favourite editor + To set a user name, use your favorite editor to create a file called .hgrc in your home directory. Mercurial will use this file to look up your personalised diff -r dbe5f4bb6507 -r 3b640272a966 en/ch04-daily.xml --- a/en/ch04-daily.xml Thu Apr 09 22:54:10 2009 -0700 +++ b/en/ch04-daily.xml Sun Apr 12 00:05:30 2009 -0700 @@ -26,14 +26,14 @@ After you run a hg commit, the files that you added before the commit will no longer be listed in the output of hg - status. The reason for this is that . The reason for this is that by default, hg status only tells you about - interesting files&emdash;those that you have - modified or told Mercurial to do something with&emdash;by - default. If you have a repository that contains thousands of - files, you will rarely want to know about files that Mercurial - is tracking, but that have not changed. (You can still get this - information; we'll return to this later.) + interesting files&emdash;those that you have (for + example) modified, removed, or renamed. If you have a repository + that contains thousands of files, you will rarely want to know + about files that Mercurial is tracking, but that have not + changed. (You can still get this information; we'll return to + this later.) Once you add a file, Mercurial doesn't do anything with it immediately. Instead, it will take a snapshot of the file's @@ -51,15 +51,15 @@ &interaction.daily.files.add-dir; - Notice in this example that Mercurial printed the names of - the files it added, whereas it didn't do so when we added the - file named a in the earlier - example. + Notice in this example that Mercurial printed + the names of the files it added, whereas it didn't do so when + we added the file named myfile.txt in the + earlier example. What's going on is that in the former case, we explicitly - named the file to add on the command line, so the assumption - that Mercurial makes in such cases is that you know what you - were doing, and it doesn't print any output. + named the file to add on the command line. The assumption + that Mercurial makes in such cases is that we know what we + are doing, and it doesn't print any output. However, when we imply the names of files by giving the name of a directory, Mercurial takes the @@ -67,8 +67,8 @@ something with. This makes it more clear what is happening, and reduces the likelihood of a silent and nasty surprise. This behavior is common to most Mercurial commands. + - Mercurial tracks files, not directories @@ -102,15 +102,15 @@ Another way to tackle a need for an empty directory is to simply create one in your automated build scripts before they will need it. - + How to stop tracking a file Once you decide that a file no longer belongs in your repository, use the hg remove - command; this deletes the file, and tells Mercurial to stop + command. This deletes the file, and tells Mercurial to stop tracking it. A removed file is represented in the output of hg status with a R. @@ -140,15 +140,16 @@ Removing a file does not in any way alter the history of the file. - If you update the working directory to a changeset in - which a file that you have removed was still tracked, it will - reappear in the working directory, with the contents it had - when you committed that changeset. If you then update the - working directory to a later changeset, in which the file had - been removed, Mercurial will once again remove the file from - the working directory. + If you update the working directory to a + changeset that was committed when it was still tracking a file + that you later removed, the file will reappear in the working + directory, with the contents it had when you committed that + changeset. If you then update the working directory to a + later changeset, in which the file had been removed, Mercurial + will once again remove the file from the working + directory. + - Missing files @@ -177,9 +178,9 @@ name of the file to recover. It will reappear, in unmodified form. -&interaction.daily.files.recover-missing; + &interaction.daily.files.recover-missing; + - Aside: why tell Mercurial explicitly to remove a file? @@ -192,8 +193,8 @@ commit, and stop tracking the file. In practice, this made it too easy to accidentally remove a file without noticing. + - Useful shorthand&emdash;adding and removing files in one step @@ -210,9 +211,9 @@ followed by a commit. &interaction.daily.files.commit-addremove; - + Copying files @@ -272,14 +273,14 @@ into its copy, new-file. &interaction.daily.copy.merge; + - Why should changes follow copies? - This behavior, of changes to a file propagating out to - copies of the file, might seem esoteric, but in most cases - it's highly desirable. + This behavior&emdash;of changes to a file + propagating out to copies of the file&emdash;might seem + esoteric, but in most cases it's highly desirable. First of all, remember that this propagation only happens when you merge. So if you @@ -288,8 +289,8 @@ of your work, nothing will happen. The second thing to know is that modifications will only - propagate across a copy as long as the repository that you're - pulling changes from doesn't know about + propagate across a copy as long as the changeset that you're + merging changes from hasn't yet seen the copy. The reason that Mercurial does this is as follows. Let's @@ -301,8 +302,8 @@ If you pulled and merged my changes, and Mercurial didn't propagate changes across copies, - your source file would now contain the bug, and unless you - remembered to propagate the bug fix by hand, the bug would + your new source file would now contain the bug, and unless you + knew to propagate the bug fix by hand, the bug would remain in your copy of the file. By automatically propagating the change that fixed the bug @@ -315,9 +316,9 @@ subsequent merge occurred, there's usually no further need to propagate changes from the original file to the copied file, and that's why Mercurial only propagates changes across copies - until this point, and no further. + at the first merge, and not afterwards. + - How to make changes <emphasis>not</emphasis> follow a copy @@ -335,7 +336,7 @@ - Behaviour of the <command role="hg-cmd">hg copy</command> + <title>Behavior of the <command role="hg-cmd">hg copy</command> command When you use the hg copy @@ -348,14 +349,17 @@ behavior a little counterintuitive, which is why I mention it here.) - The hg copy command acts - similarly to the Unix cp command (you can - use the hg cp alias if you - prefer). The last argument is the - destination, and all prior arguments are - sources. If you pass it a single file as - the source, and the destination does not exist, it creates a - new file with that name. + The hg copy + command acts similarly to the Unix cp + command (you can use the hg + cp alias if you prefer). We must supply two or + more arguments, of which the last is treated as the + destination, and all others are + sources. + + If you pass hg copy a + single file as the source, and the destination does not exist, + it creates a new file with that name. &interaction.daily.copy.simple; @@ -375,16 +379,16 @@ &interaction.daily.copy.dir-src-dest; - As with the hg rename + As with the hg remove command, if you copy a file manually and then want Mercurial to know that you've copied the file, simply use the option to hg copy. &interaction.daily.copy.after; - + Renaming files @@ -426,6 +430,11 @@ similar to the hg copy command. + If you're familiar with the Unix command line, you'll be + glad to know that hg rename + command can be invoked as hg + mv. + Renaming files and merging changes @@ -446,8 +455,8 @@ rename is definitely important. Without this facility, it would simply be too easy for changes to become orphaned when files are renamed. + - Divergent renames and merging @@ -463,7 +472,9 @@ &interaction.rename.divergent.rename.anne; Meanwhile, Bob renames it to - quux. + quux. (Remember that hg mv is an alias for hg rename.) &interaction.rename.divergent.rename.bob; @@ -478,11 +489,11 @@ &interaction.rename.divergent.merge; - Notice that Mercurial does warn about the divergent - renames, but it leaves it up to you to do something about the + Notice that while Mercurial warns about the divergent + renames, it leaves it up to you to do something about the divergence after the merge. + - Convergent renames and merging @@ -491,8 +502,8 @@ to the same destination. In this case, Mercurial runs its normal merge machinery, and lets you guide it to a suitable resolution. + - Other name-related corner cases @@ -507,6 +518,7 @@ + Recovering from mistakes @@ -523,7 +535,7 @@ hg revert to get rid of erroneous changes to a file. - It's useful to remember that the hg + It's good to remember that the hg revert command is useful for changes that you have not yet committed. Once you've committed a change, if you decide it was a mistake, you can still do something about it, @@ -533,7 +545,133 @@ role="hg-cmd">hg revert command, and details about how to deal with changes you have already committed, see . + + + Dealing with tricky merges + + In a complicated or large project, it's not unusual for a + merge of two changesets to result in some headaches. Suppose + there's a big source file that's been extensively edited by each + side of a merge: this is almost inevitably going to result in + conflicts, some of which can take a few tries to sort + out. + + Let's develop a simple case of this and see how to deal with + it. We'll start off with a repository containing one file, and + clone it twice. + + &interaction.ch04-resolve.init; + + In one clone, we'll modify the file in one way. + + &interaction.ch04-resolve.left; + + In another, we'll modify the file differently. + + &interaction.ch04-resolve.right; + + Next, we'll pull each set of changes into our original + repo. + + &interaction.ch04-resolve.pull; + + We expect our repository to now contain two heads. + + &interaction.ch04-resolve.heads; + + Normally, if we run hg + merge at this point, it will drop us into a GUI that + will let us manually resolve the conflicting edits to + myfile.txt. However, to simplify things + for presentation here, we'd like the merge to fail immediately + instead. Here's one way we can do so. + + &interaction.ch04-resolve.export; + + We've told Mercurial's merge machinery to run the command + false (which, as we desire, fails + immediately) if it detects a merge that it can't sort out + automatically. + + If we now fire up hg + merge, it should grind to a halt and report a + failure. + + &interaction.ch04-resolve.merge; + + Even if we don't notice that the merge failed, Mercurial + will prevent us from accidentally committing the result of a + failed merge. + + &interaction.ch04-resolve.cifail; + + When hg commit fails in + this case, it suggests that we use the unfamiliar hg resolve command. As usual, + hg help resolve will print a + helpful synopsis. + + + File resolution states + + When a merge occurs, most files will usually remain + unmodified. For each file where Mercurial has to do + something, it tracks the state of the file. + + + + A resolved file has been + successfully merged, either automatically by Mercurial or + manually with human intervention. + + + An unresolved file was not merged + successfully, and needs more attention. + + + + If Mercurial sees any file in the + unresolved state after a merge, it considers the merge to have + failed. Fortunately, we do not need to restart the entire + merge from scratch. + + The or + option to hg resolve prints out the state of + each merged file. + + &interaction.ch04-resolve.list; + + In the output from hg + resolve, a resolved file is marked with + R, while an unresolved file is marked with + U. If any files are listed with + U, we know that an attempt to commit the + results of the merge will fail. + + + + Resolving a file merge + + We have several options to move a file from the unresolved + into the resolved state. By far the most common is to rerun + hg resolve. If we pass the + names of individual files or directories, it will retry the + merges of any unresolved files present in those locations. We + can also pass the + or option, which + will retry the merges of all unresolved + files. + + Mercurial also lets us modify the resolution state of a + file directly. We can manually mark a file as resolved using + the option, or + as unresolved using the option. This allows + us to clean up a particularly messy merge by hand, and to keep + track of our progress with each file as we go. + diff -r dbe5f4bb6507 -r 3b640272a966 en/ch05-collab.xml --- a/en/ch05-collab.xml Thu Apr 09 22:54:10 2009 -0700 +++ b/en/ch05-collab.xml Sun Apr 12 00:05:30 2009 -0700 @@ -23,7 +23,7 @@ Also for human consumption, the web interface provides an RSS feed of the changes in a repository. This lets you - subscribe to a repository using your favourite + subscribe to a repository using your favorite feed reader, and be automatically notified of activity in that repository as soon as it happens. I find this capability much more convenient than the model of subscribing to a mailing list @@ -109,7 +109,7 @@ As one example, many projects have a loose-knit group of collaborators who rarely physically meet each other. Some groups like to overcome the isolation of working at a distance - by organising occasional sprints. In a sprint, + by organizing occasional sprints. In a sprint, a number of people get together in a single location (a company's conference room, a hotel meeting room, that kind of place) and spend several days more or less locked in there, @@ -286,7 +286,7 @@ The release train - Some projects are organised on a train + Some projects are organized on a train basis: a release is scheduled to happen every few months, and whatever features are ready when the train is ready to leave are allowed in. diff -r dbe5f4bb6507 -r 3b640272a966 en/ch11-mq.xml --- a/en/ch11-mq.xml Thu Apr 09 22:54:10 2009 -0700 +++ b/en/ch11-mq.xml Sun Apr 12 00:05:30 2009 -0700 @@ -1143,7 +1143,7 @@ free software or open source project, or a series that you intend to treat as a sequence of regular changesets when you're done, you can use some simple techniques to keep your work well - organised. + organized. Give your patches descriptive names. A good name for a patch might be rework-device-alloc.patch, diff -r dbe5f4bb6507 -r 3b640272a966 en/examples/auto-snippets.xml --- a/en/examples/auto-snippets.xml Thu Apr 09 22:54:10 2009 -0700 +++ b/en/examples/auto-snippets.xml Sun Apr 12 00:05:30 2009 -0700 @@ -51,6 +51,15 @@ + + + + + + + + + diff -r dbe5f4bb6507 -r 3b640272a966 en/examples/ch04/resolve --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/en/examples/ch04/resolve Sun Apr 12 00:05:30 2009 -0700 @@ -0,0 +1,38 @@ +#$ name: init +hg init conflict +cd conflict +echo first > myfile.txt +hg ci -A -m first +cd .. +hg clone conflict left +hg clone conflict right + +#$ name: left +cd left +echo left >> myfile.txt +hg ci -m left + +#$ name: right +cd ../right +echo right >> myfile.txt +hg ci -m right + +#$ name: pull +cd ../conflict +hg pull -u ../left +hg pull -u ../right + +#$ name: heads +hg heads + +#$ name: export +export HGMERGE=merge + +#$ name: merge +hg merge + +#$ name: cifail +hg commit -m 'Attempt to commit a failed merge' + +#$ name: list +hg resolve -l diff -r dbe5f4bb6507 -r 3b640272a966 en/examples/rename.divergent --- a/en/examples/rename.divergent Thu Apr 09 22:54:10 2009 -0700 +++ b/en/examples/rename.divergent Sun Apr 12 00:05:30 2009 -0700 @@ -14,7 +14,7 @@ #$ name: rename.anne cd anne -hg mv foo bar +hg rename foo bar hg ci -m 'Rename foo to bar' #$ name: rename.bob diff -r dbe5f4bb6507 -r 3b640272a966 en/examples/run-example --- a/en/examples/run-example Thu Apr 09 22:54:10 2009 -0700 +++ b/en/examples/run-example Sun Apr 12 00:05:30 2009 -0700 @@ -317,6 +317,7 @@ if out: ofp_basename = '%s.%s' % (self.name, out) norm = os.path.normpath(ofp_basename) + norm = norm.replace(os.sep, '-') example.entities[ '' @@ -345,7 +346,7 @@ ofp.write(hunk) # then its output ofp.write(xml_escape(output)) - ps = newps + ps = newps self.status('\n') except: print >> sys.stderr, '(killed)'