Advanced Rails - Building Industrial-Strength Web Apps in Record Time

(Tuis.) #1

304 | Chapter 10: Large Projects


Nowtrunk-newcolorscontains an identical copy of the trunk, including all history.
We are going to make changes totrunk-newcolors, preview them, and then merge
them back intotrunk. We now make the appropriate changes totrunk-newcolorsand
commit them:


$ cd trunk-newcolors/
$ sed -ie 's/color: red/color: blue/g' public/stylesheets/main.css
$ hg ci -m "Changed red to blue in main stylesheet"
$ hg tip
changeset: 1:18bb8b07ec40
tag: tip
user: Brad Ediger <[email protected]>
date: Fri Oct 26 13:08:01 2007 -0500
summary: Changed red to blue in main stylesheet

We can preview this line of development for as long as we like, and then merge it
back into trunk. To merge, we first pull the changes fromtrunk-newcolorsinto the
trunk repository:


$ cd ../trunk/
$ hg pull ../trunk-newcolors
pulling from ../trunk-newcolors
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)

This indicates that there have been changes to the trunk since the branch, so we will
need to merge.


Mercurial requires an explicit merge step, even if the merge turns out
to be trivial. In some cases, when you pull, you do not want to merge.
An extension called FetchExtension provides anhg fetchcommand to
automate the pull/merge/commit process in the case of trivial merges.

We use thehg headscommand to see the twoheads(two branches of development),
one from our local repository attrunkand the other fromtrunk-newcolors. The
merge step usinghg mergeis simple, and in this case, it is a trivial merge (without any
conflicts). Had there been conflicts,hg mergewould have attempted to find a three-
way merge tool such as FileMerge or kdiff3 to help us resolve the changes. When the
merge is complete and we have approved it, we need to commit the merge.


$ hg heads
changeset: 2:18bb8b07ec40
tag: tip
parent: 0:65aca7b5860a
user: Brad Ediger <[email protected]>
date: Fri Oct 26 13:08:01 2007 -0500
summary: Changed red to blue in main stylesheet
Free download pdf