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

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 19, 2012, 1:53 p.m.
Message ID <bf7e57987ee82b00ec22.1355925199@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/190/
State Superseded, archived
Commit 35ce17796e0e8a9ee23978638ee1f5ab283b5e6e
Headers show

Comments

Pierre-Yves David - Dec. 19, 2012, 1:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1355924466 -3600
# Node ID bf7e57987ee82b00ec22f8131ddbbe97b188cbcd
# Parent  f8e00dbbb6bb0c871278d61fb979179162d3cdd4
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,25 @@  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):
+        self = self.unfiltered()  # Until we get a smarter cache management
         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._cachabletip()
         # 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:
@@ -658,30 +670,12 @@  class localrepository(object):
         # update cache up to current tip
         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 = self.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