[PATCH 02 of 10] bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich
mads at kiilerich.com
Wed Jan 16 13:57:26 CST 2013
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1358365294 -3600
# Node ID e246188705491d7faa73afb13cfcd1ac79fd9dd3
# Parent 528c8be7d397d7c2638858006bdd9d55e3e2c314
bundlerepo: improve performance for bundle() revset expression
Create the set of revision numbers directly instead of creating a list of nodes
first.
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -35,7 +35,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:
@@ -51,10 +51,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):
@@ -67,6 +67,7 @@
self.basemap[n] = deltabase
self.index.insert(-1, e)
self.nodemap[node] = n
+ self.bundlerevs.add(n)
chain = node
n += 1
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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
More information about the Mercurial-devel
mailing list