diff mercurial/scmutil.py @ 33330:ba43e5ee9c6d

scmutil: make cleanupnodes handle filtered node In some valid usecases, the "mapping" received by scmutil.cleanupnodes have filtered nodes. Use unfiltered repo to access them correctly. The added test case will fail with the old cleanupnodes code. This is important to migrate histedit to use the cleanupnodes API.
author Jun Wu <quark@fb.com>
date Mon, 26 Jun 2017 15:08:37 -0700
parents 53b3a1968aa6
children 4bae3c117b57
line wrap: on
line diff
--- a/mercurial/scmutil.py	Fri Jul 07 08:33:10 2017 +0200
+++ b/mercurial/scmutil.py	Mon Jun 26 15:08:37 2017 -0700
@@ -619,9 +619,12 @@
             # 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 = repo.obsstore.successors.__contains__
-            sortfunc = lambda ns: repo.changelog.rev(ns[0])
-            rels = [(repo[n], (repo[m] for m in s))
+            # Unfiltered repo is needed since nodes in mapping might be hidden.
+            unfi = repo.unfiltered()
+            isobs = unfi.obsstore.successors.__contains__
+            torev = unfi.changelog.rev
+            sortfunc = lambda ns: torev(ns[0])
+            rels = [(unfi[n], (unfi[m] for m in s))
                     for n, s in sorted(mapping.items(), key=sortfunc)
                     if s or not isobs(n)]
             obsolete.createmarkers(repo, rels, operation=operation)