[PATCH 1 of 3 v3] branchmap: rename branchcache to branchheadcache

Mads Kiilerich mads at kiilerich.com
Wed Oct 15 20:19:46 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1413421352 -7200
#      Thu Oct 16 03:02:32 2014 +0200
# Node ID 1937d5ede058a1d2ad53ac1f9b6b755482fd9d8c
# Parent  48c0b101a9de1fdbd638daa858da845cd05a6be7
branchmap: rename branchcache to branchheadcache

Call it what it is. The future might bring something that _is_ a branch cache,
not just a branch head cache.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -11,7 +11,7 @@ import util
 import time
 
 def _filename(repo):
-    """name of a branchcache file for a given repo or repoview"""
+    """name of a branch head cache file for a given repo or repoview"""
     filename = "cache/branch2"
     if repo.filtername:
         filename = '%s-%s' % (filename, repo.filtername)
@@ -32,8 +32,8 @@ def read(repo):
         filteredhash = None
         if len(cachekey) > 2:
             filteredhash = bin(cachekey[2])
-        partial = branchcache(tipnode=last, tiprev=lrev,
-                              filteredhash=filteredhash)
+        partial = branchheadcache(tipnode=last, tiprev=lrev,
+                                  filteredhash=filteredhash)
         if not partial.validfor(repo):
             # invalidate the cache
             raise ValueError('tip differs')
@@ -84,7 +84,7 @@ def updatecache(repo):
         if partial is None:
             subsetname = subsettable.get(filtername)
             if subsetname is None:
-                partial = branchcache()
+                partial = branchheadcache()
             else:
                 subset = repo.filtered(subsetname)
                 partial = subset.branchmap().copy()
@@ -97,7 +97,7 @@ def updatecache(repo):
     assert partial.validfor(repo), filtername
     repo._branchcaches[repo.filtername] = partial
 
-class branchcache(dict):
+class branchheadcache(dict):
     """A dict like object that hold branches heads cache.
 
     This cache is used to avoid costly computations to determine all the
@@ -121,7 +121,7 @@ class branchcache(dict):
 
     def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
                  filteredhash=None, closednodes=None):
-        super(branchcache, self).__init__(entries)
+        super(branchheadcache, self).__init__(entries)
         self.tipnode = tipnode
         self.tiprev = tiprev
         self.filteredhash = filteredhash
@@ -194,9 +194,9 @@ class branchcache(dict):
             yield (bn, heads) + self._branchtip(heads)
 
     def copy(self):
-        """return an deep copy of the branchcache object"""
-        return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
-                           self._closednodes)
+        """return an deep copy of the branchheadcache object"""
+        return branchheadcache(self, self.tipnode, self.tiprev,
+                               self.filteredhash, self._closednodes)
 
     def write(self, repo):
         try:
@@ -216,8 +216,8 @@ class branchcache(dict):
                     f.write("%s %s %s\n" % (hex(node), state,
                                             encoding.fromlocal(label)))
             f.close()
-            repo.ui.log('branchcache',
-                        'wrote %s branch cache with %d labels and %d nodes\n',
+            repo.ui.log('branchheadcache', 'wrote %s branch head cache '
+                        'with %d labels and %d nodes\n',
                         repo.filtername, len(self), nodecount)
         except (IOError, OSError, util.Abort), inst:
             repo.ui.debug("couldn't write branch cache: %s\n" % inst)
@@ -283,5 +283,5 @@ class branchcache(dict):
         self.filteredhash = self._hashfiltered(repo)
 
         duration = time.time() - starttime
-        repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
-                    repo.filtername, duration)
+        repo.ui.log('branchheadcache', 'updated %s branch head cache '
+                    'in %.4f seconds\n', repo.filtername, duration)


More information about the Mercurial-devel mailing list