Branching vs Cloning

Greg Ward greg-hg at gerg.ca
Fri Jan 8 07:50:52 CST 2010


On Fri, Jan 8, 2010 at 12:34 AM, Michael Fromin <mfromin at yahoo.com> wrote:
> For item #1...
> I believe that I would use the TAG capability of the system to mark specific
> changesets.  As I already have 11 changesets in the repository I cannot seem
> to find a way to tag any existing changesets.  Am I missing something or is
> this not doable in Mercurial?  Is there another way to do this?  For
> example, should I branch off the main path for each "version" that I want to
> identify?

Yes, that's exactly what tags are for.  The command you are looking
for is 'hg tag -r <revid> <tagname>'.  E.g. if revision 7 is version
1.0: 'hg tag -r 7 1.0'.  See 'hg help tag' for more info.

Also, have you read *Mercurial: The Definitive Guide*?  You can buy
the book if you like paper, or read it online here:
http://hgbook.red-bean.com/read/.  Sounds like you should concentrate
on chapters 1, 2, and 3.  When you've got that stuff down pat, move on
to chapter 5.  (Chapter 4 is really interesting, but not on your
critical path. ;-)

> For item #2...
> If I have multiple "work streams" that I need to do in parallel do I make
> multiple branches or multiple clones?  It appears that (in theory) I could
> do either as both seem to provide me a way to isolate a set of code changes
> that I can later merge back into a single parent changeset.  Is there a
> particular "best practice" for how this should be done?  Are branches better
> for this?  Are clones better for this?

Correct: like other DVCSes, Mercurial supports multiple ways of
working.  I think the general consensus is that named branches are the
right way to manage long-lived stable release branches.  Using
separate repositories for that is, IMHO, awkward and clunky.  The
worst thing about it is that it's very difficult to tell
after-the-fact if changeset X happened on the stable branch or the
main branch (aka trunk).  Sometimes, it's really important to know if
that bug was fixed in version 1.0, 1.1, or 1.2!

Mercurial itself recently switched from using a separate repo for its
'stable' branch to having a named 'stable' branch right in the main
repository.

> If I do branch then would I perform "fixes/patches" to the branch and then
> merge them in later?

Correct.  In the most extreme case, every fix on the stable branch
will result in one changeset to make the fix, and a second changeset
that merges it to the trunk ('default' branch).  But more typically,
you might fix 3 bugs in a row, or some bugs will take multiple commits
to fix.  So you'll end up merging 3 or 5 or 10 changesets to the trunk
('default'), creating one additional merge changeset for the whole
group.  Whatever you like.

Greg


More information about the Mercurial mailing list