changeset 18411:8b0f0dd56cec

bundlerepo: improve performance for bundle() revset expression Create the set of revision numbers directly instead of creating a list of nodes first.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 16 Jan 2013 20:41:34 +0100
parents de7dac2a58e8
children a928865b4a4f
files mercurial/bundlerepo.py mercurial/revset.py
diffstat 2 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Wed Jan 16 20:41:32 2013 +0100
+++ b/mercurial/bundlerepo.py	Wed Jan 16 20:41:34 2013 +0100
@@ -25,8 +25,7 @@
         # (start).
         #
         # basemap is indexed with revisions coming from the bundle, and it
-        # maps to the corresponding node that is the base of the corresponding
-        # delta.
+        # maps to the node that is the base of the corresponding delta.
         #
         # To differentiate a rev in the bundle from a rev in the revlog, we
         # check revision against basemap.
@@ -37,7 +36,7 @@
         n = len(self)
         self.disktiprev = n - 1
         chain = None
-        self.bundlenodes = []
+        self.bundlerevs = set() # used by 'bundle()' revset expression
         while True:
             chunkdata = bundle.deltachunk(chain)
             if not chunkdata:
@@ -53,10 +52,10 @@
             start = bundle.tell() - size
 
             link = linkmapper(cs)
-            self.bundlenodes.append(node)
             if node in self.nodemap:
                 # this can happen if two branches make the same change
                 chain = node
+                self.bundlerevs.add(self.nodemap[node])
                 continue
 
             for p in (p1, p2):
@@ -69,6 +68,7 @@
             self.basemap[n] = deltabase
             self.index.insert(-1, e)
             self.nodemap[node] = n
+            self.bundlerevs.add(n)
             chain = node
             n += 1
 
--- a/mercurial/revset.py	Wed Jan 16 20:41:32 2013 +0100
+++ b/mercurial/revset.py	Wed Jan 16 20:41:34 2013 +0100
@@ -450,11 +450,10 @@
     Bundle must be specified by the -R option."""
 
     try:
-        bundlenodes = repo.changelog.bundlenodes
+        bundlerevs = repo.changelog.bundlerevs
     except AttributeError:
         raise util.Abort(_("no bundle provided - specify with -R"))
-    revs = set(repo[n].rev() for n in bundlenodes)
-    return [r for r in subset if r in revs]
+    return [r for r in subset if r in bundlerevs]
 
 def checkstatus(repo, subset, pat, field):
     m = None