Patchwork [2,of,4] branchmap: pass revision insteads of changectx to the update function

mail settings
Submitter Pierre-Yves David
Date Jan. 11, 2013, 6:17 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/547/
State Accepted
Commit 2502a15e033d693bbf0651173d1762a337f7b8cf
Headers show


Pierre-Yves David - Jan. 11, 2013, 6:17 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1357604919 -3600
# Node ID 0ea0b0c68cbee6d9a257a942eba773f00f696d3a
# Parent  fa58abc613ba57fdbbdbe265ab00be2fbf82fad7
branchmap: pass revision insteads of changectx to the update function

Create of changectx are very slow and not very useful. We are going to drop
them. The first step is to change the function argument type.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -75,12 +75,11 @@  def updatecache(repo):
                 partial = subset.branchmap().copy()
                 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
                 revs.extend(r for  r in extrarevs if r <= partial.tiprev)
     revs.extend(cl.revs(start=partial.tiprev + 1))
     if revs:
-        ctxgen = (repo[r] for r in revs)
-        partial.update(repo, ctxgen)
+        partial.update(repo, revs)
     assert partial.validfor(repo)
     repo._branchcaches[repo.filtername] = partial
 class branchcache(dict):
@@ -142,16 +141,17 @@  class branchcache(dict):
         except (IOError, OSError, util.Abort):
             # Abort may be raise by read only opener
-    def update(self, repo, ctxgen):
+    def update(self, repo, revgen):
         """Given a branchhead cache, self, that may have extra nodes or be
         missing heads, and a generator of nodes that are at least a superset of
         heads missing, this function updates self to be correct.
         cl = repo.changelog
+        ctxgen = (repo[r] for r in revgen)
         # collect new branch entries
         newbranches = {}
         for c in ctxgen:
             newbranches.setdefault(c.branch(), []).append(c.node())
         # if older branchheads are reachable from new ones, they aren't
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -194,11 +194,11 @@  def _headssummary(repo, remote, outgoing
     # D. Update newmap with outgoing changes.
     # This will possibly add new heads and remove existing ones.
     newmap = branchmap.branchcache((branch, heads[1])
                                  for branch, heads in headssum.iteritems()
                                  if heads[0] is not None)
-    newmap.update(repo, missingctx)
+    newmap.update(repo, (ctx.rev() for ctx in missingctx))
     for branch, newheads in newmap.iteritems():
         headssum[branch][1][:] = newheads
     return headssum
 def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1404,14 +1404,15 @@  class localrepository(object):
         # If we have info, newheadnodes, on how to update the branch cache, do
         # it, Otherwise, since nodes were destroyed, the cache is stale and this
         # will be caught the next time it is read.
         if newheadnodes:
-            ctxgen = (self[node] for node in newheadnodes
-                      if self.changelog.hasnode(node))
+            cl = self.changelog
+            revgen = (cl.rev(node) for node in newheadnodes
+                      if cl.hasnode(node))
             cache = self._branchcaches[None]
-            cache.update(self, ctxgen)
+            cache.update(self, revgen)
         # Ensure the persistent tag cache is updated.  Doing it now
         # means that the tag cache only has to worry about destroyed
         # heads immediately after a strip/rollback.  That in turn