multiple branches in one respository?
Sanjoy Mahajan
sanjoy at mrao.cam.ac.uk
Mon Aug 29 21:59:48 CDT 2005
Great, thanks for the comments. One other advantage of multiple
directories is fault tolerance -- if you trash one of the
repositories, you're not hosed entirely, whereas if all your revisions
are in one directory, bad news.
> Mercurial is neutral on this. You can certainly do it, switching
> back and forth between branches in a single repository until you're
> blue in the face.
Which reminds me of a bug in switching branches that's still around
(already sent it to the list and Matt said he thinks it's a bug but
didn't hear any more).
To reproduce it I just tried the following commands using the current
hg (version a33a7a543803). The file 'a' lives on both branches, and
'main' is created in 0->1, 'side1' is created in 0->2, and 'side2' is
created in 2->3. The graph at the end:
$ hg debugindexdot .hg/00changelog.i
digraph G {
-1 -> 0
0 -> 1
0 -> 2
2 -> 3
}
Here's the transcript with explanations of what went wrong in /* ... */:
$ hg init
$ touch a ; hg add a ; hg commit -m "Added a"
$ touch main ; hg add main ; hg commit -m "Added main"
/* Now go back to the root */
$ hg checkout 0
force None allow None moddirstate True linear True
ancestor 8515d4bfda76 local 0594b9004bae remote 8515d4bfda76
remote deleted main /* that's right */
$ ls
a /* 'main' is gone, which is good */
$ touch side1 ; hg add side1 ; hg commit -m "Added side1"
$ touch side2 ; hg add side2 ; hg commit -m "Added side2"
$ hg log
manifest: 0:8515d4bfda768e04af4c13a69a72e28c7effbea7
manifest: 1:0594b9004bae4fd6ae30249e13749a5b404d3908
manifest: 2:801e2e89e32d305b05ff90362e76f0b906733708
manifest: 3:1c0f48f8ece6bd9d310686145943c3aca307c1e6
changeset: 3:c532df2cd725
tag: tip
parent: 2:574c8f2a72d7
parent: -1:000000000000
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:50:58 2005 -0400
summary: Added side2
changeset: 2:574c8f2a72d7
parent: 0:8ee7d4ade127
parent: -1:000000000000
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:50:47 2005 -0400
summary: Added side1
changeset: 1:df3652cbfb44
parent: 0:8ee7d4ade127
parent: -1:000000000000
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:49:16 2005 -0400
summary: Added main
changeset: 0:8ee7d4ade127
parent: -1:000000000000
parent: -1:000000000000
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:48:01 2005 -0400
summary: Added a
$ hg heads
changeset: 3:c532df2cd725
tag: tip
parent: 2:574c8f2a72d7
parent: -1:000000000000
manifest: 3:1c0f48f8ece6bd9d310686145943c3aca307c1e6
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:50:58 2005 -0400
summary: Added side2
changeset: 1:df3652cbfb44
parent: 0:8ee7d4ade127
parent: -1:000000000000
manifest: 1:0594b9004bae4fd6ae30249e13749a5b404d3908
user: Sanjoy Mahajan <sanjoy at mrao.cam.ac.uk>
date: Mon Aug 29 22:49:16 2005 -0400
summary: Added main
$ ls
a side1 side2 /* this is right */
/* Now I want to go back to the tree with 'a' and 'main' */
$ hg checkout -C 1
force 1 allow None moddirstate True linear False
ancestor 8515d4bfda76 local 1c0f48f8ece6 remote 0594b9004bae
local created side2, keeping /* this is not right */
local created side1, keeping /* nor is this */
remote created main /* this is right */
$ ls
a main side1 side2 /* should have been just 'a' and 'main' */
/* as shown in the manifest: */
$ hg manifest 1
b80de5d138758541c5f05265ad144ab9fa86d1db 644 a
b80de5d138758541c5f05265ad144ab9fa86d1db 644 main
-Sanjoy
More information about the Mercurial
mailing list