changeset 5126:d57f4326623e

fold: replace a compat condition with a less specific proxy If `scmutil.cleanupnodes()` is overridden, the check in `scmutil.cleanupnodes.__code__.co_varnames` will fail. Let's use a less specific proxy for that condition so extensions are safely override `scmutil.cleanupnodes()`. I picked `util.safehasattr(scmutil, 'nullrev')` as the proxy. That basically checks for Mercurial commit d739f423bf06, which is two commits later than the commit we actually care about.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 04 Feb 2020 12:46:55 -0800
parents ce8479d1a6f9
children f4fae6359593
files hgext3rd/evolve/cmdrewrite.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Feb 11 17:21:43 2020 +0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Feb 04 12:46:55 2020 -0800
@@ -801,7 +801,9 @@
                                                          p2.node()],
                                                         commitopts=commitopts)
             phases.retractboundary(repo, tr, targetphase, [newid])
-            if 'repls' in scmutil.cleanupnodes.__code__.co_varnames:
+            # Use this condition as a proxy since the commit we care about
+            # (b99903534e06) didn't change any signatures.
+            if util.safehasattr(scmutil, 'nullrev'):
                 replacements = {tuple(ctx.node() for ctx in allctx): [newid]}
                 scmutil.cleanupnodes(repo, replacements, operation=b"fold",
                                      metadata=metadata)