Home

Working with named branches

In the beginning there was foo.

$ hg init foo
$ cd foo

foo was not moving toward a stable release, there was only development. and development was on the default branch.

$ hg branch
default
$ echo a > a
$ hg ci -Am 'new feature a'
adding a
$ hg branches
default                        0:725571b72f46

foo is moving toward a stable release for the first time. foo gains a stable branch.

$ hg branch stable
marked working directory as branch stable
$ echo aa >> a
$ hg ci -m 'fixed bug in a'
$ hg branches
stable                         1:63659c0e31ee
default                        0:725571b72f46 (inactive)

foo is now back to development. foo updates to the default branch. "fixed bug in a" is not in the default branch yet.

$ hg up default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo b > b
$ hg ci -Am 'new feature b'
adding b
$ hg branches
default                        2:c72827efddf6
stable                         1:63659c0e31ee

foo needs that bug fix in the development branch. foo's stable branch is merged into default.

$ hg merge stable
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m 'merged with stable, we now have bug fix for a'
$ hg branches
default                        3:942ce0fa73b7
stable                         1:63659c0e31ee (inactive)

foo continues to receive new features on the default branch.

$ echo c > c
$ hg ci -Am 'new feature c'
$ hg branches
default                        4:a1adc26889f7
stable                         1:63659c0e31ee (inactive)

foo needs a new stable release. everything in the development branch will be a part of the stable branch now.

$ hg up stable
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ hg merge default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m 'yeehaw, making a new release.'
$ hg branches
stable                         5:7764860de2cc
default                        4:a1adc26889f7 (inactive)

foo is now ready to be published. it's tagged for 1.0.

$ hg tag 1.0

foo is now back in development.

$ hg up default
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo d > d
$ hg ci -Am 'new feature d'
adding d
$ hg branches
default                        6:68678ccd66a8
stable                         5:7764860de2cc

foo is back on stable for bug fixes.

$ hg up stable
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo aaa >> a
$ hg ci -m 'oh no, we screwed up something in 1.0. this fixes it'
$ hg tag 1.0.1
$ hg branches
stable                         9:46a260908a1b
default                        6:68678ccd66a8

And the cycle continues...

$ hg up default
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg merge stable
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg ci -m 'merge stable into default. this brings in 1.0.1 fixes'
$ hg branches
default                       10:89bec46c78cb
stable                         9:46a260908a1b (inactive)
$ hg glog
@    changeset:   10:89bec46c78cb
|\   tag:         tip
| |  parent:      7:68678ccd66a8
| |  parent:      9:46a260908a1b
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:32:52 2010 -0400
| |  summary:     merge stable into default. this brings in 1.0.1 fixes
| |
| o  changeset:   9:46a260908a1b
| |  branch:      stable
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:23:56 2010 -0400
| |  summary:     Added tag 1.0.1 for changeset 24c85ca572db
| |
| o  changeset:   8:24c85ca572db
| |  branch:      stable
| |  tag:         1.0.1
| |  parent:      6:f557900d1ece
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:23:51 2010 -0400
| |  summary:     oh no, we screwed up something in 1.0. this fixes it
| |
o |  changeset:   7:68678ccd66a8
| |  parent:      4:a1adc26889f7
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:23:26 2010 -0400
| |  summary:     new feature d
| |
| o  changeset:   6:f557900d1ece
| |  branch:      stable
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:23:15 2010 -0400
| |  summary:     Added tag 1.0 for changeset 7764860de2cc
| |
| o  changeset:   5:7764860de2cc
|/|  branch:      stable
| |  tag:         1.0
| |  parent:      1:63659c0e31ee
| |  parent:      4:a1adc26889f7
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:23:06 2010 -0400
| |  summary:     yeehaw, making a new release.
| |
o |  changeset:   4:a1adc26889f7
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:21:07 2010 -0400
| |  summary:     new feature c
| |
o |  changeset:   3:942ce0fa73b7
|\|  parent:      2:c72827efddf6
| |  parent:      1:63659c0e31ee
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:20:59 2010 -0400
| |  summary:     merged with stable, we now have bug fix for a
| |
o |  changeset:   2:c72827efddf6
| |  parent:      0:725571b72f46
| |  user:        Brodie Rao <brodie@bitheap.org>
| |  date:        Wed Sep 08 11:20:42 2010 -0400
| |  summary:     new feature b
| |
| o  changeset:   1:63659c0e31ee
|/   branch:      stable
|    user:        Brodie Rao <brodie@bitheap.org>
|    date:        Wed Sep 08 11:20:16 2010 -0400
|    summary:     fixed bug in a
|
o  changeset:   0:725571b72f46
   user:        Brodie Rao <brodie@bitheap.org>
   date:        Wed Sep 08 11:19:47 2010 -0400
   summary:     a

Notes for experienced users

  • The glog command is part of the graphlog extension. It comes with Mercurial.
  • A branch is "inactive" when the last commit to it was merging it into another branch.
  • The hg heads command, by default, includes the last changeset on each branch. When you see "(inactive)" in hg branches, that changeset will still show up in heads, despite being merged.
  • You can do "hg heads --topo" to get the real, topographical heads based on the changeset graph. This will exclude inactive branches from its output.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.