fold: check allowdivergence before folding obsolete changesets (issue5817) stable
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 07 Sep 2019 13:03:29 +0700
branchstable
changeset 4832 8a491546e81d
parent 4831 0852dcba82f6
child 4839 485a9f3490c9
child 4841 95d2b5440731
fold: check allowdivergence before folding obsolete changesets (issue5817)
CHANGELOG
hgext3rd/evolve/cmdrewrite.py
tests/test-fold.t
--- a/CHANGELOG	Wed Aug 28 18:30:58 2019 +0700
+++ b/CHANGELOG	Sat Sep 07 13:03:29 2019 +0700
@@ -5,6 +5,7 @@
 -------------------
 
   * evolve: test that target is not orig in _solveunstable() (issue6097)
+  * fold: check allowdivergence before folding obsolete changesets (issue5817)
   * obslog: correct spacing of patch output with word-diff=yes (issue6175)
   * stack: make sure to preserve dependencies, fixes certain complex cases
 
--- a/hgext3rd/evolve/cmdrewrite.py	Wed Aug 28 18:30:58 2019 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Sat Sep 07 13:03:29 2019 +0700
@@ -762,6 +762,14 @@
         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/tests/test-fold.t	Wed Aug 28 18:30:58 2019 +0700
+++ b/tests/test-fold.t	Sat Sep 07 13:03:29 2019 +0700
@@ -254,7 +254,8 @@
   
 Test order of proposed commit message
 
-  $ hg fold --exact --hidden -r 4 -r 5 -r 6
+  $ hg fold --exact --hidden -r 4 -r 5 -r 6 \
+  >         --config experimental.evolution.allowdivergence=yes
   2 new content-divergent changesets
   3 changesets folded
   $ hg log -r tip -T '{desc}'
@@ -265,7 +266,8 @@
   
   
   r6 (no-eol)
-  $ hg fold --exact --hidden -r 6 -r 4 -r 5
+  $ hg fold --exact --hidden -r 6 -r 4 -r 5 \
+  >         --config experimental.evolution.allowdivergence=yes
   3 changesets folded
   $ hg log -r tip -T '{desc}'
   r4
@@ -399,17 +401,19 @@
   1 new orphan changesets
   2 changesets folded
 
-FIXME: fold should abort here because divergence is not allowed
+fold aborts here because divergence is not allowed
 
   $ hg fold --exact -r 'desc("A")::desc("B")' -m 'second fold' \
   >         --config experimental.evolution.allowdivergence=no
-  2 new content-divergent changesets
-  2 changesets folded
+  abort: folding obsolete revisions may cause divergence
+  (set experimental.evolution.allowdivergence=yes to allow folding them)
+  [255]
 
 but if we allow divergence, this should work and should create new content-divergent changesets
 
   $ hg fold --exact -r 'desc("A")::desc("B")' -m 'second fold' \
   >         --config experimental.evolution.allowdivergence=yes
+  2 new content-divergent changesets
   2 changesets folded
 
   $ cd ..