Patchwork [05,of,13] cleanupnodes: drop special casing around prune markers

login
register
mail settings
Submitter Boris Feld
Date Sept. 27, 2018, 5:08 p.m.
Message ID <4c65b3d61c4505f4d719.1538068117@localhost.localdomain>
Download mbox | patch
Permalink /patch/35145/
State Accepted
Headers show

Comments

Boris Feld - Sept. 27, 2018, 5:08 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1537990101 -7200
#      Wed Sep 26 21:28:21 2018 +0200
# Node ID 4c65b3d61c4505f4d719d657a087b3a254ddb5c5
# Parent  f70aad5388994c9dd8f1b6f814ed648252c378a0
# EXP-Topic trackfold
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4c65b3d61c45
cleanupnodes: drop special casing around prune markers

The `cleanupnodes` has logic to skip the creation of "prune" markers if the
changeset is already obsolete. This feels strange and gets in the way of code
changes to tracks folds. Now that callers no longer request such prune, we can
drop this logic.

In many cases, pruning through cleanupnodes should be replaced by internal
phase usage.
Yuya Nishihara - Sept. 30, 2018, 12:27 p.m.
On Thu, 27 Sep 2018 19:08:37 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1537990101 -7200
> #      Wed Sep 26 21:28:21 2018 +0200
> # Node ID 4c65b3d61c4505f4d719d657a087b3a254ddb5c5
> # Parent  f70aad5388994c9dd8f1b6f814ed648252c378a0
> # EXP-Topic trackfold
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4c65b3d61c45
> cleanupnodes: drop special casing around prune markers

Flagged this as (API) since it might lead to a subtle bug.

> @@ -978,15 +978,13 @@ def cleanupnodes(repo, replacements, ope
>              # Also sort the node in topology order, that might be useful for
>              # some obsstore logic.
>              # NOTE: the filtering and sorting might belong to createmarkers.

Can you update the inline comment as a follow up?

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -978,15 +978,13 @@  def cleanupnodes(repo, replacements, ope
             # Also sort the node in topology order, that might be useful for
             # some obsstore logic.
             # NOTE: the filtering and sorting might belong to createmarkers.
-            isobs = unfi.obsstore.successors.__contains__
             torev = unfi.changelog.rev
             sortfunc = lambda ns: torev(ns[0][0])
             rels = []
             for ns, s in sorted(replacements.items(), key=sortfunc):
                 for n in ns:
-                    if s or not isobs(n):
-                        rel = (unfi[n], tuple(unfi[m] for m in s))
-                        rels.append(rel)
+                    rel = (unfi[n], tuple(unfi[m] for m in s))
+                    rels.append(rel)
             if rels:
                 obsolete.createmarkers(repo, rels, operation=operation,
                                        metadata=metadata)
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -1246,7 +1246,7 @@  Test high-level scmutil.cleanupnodes API
   >                            node(b'D'): [node(b'D2')],
   >                            node(b'G'): [node(b'G2')]}
   >                 scmutil.cleanupnodes(repo, mapping, b'replace')
-  >                 scmutil.cleanupnodes(repo, nodes(b'((B::)+I+Z)-D2'),
+  >                 scmutil.cleanupnodes(repo, nodes(b'((B::)+I+Z)-D2-obsolete()'),
   >                                      b'replace')
   > EOF
   $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py