Patchwork [02,of,10] bundlerepo: improve performance for bundle() revset expression

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 16, 2013, 7:57 p.m.
Message ID <e246188705491d7faa73.1358366246@mk-desktop>
Download mbox | patch
Permalink /patch/662/
State Accepted
Commit 8b0f0dd56cecb552c839154d92f8a3db3a1d7c9a
Headers show

Comments

Mads Kiilerich - Jan. 16, 2013, 7:57 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@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.
tonfa - Jan. 16, 2013, 8:15 p.m.
LGTM


On Wed, Jan 16, 2013 at 8:57 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski@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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



On Wed, Jan 16, 2013 at 8:57 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski@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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

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