RFC: Revised branching implementation
Andrew Beekhof
beekhof at gmail.com
Wed Sep 6 10:16:47 UTC 2006
On 9/4/06, Andrew Beekhof <beekhof at gmail.com> wrote:
> On 9/4/06, Andrew Beekhof <abeekhof at suse.de> wrote:
> >
> > Take 3 :-)
> >
> >
> > On Matt's suggestion I have implemented branching in the repository's
> > changelog instead of hgbranches.
> >
> > Specifically, I chose to create a new index format, which may or may not
> > have been what Matt intended, and I'm happy to discuss the appropriateness
> > of that decision.
> >
> > Because of this, in order to use the new branching code one needs to specify
> > the --pull option to "hg clone". This option will convert the repo to the
> > required index format.
> >
> >
> > Properties of this implementation:
> > commands.branch : O(1)
> > commands.branches : see repo.branch_list belowrepo.branch_list
> > : O(changesets) (cached)
> > repo.branch_for_(node|rev) : O(1)
> > repo.branch_head : O(heads)
> > fallback case uses repo.branch_list when the branch is not currently a
> > head
> >
> > repo.branch_list could possibly be speed up with some extra cleverness.
> >
> > Commits that do not include a branch name lookup p1's branch name and use
> > that (which I believe also achieves the required behavior during merges).
> >
> >
> > Attached is an exported series of changes that implements this feature set.
> > The individual patches are also available
> > from http://hg.beekhof.net/hg/revlog-branching
> >
> > I'm interested to know what people think...
>
>
> Below is also some indicative usage information:
>
> laptop::beekhof hg # mkdir test
> laptop::beekhof hg # cd test
> laptop::beekhof test # export hg=../hg-br/hg
>
> laptop::beekhof test # $hg init
>
> test::patches test # $hg tip
> changeset: -1:000000000000
> tag: tip
> user:
> date: Thu Jan 01 00:00:00 1970 +0000
> files:
>
> test::patches test # echo foo >> bar
>
> test::patches test # $hg add bar
> adding bar
>
> test::patches test # $hg commit -m "Initial commit" bar
> bar
>
> laptop::beekhof test # $hg tip
> changeset: 0:428ae582d6e3
> tag: tip
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:51:43 2006 +0200
> files: bar
> description:
> Initial commit
>
>
> laptop::beekhof test # $hg branch b-1
>
> laptop::beekhof test # $hg tip
> changeset: 1:ad7fa76e5b86
> tag: tip
> branch: b-1
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:52:08 2006 +0200
> files:
> description:
> Created branch b-1 originating from changeset 428ae582d6e3
>
>
> laptop::beekhof test # $hg branches
> b-1:ad7fa76e5b869a9645cc2cc84f19a346e4aba896:1
>
> laptop::beekhof test # $hg branch b-2
>
> laptop::beekhof test # $hg branches
> b-2:6888f7117068b13f9ee24a0306843b4e44331bf0:2
> b-1:ad7fa76e5b869a9645cc2cc84f19a346e4aba896:1
>
> laptop::beekhof test # $hg tip
> changeset: 2:6888f7117068
> tag: tip
> branch: b-2
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:52:29 2006 +0200
> files:
> description:
> Created branch b-2 originating from changeset ad7fa76e5b86
>
>
> laptop::beekhof test # $hg update -C b-1
> Translated b-1 into node ad7fa76e5b869a9645cc2cc84f19a346e4aba896
> resolving manifests
> 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>
>
> laptop::beekhof test # $hg branch b-3
>
> laptop::beekhof test # $hg heads
> changeset: 3:ef6ecbce1129
> tag: tip
> parent: 1:ad7fa76e5b86
> branch: b-3
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:53:37 2006 +0200
> files:
> description:
> Created branch b-3 originating from changeset 6888f7117068
>
>
> changeset: 2:6888f7117068
> branch: b-2
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:52:29 2006 +0200
> files:
> description:
> Created branch b-2 originating from changeset ad7fa76e5b86
>
>
> laptop::beekhof test # $hg merge b-2
> Translated b-2 into node 6888f7117068b13f9ee24a0306843b4e44331bf0
> resolving manifests
> 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> (branch merge, don't forget to commit)
>
> laptop::beekhof test # $hg commit -m "Merge with b-2"
> Inheriting branch name 'b-3' from ef6ecbce11296eed0b5321e41416241a21424b73
>
> laptop::beekhof test # $hg tip
> changeset: 4:194314eea8c5
> tag: tip
> parent: 3:ef6ecbce1129
> parent: 2:6888f7117068
> branch: b-3
> user: Andrew Beekhof <beekhof at gmail.com>
> date: Mon Sep 04 13:54:24 2006 +0200
> files:
> description:
> Merge with b-2
>
> laptop::beekhof test #
>
After some further consultation with people on IRC, here is an updated
branching patch.
Changes are attached and available from
http://hg.beekhof.net/hg/revlog-branching (which is now badly named)
Changes...
* "hg branches" matches the format of "hg tags"
* the branch name is now stored as a prefix to the description field
* no changes to the index format are required
* cloning with older clients preserves branching data
* "clone --pull" etc work without requiring any changes.
People running older clients will see:
test::empty test # hg tip
changeset: 4:66a5aa5e040e
tag: tip
parent: 3:44d9a22e5ca1
parent: 2:cc03f4fc73dc
user: Andrew Beekhof <beekhof at gmail.com>
date: Mon Sep 04 21:34:55 2006 +0200
files:
description:
HGBRANCH: b-3
Merge with b-2
People with new software will see:
test::empty test # ../cl-2/hg tip
changeset: 4:66a5aa5e040e
tag: tip
parent: 3:44d9a22e5ca1
parent: 2:cc03f4fc73dc
branch: b-3
user: Andrew Beekhof <beekhof at gmail.com>
date: Mon Sep 04 21:34:55 2006 +0200
files:
description:
Merge with b-2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changelog-branching.hgexport
Type: application/octet-stream
Size: 24031 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20060906/ff1e7a67/attachment-0001.obj>
More information about the Mercurial
mailing list