Mercurial Workflow: Feature seperation via named branches

Arne Babenhauserheide arne_bab at web.de
Tue May 10 16:15:53 UTC 2011


I just added a new workflow to the wikipage and to my own site. I hope it’s 
interesting to you! I wrote the original guide for PyHurd.

→ http://draketo.de/light/english/mercurial/feature-seperation-via-named-
branches
→ → short: http://draketo.de/node/446http://mercurial.selenic.com/wiki/Workflows#Feature_seperation_through_named_branches

## For Whom?

If you want to develop features collaboratively and you want to be able to see 
later for which feature a given change was added, then this workflow might be 
right for you.

## What you need

Just vanilla Mercurial.

## Workflow

The workflow is 6-stepped: 

1. create the new feature, 
2. Implement and share, 
3. merge other changes into it, 
4. merge stable features, 
5. close finished features and 
6. reopen features.

Let’s see the steps in detail.

#### 1. New feature

first start a new branch with the name of the feature starting from default. 

<pre>hg branch feature-x
\# do some changes
hg commit -m "Started implemented feature-x"
</pre>

#### 2. Implement and share

Then commit away and push whenever you finish something which might be of 
interest to others, regardless how marginal. 

You can push to a shared repository, or to your own clone or even send the 
changes via email to other contributors (for example via the mailbomb 
extension). 

#### 3. Merge in default

Merge changes in the default branch into your feature as often as possible to 
reduce the work necessary when you want to merge the feature later on.

<pre>hg update feature-x
hg merge default
hg commit -m "merged default into feature-x"
</pre>

#### 4. Merge stable features

When your feature is stable, merge it into default.

<pre>hg update default
hg merge feature-x
hg commit -m "merged feature-x"
</pre>

#### 5. Close the branch when it’s done

And when the feature needs no more work, close the branch.

<pre>\# start from default, automatic when using a fresh clone
hg update default
hg branch feature-x
\# do some changes
hg commit -m "started feature X" 
hg push 
</pre>
<pre>\# commit and push as you like</pre>
<pre>hg update default
hg merge feature-x
hg ci -m "merged feature X into default"
hg commit --close-branch -m "finished feature X"
</pre>

This hides the branch from the output of `hg branches`, so you don’t clutter 
your history.

#### 6. Reopen the feature

To improve a feature after it was officially closed, first merge default into the 
feature branch (to get it up to date), then work just as if you had started 
it.

<pre>hg up feature-x
hg merge default
hg ci -m "merged default into feature X"
\# commit, push, repeat, finish
</pre>

Generally merge default into your feature as often as possible.

## Epilog

If this workflow helps you, I’d be glad to hear from you here or as comment on 
my page: http://drakteto.de/comment/reply/446#comment-form

Feel free to use it under GPLv2 or later.

Best wishes, 
Arne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20110510/a84cc54e/attachment.asc>


More information about the Mercurial mailing list