Code Lab

Mercurial Named Branches

This example shows how Mercurial named branches keep a faithful record of the history of a branch.

#!/bin/bash # # Mercurial and Named Branches # cd /tmp if [ -d named_branches ]; then rm -rf named_branches fi hg init named_branches cd named_branches hg summary echo 'zero' > default.txt hg add hg commit -m zero -d '0 0' --user Fulano hg branch hg branch stable hg summary echo 'one' > stable.txt hg add hg commit -m one -d '0 0' --user Beltrano echo 'two' >> stable.txt hg commit -m two -d '0 0' --user Beltrano hg update default echo 'three' >> default.txt hg commit -m tres -d '0 0' --user Fulano hg log -G hg log -G --template '{rev}:{node|short} | {branch}' hg branches hg merge stable hg commit -m four -d '0 0' --user Beltrano hg update 3 hg branch bug echo 'five' > bug.txt hg add hg commit -m five -d '0 0' --user Fulano echo 'six' >> bug.txt hg commit -m six -d '0 0' --user Fulano hg update default hg merge bug hg commit -m seven -d '0 0' --user Fulano hg up 0 hg branch feature echo 'eigth' > feature.txt hg add hg commit -m eigth -d '0 0' --user Fulano hg merge bug hg commit -m nine -d '0 0' --user Fulano echo -e '\n\n========\ndefault\n========' hg log -Gqb default echo -e '\n\n=======\nfeature\n=======' hg log -Gqb feature echo -e '\n\n===\nbug\n===' hg log -Gqb bug echo -e '\n\n======\nstable\n======' hg log -Gqb stable
:
Input
Input Data (stdin):
Output
parent: -1:000000000000 tip (empty repository)
branch: default
commit: (clean)
update: (current)
adding default.txt
default
marked working directory as branch stable
(branches are permanent and global, did you want a bookmark?)
parent: 0:495b558b0306 tip
 zero
branch: stable
commit: (new branch)
update: (current)
phases: 1 draft
adding stable.txt
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
@  changeset:   3:5aeec51ebb65
|  tag:         tip
|  parent:      0:495b558b0306
|  user:        Fulano
|  date:        Thu Jan 01 00:00:00 1970 +0000
|  summary:     tres
|
| o  changeset:   2:928bcbab9b90
| |  branch:      stable
| |  user:        Beltrano
| |  date:        Thu Jan 01 00:00:00 1970 +0000
| |  summary:     two
| |
| o  changeset:   1:360d67e6e7b9
|/   branch:      stable
|    user:        Beltrano
|    date:        Thu Jan 01 00:00:00 1970 +0000
|    summary:     one
|
o  changeset:   0:495b558b0306
   user:        Fulano
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     zero

@  3:5aeec51ebb65 | default
|
| o  2:928bcbab9b90 | stable
| |
| o  1:360d67e6e7b9 | stable
|/
o  0:495b558b0306 | default

default                        3:5aeec51ebb65
stable                         2:928bcbab9b90
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
marked working directory as branch bug
adding bug.txt
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
marked working directory as branch feature
adding feature.txt
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)


========
default
========
o    7:f6aedb47c873
|\
o :  4:31d75556135b
:\:
: o  3:5aeec51ebb65
:/
o  0:495b558b0306



=======
feature
=======
@    9:2373841e2368
|\
| ~
o  8:745fb9c14a7b
|
~


===
bug
===
o  6:e0d178ee3557
|
o  5:ef830133871e
|
~


======
stable
======
o  2:928bcbab9b90
|
o  1:360d67e6e7b9
|
~