Move branches.cache to branch.cache
authorMatt Mackall <mpm@selenic.com>
Tue, 13 Mar 2007 15:18:10 -0500
changeset 4177 a7af0eeae8a3
parent 4176 f9bbcebcacea
child 4178 0b48e3985765
Move branches.cache to branch.cache Keeps old clients from conflicting with new caches, makes features logic unnecessary.
mercurial/localrepo.py
tests/test-mq-caches
tests/test-mq-caches.out
tests/test-newbranch
tests/test-newbranch.out
--- a/mercurial/localrepo.py	Tue Mar 13 15:02:33 2007 -0300
+++ b/mercurial/localrepo.py	Tue Mar 13 15:18:10 2007 -0500
@@ -17,7 +17,6 @@
 class localrepository(repo.repository):
     capabilities = ('lookup', 'changegroupsubset')
     supported = ('revlogv1', 'store')
-    branchcache_features = ('default',)
 
     def __del__(self):
         self.transhandle = None
@@ -374,25 +373,9 @@
     def _readbranchcache(self):
         partial = {}
         try:
-            f = self.opener("branches.cache")
+            f = self.opener("branch.cache")
             lines = f.read().split('\n')
             f.close()
-            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
@@ -413,8 +396,7 @@
 
     def _writebranchcache(self, branches, tip, tiprev):
         try:
-            f = self.opener("branches.cache", "w")
-            f.write(" features: %s\n" % ' '.join(self.branchcache_features))
+            f = self.opener("branch.cache", "w")
             f.write("%s %s\n" % (hex(tip), tiprev))
             for label, node in branches.iteritems():
                 f.write("%s %s\n" % (hex(node), label))
--- a/tests/test-mq-caches	Tue Mar 13 15:02:33 2007 -0300
+++ b/tests/test-mq-caches	Tue Mar 13 15:18:10 2007 -0500
@@ -5,7 +5,7 @@
 
 show_branch_cache()
 {
-    branches=.hg/branches.cache
+    branches=.hg/branch.cache
     # force cache (re)generation
     hg log -r does-not-exist 2> /dev/null
     hg log -r tip --template 'tip: #rev#\n'
@@ -61,7 +61,7 @@
 
 echo
 echo '# removing the cache'
-rm .hg/branches.cache
+rm .hg/branch.cache
 show_branch_cache 1
 
 echo
--- a/tests/test-mq-caches.out	Tue Mar 13 15:02:33 2007 -0300
+++ b/tests/test-mq-caches.out	Tue Mar 13 15:18:10 2007 -0500
@@ -1,13 +1,12 @@
 # mq patch on an empty repo
 tip: 0
-No .hg/branches.cache
+No .hg/branch.cache
 tip: 0
-No .hg/branches.cache
+No .hg/branch.cache
 
 # some regular revisions
 Patch queue now empty
 tip: 1
- features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -16,12 +15,10 @@
 applying p1
 Now at: p1
 tip: 2
- features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
 tip: 3
- features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -30,7 +27,6 @@
 
 # removing the cache
 tip: 3
- features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -39,7 +35,6 @@
 
 # importing rev 1 (the cache now ends in one of the patches)
 tip: 3
- features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -54,6 +49,5 @@
 applying p2
 Now at: p2
 tip: 3
- features: default
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
--- a/tests/test-newbranch	Tue Mar 13 15:02:33 2007 -0300
+++ b/tests/test-newbranch	Tue Mar 13 15:18:10 2007 -0500
@@ -30,39 +30,14 @@
 
 echo % test for invalid branch cache
 hg rollback
-cp .hg/branches.cache .hg/bc-invalid
+cp .hg/branch.cache .hg/bc-invalid
 hg log -r foo
-cp .hg/bc-invalid .hg/branches.cache
+cp .hg/bc-invalid .hg/branch.cache
 hg --debug log -r foo
-rm .hg/branches.cache
-echo corrupted > .hg/branches.cache
+rm .hg/branch.cache
+echo corrupted > .hg/branch.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
+cat .hg/branch.cache
 
 echo % update with no arguments: tipmost revision of the current branch
 hg up -q -C 0
--- a/tests/test-newbranch.out	Tue Mar 13 15:02:33 2007 -0300
+++ b/tests/test-newbranch.out	Tue Mar 13 15:18:10 2007 -0500
@@ -74,26 +74,10 @@
 
 
 4:4909a3732169
- features: default
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
 bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
 67ec16bde7f1575d523313b9bca000f6a6f12dca bar
-% test for different branch cache features
-branch cache: no features specified
-foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
-bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
-branch cache: missing features: default
-foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
-bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
-branch cache: missing features: default
-foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
-bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
-% test old hg reading branch cache with feature list
-ValueError raised correctly, good.
 % update with no arguments: tipmost revision of the current branch
 bf1bc2f45e83
 4909a3732169 (foo) tip