Patchwork [5,of,7] histedit: pass multiple nodes to strip (BC)

login
register
mail settings
Submitter Jun Wu
Date July 8, 2017, 11:51 p.m.
Message ID <9a325ae88021e0e02a87.1499557893@x1c>
Download mbox | patch
Permalink /patch/22143/
State Accepted
Headers show

Comments

Jun Wu - July 8, 2017, 11:51 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1499557831 25200
#      Sat Jul 08 16:50:31 2017 -0700
# Node ID 9a325ae88021e0e02a87ef1ae6baa8a199405140
# Parent  d1b9eb1ad8ac5f9e645337034594862e1ba37092
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9a325ae88021
histedit: pass multiple nodes to strip (BC)

Previously, histedit.cleanupnode pass root nodes one by one. Since
repair.strip takes multiple nodes and can handle them just fine, pass all
strip roots at once.

This is BC because the number of strip backup files may change from N to 1.
via Mercurial-devel - July 9, 2017, 5:02 p.m.
On Sat, Jul 8, 2017 at 4:51 PM, Jun Wu <quark@fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1499557831 25200
> #      Sat Jul 08 16:50:31 2017 -0700
> # Node ID 9a325ae88021e0e02a87ef1ae6baa8a199405140
> # Parent  d1b9eb1ad8ac5f9e645337034594862e1ba37092
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9a325ae88021
> histedit: pass multiple nodes to strip (BC)
>
> Previously, histedit.cleanupnode pass root nodes one by one. Since
> repair.strip takes multiple nodes and can handle them just fine, pass all
> strip roots at once.
>
> This is BC because the number of strip backup files may change from N to 1.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -1604,9 +1604,6 @@ def cleanupnode(ui, repo, nodes):
>          nodes = sorted(n for n in nodes if n in nm)
>          roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
> -        for c in roots:
> -            # We should process node in reverse order to strip tip most first.
> -            # but this trigger a bug in changegroup hook.
> -            # This would reduce bundle overhead

Oddly enough, all the histedit tests pass with your patch applied even
in the revision that introduced this comment -- 4eb13b619785
(histedit: factorise node stripping logic, 2012-09-26). The commit
message didn't mention the problem, so I don't know how to reproduce
the "bug in changegroup hook". We'll just have to assume it's been
fixed (if it was ever there).

> -            repair.strip(ui, repo, c)
> +        if roots:
> +            repair.strip(ui, repo, roots)
>
>  def safecleanupnode(ui, repo, nodes):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1604,9 +1604,6 @@  def cleanupnode(ui, repo, nodes):
         nodes = sorted(n for n in nodes if n in nm)
         roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
-        for c in roots:
-            # We should process node in reverse order to strip tip most first.
-            # but this trigger a bug in changegroup hook.
-            # This would reduce bundle overhead
-            repair.strip(ui, repo, c)
+        if roots:
+            repair.strip(ui, repo, roots)
 
 def safecleanupnode(ui, repo, nodes):