study

Workflow with Mercurial named branch

Feature separation 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.

Note: If you have a huge number of small features (2000 and upwards), the number of persistent named branches can create certain performance problems. For features which need no collaboration or need only a few commits, this workflow also has much unnecessary overhead. It is best used for features which will be developed side by side with default for some time (and many commits), so tracking the default branch against the feature is relevant. To mark single-commit features as belonging to a feature, just use the commit message.

Note: The difference between Mercurial named branches and git branches is that git branches don’t stay in history. They don’t allow you to find out later in which branch a certain commit was added. If you want git-style branching, just use bookmarks.

What you need

Just vanilla Mercurial.

Workflow

To start a new feature,

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

hg branch feature-x

# do some changes

hg commit -m “Started implementing feature-x”

 

2. Then commit away and push whenever you finish something which might be of interest to others, regardless how marginal. If you want to hack on a feature started by someone else, or you want to switch between features, just update to the feature.

hg update –check feature-x

# do some changes

hg commit -m “Improved X”

Note: The short form of hg update –check feature-x is hg up -c feature-x.

 

3. Merge default into your feature as often as possible.

hg update feature-x

hg merge default

hg commit -m “merged default into feature-x”

 

4. When your feature is stable, merge it into default.

hg update default

hg merge feature-x

hg commit -m “merged feature-x”

 

5. When the feature is done and needs no more work, close the branch.

hg update default # start from default, automatic when using a fresh clone

hg branch feature-x

# do some changes

hg commit -m “started feature X”

hg push

# commit and push as you want

hg update default

hg merge feature-x

hg ci -m “merged feature X into default”

hg commit –close-branch -m “finished feature X”

 

6. 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.

hg up feature-x

hg merge default

hg ci -m “merged default into feature X”

# commit, push, repeat, finish

Generally merge default into your feature as often as possible.

via Workflows – Mercurial.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s