--- a/tests/test-fold.t Fri Sep 06 13:23:25 2019 +0700
+++ b/tests/test-fold.t Wed Aug 28 18:30:58 2019 +0700
@@ -381,3 +381,35 @@
o 0: r0
$ cd ..
+
+Fold should respect experimental.evolution.allowdivergence option
+https://bz.mercurial-scm.org/show_bug.cgi?id=5817
+
+ $ hg init issue5817
+ $ cd issue5817
+
+ $ echo A > foo
+ $ hg ci -qAm A
+ $ echo B > foo
+ $ hg ci -m B
+ $ echo C > foo
+ $ hg ci -m C
+
+ $ hg fold --exact -r 'desc("A")::desc("B")' -m 'first fold'
+ 1 new orphan changesets
+ 2 changesets folded
+
+FIXME: fold should abort 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
+
+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 changesets folded
+
+ $ cd ..