Patchwork [2,of,2] graft: use missing ancestors algorithm to find earlier grafts

login
register
mail settings
Submitter Siddharth Agarwal
Date April 7, 2013, 3:15 a.m.
Message ID <99a410e82b35e71d5f61.1365304524@sid0x220>
Download mbox | patch
Permalink /patch/1258/
State Accepted
Commit ce8c169a0decf607c68fb019d23c09349427d058
Headers show

Comments

Siddharth Agarwal - April 7, 2013, 3:15 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1365303003 25200
#      Sat Apr 06 19:50:03 2013 -0700
# Node ID 99a410e82b35e71d5f6121a9b9bfc11103678e83
# Parent  aff777b0929f7c26ffe97f226389271dd3d353d4
graft: use missing ancestors algorithm to find earlier grafts

When the revisions to graft are numerically close to the destination, this
avoids two walks up the DAG, which for a repository with over 470,000
changesets translates to around 2.2 seconds.
Augie Fackler - April 7, 2013, 8:20 p.m.
Pushed both of these, thanks

On Apr 6, 2013, at 11:15 PM, Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1365303003 25200
> #      Sat Apr 06 19:50:03 2013 -0700
> # Node ID 99a410e82b35e71d5f6121a9b9bfc11103678e83
> # Parent  aff777b0929f7c26ffe97f226389271dd3d353d4
> graft: use missing ancestors algorithm to find earlier grafts
> 
> When the revisions to graft are numerically close to the destination, this
> avoids two walks up the DAG, which for a repository with over 470,000
> changesets translates to around 2.2 seconds.
> 
> diff -r aff777b0929f -r 99a410e82b35 mercurial/commands.py
> --- a/mercurial/commands.py	Sat Apr 06 20:05:17 2013 -0700
> +++ b/mercurial/commands.py	Sat Apr 06 19:50:03 2013 -0700
> @@ -2937,7 +2937,9 @@ def graft(ui, repo, *revs, **opts):
> 
>     # check ancestors for earlier grafts
>     ui.debug('scanning for duplicate grafts\n')
> -    for ctx in repo.set("::. - ::%ld", revs):
> +
> +    for rev in repo.changelog.findmissingrevs(revs, [crev]):
> +        ctx = repo[rev]
>         n = ctx.extra().get('source')
>         if n in ids:
>             r = repo[n].rev()
> @@ -2951,7 +2953,7 @@ def graft(ui, repo, *revs, **opts):
>         elif ctx.hex() in ids:
>             r = ids[ctx.hex()]
>             ui.warn(_('skipping already grafted revision %s '
> -                            '(was grafted from %d)\n') % (r, ctx.rev()))
> +                            '(was grafted from %d)\n') % (r, rev))
>             revs.remove(r)
>     if not revs:
>         return -1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r aff777b0929f -r 99a410e82b35 mercurial/commands.py
--- a/mercurial/commands.py	Sat Apr 06 20:05:17 2013 -0700
+++ b/mercurial/commands.py	Sat Apr 06 19:50:03 2013 -0700
@@ -2937,7 +2937,9 @@  def graft(ui, repo, *revs, **opts):
 
     # check ancestors for earlier grafts
     ui.debug('scanning for duplicate grafts\n')
-    for ctx in repo.set("::. - ::%ld", revs):
+
+    for rev in repo.changelog.findmissingrevs(revs, [crev]):
+        ctx = repo[rev]
         n = ctx.extra().get('source')
         if n in ids:
             r = repo[n].rev()
@@ -2951,7 +2953,7 @@  def graft(ui, repo, *revs, **opts):
         elif ctx.hex() in ids:
             r = ids[ctx.hex()]
             ui.warn(_('skipping already grafted revision %s '
-                            '(was grafted from %d)\n') % (r, ctx.rev()))
+                            '(was grafted from %d)\n') % (r, rev))
             revs.remove(r)
     if not revs:
         return -1