There are numerous discussions here that have addressed issues that seem related to this question, but nothing has really answered it directly. Basically, using Mercurial, I want to be able to work on multiple, independent tasks within the same project, at the same time.
For example, I’m simultaneously tasked with bugs X & Y. I work on X for a while until I hit a point where I need to put it on hold for a few days. Say I need input from someone else who is out of the office. So I want to move on to working on bug-Y. Clearly, one option is to just create a new clone of the stable repository. The problem is that requires a new working directory, new Eclipse project, yada-yada… I’d like to be able to keep one working copy.
With SVN I could create a new branch in the repository for each task and just switch my working copy between them. With ClearCase I could create a new activity for each one. In both cases, I could work on each task independently, in clean environment. Then when I’m done with a task, I can commit/push just that one to the central repo.
I’ve read about Hg named branches & bookmarks. I’m sure that somewhere in there there’s a solution to fit our workflow, but I’m not seeing it yet. Can someone explain the steps I can use to achieve this? Is it possible to create two heads in my local repository that I can just switch between? And then update/commit/push/pull those heads independently? In practice I might never even merge them locally, just push each one to our stable repo when it’s ready. Am I just thinking about this in entirely the wrong way? I’m very new to Hg (and DVCS’s in general) and trying to develop a workflow for it.
The process you’re describing is really simple to implement with Mercurial, and there’s many way to do it.
For example, you can use anonymous branches :
You just created two anonymous branches in your working copy starting at the decided changeset.
You’re absolutely not limited to the number of anonymous branches or their starting point, you can even create new anonymous branches on your anonymous branches.
In some cases, tools like TortoiseHG or the the GraphLog extension can really help you understanding which are the parents of each branches and what’s the best way of merging them back.
Bookmarks are only a way to easily keep track of various changeset, you can put bookmark on each of your new heads. Depending on the version of Mercurial you’re using, the bookmark will “follow” each new commit you make in its particular branch or not.
You can also use named branch to achieve the same purpose, but the problem is you can’t easily delete a named branch after it’s been created, the name will still be their.
PS: this workflow, or something very similar is described in the following blog post : http://stevelosh.com/blog/2010/02/mercurial-workflows-branch-as-needed/