views:

62

answers:

2

Is it possible to have different development "paths" from a given point in Mercurial, without having to clone my project? I currently have 2-3 different implementations options for a project and I'd like to try them out. If I could just use one and at any point come back and start in another "path" without losing data from the older one that would be nice, but I am not even sure it is possible.

Thanks

+3  A: 

This is exactly what branching is designed for:

http://mercurial.selenic.com/wiki/Branch

The easiest way to create a branch in Mercurial is to simply checkout an older version, and then commit again with something different from what you committed after it the first time. You won't lose the old following commit, the new commit will simply branch out into a new line of development and the original commit(s) will remain on the previous line of development.

Amber
Ah, I see. Isn't there a way to make it more visually obvious when running Repository Explorer? I had done this before but as in the Graph Summary everything looked "connected" I thought it was in some way only following the last "branch".
devoured elysium
If something shows up in repository explorer, then it's still part of the repository. :) If you haven't yet committed diverging code, then you'll get a straight graph.
Amber
I created a project, and then made a commit. I added a print line and made another commit called "branch1". I then reverted to the initial commit and made a different print ln, committing it to "branch2". What am I missing here?
devoured elysium
When you say you "reverted" to the initial commit, did you actually use the "revert" command, or did you simply update your working directory back to the initial commit with "hg update 0"?
Patrick Steele
I used the revert command that appears in the repository GUI, in the context menu when you right click in a given commit.
devoured elysium
So what you want to do isn't revert (because that continues the same branch), but instead simply `update` to the older version (checking out that commit) and then work on it, committing after - that will create a diverging branch. Reverting is actually committing a changeset that undoes your changes, in the same branch.
Amber
+2  A: 

Yes, you probably want bookmarks for this - they're a lightweight way of marking various heads without recording the names forever in the revision (which branches do.) See http://mercurial.selenic.com/wiki/BookmarksExtension for more details.

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/ may also be helpful - it's essentially the canonical document on branch management strategies in Mercurial.

durin42