Store empty (default) branch in branch cache, too.
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 09 Mar 2007 18:09:02 +0100
changeset 4167 4574a8cb080f
parent 4157 bfeff6dcac7a
child 4168 bbfe5a3fc80c
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.
mercurial/localrepo.py
tests/test-diffdir
tests/test-diffdir.out
tests/test-encoding.out
tests/test-log
tests/test-log.out
tests/test-newbranch.out
--- a/mercurial/localrepo.py	Wed Mar 07 15:06:32 2007 +0100
+++ b/mercurial/localrepo.py	Fri Mar 09 18:09:02 2007 +0100
@@ -376,7 +376,7 @@
             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 @@
                 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 @@
         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	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-diffdir	Fri Mar 09 18:09:02 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	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-diffdir.out	Fri Mar 09 18:09:02 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	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-encoding.out	Fri Mar 09 18:09:02 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	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-log	Fri Mar 09 18:09:02 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	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-log.out	Fri Mar 09 18:09:02 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-newbranch.out	Wed Mar 07 15:06:32 2007 +0100
+++ b/tests/test-newbranch.out	Fri Mar 09 18:09:02 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
@@ -73,5 +75,6 @@
 
 4:4909a3732169
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
+bf1bc2f45e834c75404d0ddab57d53beab56e2f8 
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
 67ec16bde7f1575d523313b9bca000f6a6f12dca bar