bundlerepo: improve performance for bundle() revset expression

Create the set of revision numbers directly instead of creating a list of nodes
first.
This commit is contained in:
Mads Kiilerich 2013-01-16 20:41:34 +01:00
parent 2539797b50
commit 7bc546e4e0
2 changed files with 6 additions and 7 deletions

View File

@ -25,8 +25,7 @@ class bundlerevlog(revlog.revlog):
# (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 @@ class bundlerevlog(revlog.revlog):
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 @@ class bundlerevlog(revlog.revlog):
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 @@ class bundlerevlog(revlog.revlog):
self.basemap[n] = deltabase
self.index.insert(-1, e)
self.nodemap[node] = n
self.bundlerevs.add(n)
chain = node
n += 1

View File

@ -450,11 +450,10 @@ def bundle(repo, subset, x):
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