# HG changeset patch # User Thomas Arendsen Hein # Date 1173460142 -3600 # Node ID 4574a8cb080fdf284ec7a002523020e52c4e8ce1 # Parent bfeff6dcac7a64fdddc5557849343450fd29ac9a Store empty (default) branch in branch cache, too. Operations on this branch don't work otherwise. Reading branches.cache had to be adjusted to allow an empty label. Adjusted reading of the cache tip for symmetry, no functional change here. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -376,7 +376,7 @@ class localrepository(repo.repository): f = self.opener("branches.cache") lines = f.read().split('\n') f.close() - last, lrev = lines.pop(0).rstrip().split(" ", 1) + 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 @@ -384,8 +384,8 @@ class localrepository(repo.repository): 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: @@ -407,8 +407,7 @@ class localrepository(repo.repository): 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 == '.': diff --git a/tests/test-diffdir b/tests/test-diffdir --- a/tests/test-diffdir +++ b/tests/test-diffdir @@ -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" diff --git a/tests/test-diffdir.out b/tests/test-diffdir.out --- a/tests/test-diffdir.out +++ b/tests/test-diffdir.out @@ -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 @@ diff --git a/tests/test-encoding.out b/tests/test-encoding.out --- a/tests/test-encoding.out +++ b/tests/test-encoding.out @@ -126,10 +126,13 @@ tip 5:db5 é 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: é diff --git a/tests/test-log b/tests/test-log --- a/tests/test-log +++ b/tests/test-log @@ -47,6 +47,7 @@ hg log -pv d # 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' diff --git a/tests/test-log.out b/tests/test-log.out --- a/tests/test-log.out +++ b/tests/test-log.out @@ -105,19 +105,22 @@ adding base 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 @@ summary: base 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 @@ 2 files updated, 0 files merged, 1 files 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 diff --git a/tests/test-newbranch.out b/tests/test-newbranch.out --- a/tests/test-newbranch.out +++ b/tests/test-newbranch.out @@ -43,8 +43,10 @@ date: Mon Jan 12 13:46:40 1970 +0 summary: initial foo 5:5f8fb06e083e + 3:bf1bc2f45e83 bar 2:67ec16bde7f1 foo + bar % test for invalid branch cache rolling back last transaction @@ -73,5 +75,6 @@ modify a branch 4:4909a3732169 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 +bf1bc2f45e834c75404d0ddab57d53beab56e2f8 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo 67ec16bde7f1575d523313b9bca000f6a6f12dca bar