[PATCH 8 of 9] teach commit how to close branches
Alexis S. L. Carvalho
alexis at cecm.usp.br
Sun Mar 2 13:01:30 CST 2008
# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Date 1204481759 10800
# Node ID efbc14991a6e45cd59514c74abae4765e19d0cd0
# Parent 5cf7311702a4ae5dd8e3e865bdd88d4cff3f2e1f
teach commit how to close branches
The name of the branch to close is read from .hg/closebranch.
extra["closebranch"] is set to this name; extra["closebranchnodes"]
is set to the hex node of the branch head being closed. If there's
more than one branch head, they're simply concatenated.
diff -r 5cf7311702a4 -r efbc14991a6e mercurial/localrepo.py
--- a/mercurial/localrepo.py Sun Mar 02 15:15:59 2008 -0300
+++ b/mercurial/localrepo.py Sun Mar 02 15:15:59 2008 -0300
@@ -880,8 +880,21 @@ class localrepository(repo.repository):
branchname = branchname.decode('UTF-8').encode('UTF-8')
except UnicodeDecodeError:
raise util.Abort(_('branch name not in UTF-8!'))
+ cbranchname = self.dirstate.getclosedbranch()
+ try:
+ cbranchname = cbranchname.decode('UTF-8').encode('UTF-8')
+ except UnicodeDecodeError:
+ raise util.Abort(_('name of the branch to close '
+ 'is not in UTF-8!'))
+ if cbranchname:
+ cbranchnodes = self.closebranchnodes(cbranchname, (p1, p2))
+ if not cbranchnodes:
+ raise util.Abort(_('could not find a head of branch '
+ '%s to close!')
+ % util.tolocal(cbranchname))
else:
branchname = ""
+ cbranchname = ""
if use_dirstate:
oldname = c1[5].get("branch") # stored in UTF-8
@@ -978,6 +991,9 @@ class localrepository(repo.repository):
if branchname:
extra["branch"] = branchname
+ if cbranchname:
+ extra["closebranch"] = cbranchname
+ extra["closebranchnodes"] = ''.join(map(hex, cbranchnodes))
if use_dirstate:
lines = [line.rstrip() for line in text.rstrip().splitlines()]
@@ -1001,6 +1017,7 @@ class localrepository(repo.repository):
if use_dirstate:
for f in removed:
self.dirstate.forget(f)
+ self.dirstate.closebranch('')
valid = 1 # our dirstate updates are complete
self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
diff -r 5cf7311702a4 -r efbc14991a6e tests/test-inherit-mode.out
--- a/tests/test-inherit-mode.out Sun Mar 02 15:15:59 2008 -0300
+++ b/tests/test-inherit-mode.out Sun Mar 02 15:15:59 2008 -0300
@@ -13,6 +13,7 @@ 00770 ./.hg/store/
% new directories are setgid
00700 ./.hg/
00600 ./.hg/00changelog.i
+00660 ./.hg/closebranch
00660 ./.hg/dirstate
00600 ./.hg/requires
00770 ./.hg/store/
diff -r 5cf7311702a4 -r efbc14991a6e tests/test-newbranch
--- a/tests/test-newbranch Sun Mar 02 15:15:59 2008 -0300
+++ b/tests/test-newbranch Sun Mar 02 15:15:59 2008 -0300
@@ -25,6 +25,7 @@ hg branch -c bar
hg branch -c bar
hg branch -c
hg ci -m "clear branch name" -d "1000000 0"
+hg tip --debug
hg co foo
hg branch
@@ -80,7 +81,7 @@ hg branch
hg branch
hg branch -c
hg commit -m'Merge ff into foo' -d '1000000 0'
-hg parents
+hg parents --debug
hg manifest
exit 0
diff -r 5cf7311702a4 -r efbc14991a6e tests/test-newbranch.out
--- a/tests/test-newbranch.out Sun Mar 02 15:15:59 2008 -0300
+++ b/tests/test-newbranch.out Sun Mar 02 15:15:59 2008 -0300
@@ -11,6 +11,20 @@ abort: there's no branch named invalid!
% close branch bar
branch bar will be closed on the next commit
bar
+changeset: 3:a78f15a8bec6b186583cf0e7992b9dee7943d1b5
+tag: tip
+parent: 2:67ec16bde7f1575d523313b9bca000f6a6f12dca
+parent: -1:0000000000000000000000000000000000000000
+manifest: 3:a509574fa286984de0a407d93516e1d713d6c4db
+user: test
+date: Mon Jan 12 13:46:40 1970 +0000
+extra: branch=default
+extra: closebranch=bar
+extra: closebranchnodes=67ec16bde7f1575d523313b9bca000f6a6f12dca
+description:
+clear branch name
+
+
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
foo
% fail to close a branch where no head is our ancestor
@@ -18,11 +32,11 @@ 0 files updated, 0 files merged, 0 files
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
foo
-changeset: 5:5f8fb06e083e
+changeset: 5:5321a81a517f
branch: foo
tag: tip
parent: 4:4909a3732169
-parent: 3:bf1bc2f45e83
+parent: 3:a78f15a8bec6
user: test
date: Mon Jan 12 13:46:40 1970 +0000
summary: merge
@@ -34,7 +48,7 @@ date: Mon Jan 12 13:46:40 1970 +0
date: Mon Jan 12 13:46:40 1970 +0000
summary: modify a branch
-changeset: 3:bf1bc2f45e83
+changeset: 3:a78f15a8bec6
user: test
date: Mon Jan 12 13:46:40 1970 +0000
summary: clear branch name
@@ -56,8 +70,8 @@ date: Mon Jan 12 13:46:40 1970 +0
date: Mon Jan 12 13:46:40 1970 +0000
summary: initial
-foo 5:5f8fb06e083e
-default 3:bf1bc2f45e83 (inactive)
+foo 5:5321a81a517f
+default 3:a78f15a8bec6 (inactive)
bar 2:67ec16bde7f1 (inactive)
foo
default
@@ -89,7 +103,7 @@ modify a branch
4:4909a3732169
4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
-bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default
+a78f15a8bec6b186583cf0e7992b9dee7943d1b5 default
4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
67ec16bde7f1575d523313b9bca000f6a6f12dca bar
% push should update the branch cache
@@ -98,11 +112,11 @@ be8523e69bf892e25817fc97187516b3c0804ae4
be8523e69bf892e25817fc97187516b3c0804ae4 default
% pushing everything
4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
-bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default
+a78f15a8bec6b186583cf0e7992b9dee7943d1b5 default
4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
67ec16bde7f1575d523313b9bca000f6a6f12dca bar
% update with no arguments: tipmost revision of the current branch
-bf1bc2f45e83
+a78f15a8bec6
4909a3732169 (foo) tip
marked working directory as branch foobar
abort: branch foobar not found
@@ -115,14 +129,21 @@ branch ff will be closed on the next com
branch ff will be closed on the next commit
foo
ff
-changeset: 6:f0c74f92a385
+changeset: 6:999d9aa54cfdd36173c3f502721d59a2848b0ce3
branch: foo
tag: tip
-parent: 4:4909a3732169
-parent: 5:c420d2121b71
+parent: 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
+parent: 5:c420d2121b71a05a99c19ab792a63ad23c9e5183
+manifest: 6:e6c6f59eb59cbb6369004f138497b0ef71f14268
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: Merge ff into foo
+files+: ff
+extra: branch=foo
+extra: closebranch=ff
+extra: closebranchnodes=c420d2121b71a05a99c19ab792a63ad23c9e5183
+description:
+Merge ff into foo
+
a
ff
More information about the Mercurial-devel
mailing list