Patchwork [03,of,10,V2] branchmap: merge _branchtags into updatebranchcache

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 20, 2012, 2:08 p.m.
Message ID <7fb0f8672f361e05e78c.1356012513@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/203/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Headers show

Comments

Pierre-Yves David - Dec. 20, 2012, 2:08 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356006209 -3600
# Node ID 7fb0f8672f361e05e78cce6c95c02928f752ddb6
# Parent  322a1c4c3fff352d7694647c291e4edefa1ccc6a
branchmap: merge _branchtags into updatebranchcache

Now that nobody overwrite it, there is no reasons for `_branchtags` to remains
separated from `updatebranchcache`.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -642,13 +642,24 @@  class localrepository(object):
         better alternative. But we are using this approach until it is ready.
         """
         cl = self.changelog
         return cl.rev(cl.tip())
 
-    def _branchtags(self, partial, lrev):
-        # TODO: rename this function?
+    @unfilteredmethod # Until we get a smarter cache management
+    def updatebranchcache(self):
         cl = self.changelog
+        tip = cl.tip()
+        if self._branchcache is not None and self._branchcachetip == tip:
+            return
+
+        oldtip = self._branchcachetip
+        if oldtip is None or oldtip not in cl.nodemap:
+            partial, last, lrev = self._readbranchcache()
+        else:
+            lrev = cl.rev(oldtip)
+            partial = self._branchcache
+
         catip = self._cacheabletip()
         # if lrev == catip: cache is already up to date
         # if lrev >  catip: we have uncachable element in `partial` can't write
         #                   on disk
         if lrev < catip:
@@ -661,30 +672,12 @@  class localrepository(object):
         # written to disk since it's not cacheable.
         tiprev = len(self) - 1
         if lrev < tiprev:
             ctxgen = (self[r] for r in cl.revs(lrev + 1, tiprev))
             self._updatebranchcache(partial, ctxgen)
-        return partial
-
-    @unfilteredmethod # Until we get a smarter cache management
-    def updatebranchcache(self):
-        cl = self.changelog
-        tip = cl.tip()
-        if self._branchcache is not None and self._branchcachetip == tip:
-            return
-
-        oldtip = self._branchcachetip
+        self._branchcache = partial
         self._branchcachetip = tip
-        if oldtip is None or oldtip not in cl.nodemap:
-            partial, last, lrev = self._readbranchcache()
-        else:
-            lrev = cl.rev(oldtip)
-            partial = self._branchcache
-
-        self._branchtags(partial, lrev)
-        # this private cache holds all heads (not just the branch tips)
-        self._branchcache = partial
 
     def branchmap(self):
         '''returns a dictionary {branch: [branchheads]}'''
         if self.changelog.filteredrevs:
             # some changeset are excluded we can't use the cache