touch: allow divergence with -A even if allowdivergence=no
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 04 Feb 2020 16:22:40 -0800
changeset 5135 731b5a89a784
parent 5134 d9b1336f7d1c
child 5136 bbf33d5f32ef
touch: allow divergence with -A even if allowdivergence=no 1f92a6aa40d6 (evolve: add pre-check logic for content-divergence in rewriteutil.precheck(), 2019-11-04) taught `rewriteutil.precheck()` to check for divergence. It also set allowdivergence=yes in test-touch.t to silence the error. However, if one does *not* have that set, it is no longer possible to allow divergence with `hg touch -A`. This patch fixes that.
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/rewriteutil.py
tests/test-touch.t
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Feb 04 13:43:16 2020 -0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Feb 04 16:22:40 2020 -0800
@@ -1389,7 +1389,8 @@
 
     duplicate = opts['duplicate']
     if not duplicate:
-        rewriteutil.precheck(repo, revs, b'touch')
+        # allowdivergence=True because we'll do our own checking later instead
+        rewriteutil.precheck(repo, revs, b'touch', allowdivergence=True)
     tmpl = utility.shorttemplate
     displayer = compat.changesetdisplayer(ui, repo, {b'template': tmpl})
     with repo.wlock(), repo.lock(), repo.transaction(b'touch'):
--- a/hgext3rd/evolve/rewriteutil.py	Tue Feb 04 13:43:16 2020 -0800
+++ b/hgext3rd/evolve/rewriteutil.py	Tue Feb 04 16:22:40 2020 -0800
@@ -51,7 +51,7 @@
         summary %= (node.short(tonode(first)), numrevs - 1)
     return summary
 
-def precheck(repo, revs, action=b'rewrite'):
+def precheck(repo, revs, action=b'rewrite', allowdivergence=None):
     """check if <revs> can be rewritten
 
     <action> can be used to control the commit message.
@@ -77,8 +77,9 @@
         hint = _(b"see 'hg help evolution.instability'")
         raise error.Abort(msg, hint=hint)
     divrisk = revs_hascontentdivrisk(repo, revs)
-    allowdivergence = repo.ui.configbool(b'experimental',
-                                         b'evolution.allowdivergence')
+    if allowdivergence is None:
+        allowdivergence = repo.ui.configbool(b'experimental',
+                                             b'evolution.allowdivergence')
     if divrisk and not allowdivergence:
         localdiv = repo[divrisk[0]]
         otherdiv, base = repo[divrisk[1][0]], repo[divrisk[1][1]]
--- a/tests/test-touch.t	Tue Feb 04 13:43:16 2020 -0800
+++ b/tests/test-touch.t	Tue Feb 04 16:22:40 2020 -0800
@@ -6,8 +6,6 @@
   > amend=-d "0 0"
   > [alias]
   > glog = log -GT "{rev}: {desc}"
-  > [experimental]
-  > evolution.allowdivergence = True
   > [extensions]
   > hgext.rebase=
   > EOF