diff tests/test-amend.t @ 5079:1f92a6aa40d6

evolve: add pre-check logic for content-divergence in rewriteutil.precheck() For now, pre-check will abort if rewriting a rev create divergence (and config experimental.evolution.allowdivergence is not set to True). But this behaviour can be improved where instead of abort maybe we can confirm the user to either proceed with divergence or some other options depends on what command user is running. Changes in test file are used to overrides the pre-check for testing purpose (using experimental.evolution.allowdivergence=yes).
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Mon, 04 Nov 2019 01:30:50 +0530
parents 588b3484c131
children 900668a93629
line wrap: on
line diff
--- a/tests/test-amend.t	Wed Jan 01 21:36:21 2020 +0530
+++ b/tests/test-amend.t	Mon Nov 04 01:30:50 2019 +0530
@@ -121,6 +121,9 @@
   update: (current)
   phases: 3 draft
 
+setting the user after we have performed the test with no username
+  $ HGUSER=test
+
 Check the help
   $ hg amend -h
   hg amend [OPTION]... [FILE]...
@@ -170,3 +173,63 @@
   $ hg amend --patch --extract
   abort: cannot use both --patch and --extract
   [255]
+
+  $ cd ..
+
+Check the pre-check logic for content-divergence
+  $ hg init precheckrepo
+  $ cd precheckrepo
+  $ echo a > a
+  $ hg ci -Am "added a"
+  adding a
+  $ echo newchanges > a
+  $ hg amend
+  $ hg up 0 --hidden -q
+  updated to hidden changeset 9092f1db7931
+  (hidden revision '9092f1db7931' was rewritten as: aafaf407b00d)
+  working directory parent is obsolete! (9092f1db7931)
+
+when rewritting an already rewritten changeset (i.e cset being rewritten will
+be the base of divergence)
+  $ hg amend -m "i am gonna create divergence"
+  abort: amend of 9092f1db7931 creates content-divergence with aafaf407b00d
+  (add --verbose for details or see 'hg help evolution.instability')
+  [255]
+  $ hg amend -m "i am gonna create divergence" --verbose
+  abort: amend of 9092f1db7931 creates content-divergence with aafaf407b00d
+      changeset 9092f1db7931 already have a successors as changeset aafaf407b00d
+      rewriting changeset 9092f1db7931 would create "content-divergence"
+      set experimental.evolution.allowdivergence=True to overwrite this check
+  (see 'hg help evolution.instability' for details on content-divergence)
+  [255]
+
+when rewritting a cset which has a predecessor with non-obsolete successor
+
+to prepare the repo
+1) create content-divergence
+2) remove divergence by pruning one of the divergent cset
+  $ echo edited_a > a
+  $ hg ci -m "edited a"
+  1 new orphan changesets
+  $ hg debugobsolete $(hg id -ir 0 --debug) $(hg id -ir 2 --debug)
+  1 new obsolescence markers
+  2 new content-divergent changesets
+
+remove divergence by pruning one side of divergenence
+  $ hg debugobsolete $(hg id -ir 2 --debug)
+  1 new obsolescence markers
+  obsoleted 1 changesets
+
+  $ hg evolve -l
+  $ hg amend -m "i am gonna create divergence"
+  abort: amend of f8c05838af90 creates content-divergence with aafaf407b00d, from 9092f1db7931
+  (add --verbose for details or see 'hg help evolution.instability')
+  [255]
+  $ hg amend -m "i am gonna create divergence" --verbose
+  abort: amend of f8c05838af90 creates content-divergence with aafaf407b00d, from 9092f1db7931
+      changeset f8c05838af90 is an evolution of changeset 9092f1db7931
+      changeset 9092f1db7931 already have a successors as changeset aafaf407b00d
+      rewriting changeset f8c05838af90 would create "content-divergence"
+      set experimental.evolution.allowdivergence=True to overwrite this check
+  (see 'hg help evolution.instability' for details on content-divergence)
+  [255]