changeset 4841:95d2b5440731 stable

rewriteutil: move allowdivergence check to foldcheck() foldcheck() calls precheck() first and then performs more fold-specific checks.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 10 Sep 2019 15:43:20 +0700
parents 8a491546e81d
children ee0866a279da
files hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/rewriteutil.py
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Sat Sep 07 13:03:29 2019 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Sep 10 15:43:20 2019 +0700
@@ -762,14 +762,6 @@
         ui.write_err(_('single revision specified, nothing to fold\n'))
         return 1
 
-    if not ui.configbool('experimental', 'evolution.allowdivergence'):
-        for rev in revs:
-            if repo[rev].obsolete():
-                msg = _('folding obsolete revisions may cause divergence')
-                hint = _('set experimental.evolution.allowdivergence=yes'
-                         ' to allow folding them')
-                raise error.Abort(msg, hint=hint)
-
     # Sort so combined commit message of `hg fold --exact -r . -r .^` is
     # in topological order.
     revs.sort()
--- a/hgext3rd/evolve/rewriteutil.py	Sat Sep 07 13:03:29 2019 +0700
+++ b/hgext3rd/evolve/rewriteutil.py	Tue Sep 10 15:43:20 2019 +0700
@@ -117,6 +117,13 @@
     if len(baseparents) > 2:
         raise error.Abort(_("cannot fold revisions that merge with more than "
                             "one external changeset (not in revisions)"))
+    if not repo.ui.configbool('experimental', 'evolution.allowdivergence'):
+        obsolete = repo.revs('%ld and obsolete()', revs)
+        if obsolete:
+            msg = _('folding obsolete revisions may cause divergence')
+            hint = _('set experimental.evolution.allowdivergence=yes'
+                     ' to allow folding them')
+            raise error.Abort(msg, hint=hint)
     # root's p1 is already used as the target ctx p1
     baseparents -= {root.p1().rev()}
     p2 = repo[baseparents.first()]