A Guide to Branching in Mercurial

Giorgos Keramidas keramida at ceid.upatras.gr
Sat Sep 5 10:39:57 CDT 2009


On Sat, 05 Sep 2009 11:38:03 +0200, "Alexander Schatten" <ml_alexanderschatten at gmx.at> wrote:
> Martin,
>
> thanks for your detailed answer; this was also my understanding. I
> just think, that this is a significant issue of this blog-post.
>
> May I add one question here, though, that I was already struggling
> with and that is in my opinion related. Assume this situation:
>
> (1) I have a piece of Code version controlled and I am, say, at
> Rev. 10. Everything is fine so far.
>
> (2) Now I continue a "risky" feature development, say until
> Rev. 15. Then I figure this leads nowhere, I have broken the system,
> whatever.
>
> (3) Hence I go back to rev. 10 (hg update 10). This was the last
> stable version. Then I continue working from here (Rev. 16, 17,
> ...). In effect I made a branche. This is why I have SCM, right?
>
> Now: the thing is: this unnamed branch Rev. 11-15 will allways annoy
> me in the future, because I cannot push and I definitly do not want to
> merge crappy code into my main line of dev.

If you keep the work 'local' until it's done, or in a separate temporary
clone, you can just throw away that clone.  The feature-clone does not
have to be local to a single machine, i.e. multiple people may be using
it to work on the experimental feature 'X'.

What you do with the feature-clone is a matter of local convention and
only of that.  For example, if you set a team policy that includes:

  * Only complete, tested and QA'ed features will be pushed to the NFS
    shared `/workspaces/release/foo/trunk' repository.

  * You can keep personal clones in the NFS shared path matching your
    username under `/workspaces/user'.

  * Anything that gets pushed to `/workspaces/release/foo/trunk' must
    come from one of the `/workspaces/testing/foo/xxx' clones.

Then you can clone & copy as many copies of `trunk' as you want under
your own personal tree at `/workspaces/user/mla/xxx'.  You can even
throw them away if you really don't like what they look like.

This is a scenario based on feature-clones.  It isn't the _only_
workflow supported by Mercurial.  Just one of the workflows I find easy
to grasp.


More information about the Mercurial mailing list