A complete Mercurial branching strategy (writeup)

Arne Babenhauserheide arne_bab at web.de
Sat Aug 18 09:35:44 UTC 2012


Hi Todd,

Am Mittwoch, 15. August 2012, 19:46:31 schrieb Todd Greer:
> Arne Babenhauserheide wrote:
> > http://draketo.de/light/english/mercurial/complete-branching-strategy

> Looks like a nice write-up. I noticed that you don't discuss closing feature
> branches. That would be a good addition.

Good catch - thanks!


I now added closing branches as an item to feature branches.

http://draketo.de/node/513#feature-branches

This makes feature branches a bit more complex, but I think it helps a lot in 
actual development, because the current state of the repository stays cleaner.

### Feature branches

*Now we want to do some larger development, so we use a feature branch. The 
one commit could be an arbitrary number of commits, and as long as you stay in 
your branch, the development of your collegues will not disturb your own work. 
Once the feature is finished, we merge it into default. That gives us 
changesets 9 to 11. Changeset 10 is a commit added in-between on the default 
branch.*

    o      changeset:   16:2088b93fb3f4
    |\     parent:      14:684c6176ce71
    | |    parent:      15:168429fdaf57
    | |    user:        Arne Babenhauserheide <bab at draketo.de>
    | |    date:        Sat Aug 18 10:53:48 2012 +0200
    | |    summary:     merged finished feature x into default
    | |
    | o    changeset:   15:168429fdaf57
    | |    branch:      feature-x
    | |    parent:      13:e3985e582fc4
    | |    user:        Arne Babenhauserheide <bab at draketo.de>
    | |    date:        Sat Aug 18 10:53:47 2012 +0200
    | |    summary:     finished feature x
    | |
    o |    changeset:   14:684c6176ce71
    |\|    parent:      12:70d38749f7dd
    | |    parent:      13:e3985e582fc4
    | |    user:        Arne Babenhauserheide <bab at draketo.de>
    | |    date:        Sat Aug 18 10:53:46 2012 +0200
    | |    summary:     merged feature x into default
    | |
    | o    changeset:   13:e3985e582fc4
    |/     branch:      feature-x
    |      user:        Arne Babenhauserheide <bab at draketo.de>
    |      date:        Sat Aug 18 10:53:45 2012 +0200
    |      summary:     x
    | 
    o    changeset:   12:70d38749f7dd
    |\   parent:      9:760af400d190
    | |  parent:      11:cf4cf65df405
    | |  user:        Arne Babenhauserheide <bab at draketo.de>
    | |  date:        Sat Aug 18 10:53:45 2012 +0200
    | |  summary:     merged stable into default: ready for more development


Commands:

* Start the feature

        hg branch feature-x 
        (edit)
        hg ci -m "message"

* Do an intermediate commit on default

        hg update default
        (edit)
        hg ci -m "message"

* Continue working on the feature

        hg update feature-x
        (edit)
        hg ci -m "message"
    
* Merge the feature

        hg update default
        hg merge feature-x
        hg ci -m "merged feature x into default"`

* Close and merge a finished feature

        hg update feature-x
        hg ci --close-branch -m "finished feature x"
        hg update default; hg merge feature-x
        hg ci -m "merged finished feature x into default"

*Note: Closing the feature branch hides that branch in the output of `hg 
heads` and `hg branches` (except when using `--closed`) to make the repository 
state lean and simple while still keeping the feature branch information in 
history. It shows your collegues, that they no longer have to keep the feature 
in mind as soon as they merge the most recent changes from the default branch 
into their own feature branches.*

*Note: To make the final merge of your feature into default easier, you can 
regularly merge the default branch into the feature branch.*


Best wishes,
Arne
--
Konstruktive Kritik: 

- http://draketo.de/licht/krude-ideen/konstruktive-kritik

-------------- 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/20120818/2a4a8c65/attachment.asc>


More information about the Mercurial mailing list