--- a/mercurial/localrepo.py Thu Mar 08 20:08:24 2007 -0300
+++ b/mercurial/localrepo.py Fri Mar 09 20:08:13 2007 +0100
@@ -15,6 +15,7 @@
class localrepository(repo.repository):
capabilities = ('lookup', 'changegroupsubset')
supported = ('revlogv1', 'store')
+ branchcache_features = ('unnamed',)
def __del__(self):
self.transhandle = None
@@ -397,7 +398,23 @@
f = self.opener("branches.cache")
lines = f.read().split('\n')
f.close()
- last, lrev = lines.pop(0).rstrip().split(" ", 1)
+ features = lines.pop(0).strip()
+ if not features.startswith('features: '):
+ raise ValueError(_('branch cache: no features specified'))
+ features = features.split(' ', 1)[1].split()
+ missing_features = []
+ for feature in self.branchcache_features:
+ try:
+ features.remove(feature)
+ except ValueError, inst:
+ missing_features.append(feature)
+ if missing_features:
+ raise ValueError(_('branch cache: missing features: %s')
+ % ', '.join(missing_features))
+ if features:
+ raise ValueError(_('branch cache: unknown features: %s')
+ % ', '.join(features))
+ last, lrev = lines.pop(0).split(" ", 1)
last, lrev = bin(last), int(lrev)
if not (lrev < self.changelog.count() and
self.changelog.node(lrev) == last): # sanity check
@@ -405,8 +422,8 @@
raise ValueError('Invalid branch cache: unknown tip')
for l in lines:
if not l: continue
- node, label = l.rstrip().split(" ", 1)
- partial[label] = bin(node)
+ node, label = l.split(" ", 1)
+ partial[label.strip()] = bin(node)
except (KeyboardInterrupt, util.SignalInterrupt):
raise
except Exception, inst:
@@ -418,6 +435,7 @@
def _writebranchcache(self, branches, tip, tiprev):
try:
f = self.opener("branches.cache", "w")
+ f.write(" features: %s\n" % ' '.join(self.branchcache_features))
f.write("%s %s\n" % (hex(tip), tiprev))
for label, node in branches.iteritems():
f.write("%s %s\n" % (hex(node), label))
@@ -428,8 +446,7 @@
for r in xrange(start, end):
c = self.changectx(r)
b = c.branch()
- if b:
- partial[b] = c.node()
+ partial[b] = c.node()
def lookup(self, key):
if key == '.':
--- a/tests/test-diffdir Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-diffdir Fri Mar 09 20:08:13 2007 +0100
@@ -1,6 +1,7 @@
#!/bin/sh
hg init
+hg branch dummy # needed so -r "" doesn't point to the unnamed/default branch
touch a
hg add a
hg ci -m "a" -d "1000000 0"
--- a/tests/test-diffdir.out Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-diffdir.out Fri Mar 09 20:08:13 2007 +0100
@@ -1,19 +1,19 @@
-diff -r acd8075edac9 b
+diff -r 4da5fa99f904 b
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
+123
-diff -r acd8075edac9 b
+diff -r 4da5fa99f904 b
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
+123
-diff -r acd8075edac9 a
+diff -r 4da5fa99f904 a
--- a/a
+++ b/a
@@ -0,0 +1,1 @@
+foo
-diff -r acd8075edac9 b
+diff -r 4da5fa99f904 b
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
--- a/tests/test-encoding.out Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-encoding.out Fri Mar 09 20:08:13 2007 +0100
@@ -126,10 +126,13 @@
é 3:770b9b11621d
% ascii
? 5:db5520b4645f
+ 4:9cff3c980b58
% latin-1
é 5:db5520b4645f
+ 4:9cff3c980b58
% utf-8
é 5:db5520b4645f
+ 4:9cff3c980b58
% utf-8
changeset: 5:db5520b4645f
branch: é
--- a/tests/test-log Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-log Fri Mar 09 20:08:13 2007 +0100
@@ -47,6 +47,7 @@
# log --follow tests
hg init ../follow
cd ../follow
+hg branch dummy # needed so -r "" doesn't point to the unnamed/default branch
echo base > base
hg ci -Ambase -d '1 0'
--- a/tests/test-log.out Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-log.out Fri Mar 09 20:08:13 2007 +0100
@@ -105,19 +105,22 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding b1
% log -f
-changeset: 3:e62f78d544b4
+changeset: 3:07a62f044f0d
+branch: dummy
tag: tip
-parent: 1:3d5bf5654eda
+parent: 1:fb3d4e35b279
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1
-changeset: 1:3d5bf5654eda
+changeset: 1:fb3d4e35b279
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: r1
-changeset: 0:67e992f2c4f3
+changeset: 0:ea445bfed6b9
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: base
@@ -125,18 +128,21 @@
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
adding b2
% log -f -r 1:tip
-changeset: 1:3d5bf5654eda
+changeset: 1:fb3d4e35b279
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: r1
-changeset: 2:60c670bf5b30
+changeset: 2:e8882cbc828c
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: r2
-changeset: 3:e62f78d544b4
-parent: 1:3d5bf5654eda
+changeset: 3:07a62f044f0d
+branch: dummy
+parent: 1:fb3d4e35b279
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1
@@ -145,57 +151,66 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
% log --follow-first
-changeset: 6:2404bbcab562
+changeset: 6:0f621dafa603
+branch: dummy
tag: tip
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1.1
-changeset: 5:302e9dd6890d
-parent: 3:e62f78d544b4
-parent: 4:ddb82e70d1a1
+changeset: 5:0cf53fb6dfd5
+branch: dummy
+parent: 3:07a62f044f0d
+parent: 4:b76598590bc3
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: m12
-changeset: 3:e62f78d544b4
-parent: 1:3d5bf5654eda
+changeset: 3:07a62f044f0d
+branch: dummy
+parent: 1:fb3d4e35b279
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1
-changeset: 1:3d5bf5654eda
+changeset: 1:fb3d4e35b279
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: r1
-changeset: 0:67e992f2c4f3
+changeset: 0:ea445bfed6b9
+branch: dummy
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: base
% log -P 2
-changeset: 6:2404bbcab562
+changeset: 6:0f621dafa603
+branch: dummy
tag: tip
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1.1
-changeset: 5:302e9dd6890d
-parent: 3:e62f78d544b4
-parent: 4:ddb82e70d1a1
+changeset: 5:0cf53fb6dfd5
+branch: dummy
+parent: 3:07a62f044f0d
+parent: 4:b76598590bc3
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: m12
-changeset: 4:ddb82e70d1a1
-parent: 0:67e992f2c4f3
+changeset: 4:b76598590bc3
+branch: dummy
+parent: 0:ea445bfed6b9
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b2
-changeset: 3:e62f78d544b4
-parent: 1:3d5bf5654eda
+changeset: 3:07a62f044f0d
+branch: dummy
+parent: 1:fb3d4e35b279
user: test
date: Thu Jan 01 00:00:01 1970 +0000
summary: b1
--- a/tests/test-mq-caches.out Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-mq-caches.out Fri Mar 09 20:08:13 2007 +0100
@@ -7,6 +7,7 @@
# some regular revisions
Patch queue now empty
tip: 1
+ features: unnamed
3f910abad313ff802d3a23a7529433872df9b3ae 1
3f910abad313ff802d3a23a7529433872df9b3ae bar
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -15,10 +16,12 @@
applying p1
Now at: p1
tip: 2
+ features: unnamed
3f910abad313ff802d3a23a7529433872df9b3ae 1
3f910abad313ff802d3a23a7529433872df9b3ae bar
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
tip: 3
+ features: unnamed
3f910abad313ff802d3a23a7529433872df9b3ae 1
3f910abad313ff802d3a23a7529433872df9b3ae bar
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -27,6 +30,7 @@
# removing the cache
tip: 3
+ features: unnamed
3f910abad313ff802d3a23a7529433872df9b3ae 1
3f910abad313ff802d3a23a7529433872df9b3ae bar
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -35,6 +39,7 @@
# importing rev 1 (the cache now ends in one of the patches)
tip: 3
+ features: unnamed
3f910abad313ff802d3a23a7529433872df9b3ae 1
3f910abad313ff802d3a23a7529433872df9b3ae bar
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -49,5 +54,6 @@
applying p2
Now at: p2
tip: 3
+ features: unnamed
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0
9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
--- a/tests/test-newbranch Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-newbranch Fri Mar 09 20:08:13 2007 +0100
@@ -38,3 +38,28 @@
echo corrupted > .hg/branches.cache
hg log -qr foo
cat .hg/branches.cache
+
+echo % test for different branch cache features
+echo '4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4' > .hg/branches.cache
+hg branches --debug
+echo ' features: unnamed dummy foo bar' > .hg/branches.cache
+hg branches --debug
+echo ' features: dummy' > .hg/branches.cache
+hg branches --debug
+
+echo % test old hg reading branch cache with feature list
+python << EOF
+import binascii
+f = file('.hg/branches.cache')
+lines = f.read().split('\n')
+f.close()
+firstline = lines[0]
+last, lrev = lines.pop(0).rstrip().split(" ", 1)
+try:
+ last, lrev = binascii.unhexlify(last), int(lrev)
+except ValueError, inst:
+ if str(inst) == "invalid literal for int():%s" % firstline:
+ print "ValueError raised correctly, good."
+ else:
+ print "ValueError: %s" % inst
+EOF
--- a/tests/test-newbranch.out Thu Mar 08 20:08:24 2007 -0300
+++ b/tests/test-newbranch.out Fri Mar 09 20:08:13 2007 +0100
@@ -43,8 +43,10 @@
summary: initial
foo 5:5f8fb06e083e
+ 3:bf1bc2f45e83
bar 2:67ec16bde7f1
foo
+
bar
% test for invalid branch cache
rolling back last transaction
@@ -72,6 +74,23 @@
4:4909a3732169
+ features: unnamed
4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
+bf1bc2f45e834c75404d0ddab57d53beab56e2f8
4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
67ec16bde7f1575d523313b9bca000f6a6f12dca bar
+% test for different branch cache features
+branch cache: no features specified
+foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
+ 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca
+branch cache: unknown features: dummy, foo, bar
+foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
+ 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca
+branch cache: missing features: unnamed
+foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
+ 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca
+% test old hg reading branch cache with feature list
+ValueError raised correctly, good.