tests: add more cases about stabilization of an orphaned merge commit
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 19 Mar 2018 14:03:41 +0100
changeset 3544 329056287ef5
parent 3543 93deeed63908
child 3545 6aff754c2457
tests: add more cases about stabilization of an orphaned merge commit This patch adds three more cases related to stabilization of orphaned merge commits.
tests/test-evolve-orphan-merge.t
--- a/tests/test-evolve-orphan-merge.t	Mon Mar 19 13:47:07 2018 +0100
+++ b/tests/test-evolve-orphan-merge.t	Mon Mar 19 14:03:41 2018 +0100
@@ -419,3 +419,167 @@
   $ hg evolve --all
   warning: no support for evolving merge changesets with two obsolete parents yet
   (Redo the merge (7b78a9784f3e) and use `hg prune <old> --succ <new>` to obsolete the old one)
+
+5) When one of the merge parent is pruned without a successor
+-------------------------------------------------------------
+
+  $ hg prune -r 7b78a9784
+  1 changesets pruned
+
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m "merged l and x"
+  $ hg glog
+  @    26:47e57ebc80aa merged l and x
+  |\    () draft
+  | o  25:cdf6547da25f added x
+  | |   () draft
+  o |  24:3f371171d767 added l
+  |/    () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+  $ hg prune -r cdf6547da25f
+  1 changesets pruned
+  1 new orphan changesets
+  $ hg glog
+  @    26:47e57ebc80aa merged l and x
+  |\    () draft
+  | x  25:cdf6547da25f added x
+  | |   () draft
+  o |  24:3f371171d767 added l
+  |/    () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+  $ hg evolve --rev .
+  move:[26] merged l and x
+  atop:[0] added hgignore
+  working directory is now at c117a030135c
+
+  $ hg glog
+  @    27:c117a030135c merged l and x
+  |\    () draft
+  | o  24:3f371171d767 added l
+  |/    () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+6) When one parent is pruned without successor and the other parent of merge is
+the parent of the pruned commit
+--------------------------------------------------------------------------------
+
+  $ hg glog
+  @    27:c117a030135c merged l and x
+  |\    () draft
+  | o  24:3f371171d767 added l
+  |/    () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+  $ hg prune -r 3f371171d767
+  1 changesets pruned
+  1 new orphan changesets
+
+  $ hg glog
+  @    27:c117a030135c merged l and x
+  |\    () draft
+  | x  24:3f371171d767 added l
+  |/    () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+This is the right thing to do here. When you have a merge changeset, and one
+parent is pruned and parent of that pruned parent is same as another parent of
+the merge changeset, that should lead to merge changeset being a non-merge
+changeset and non-pruned changeset as its only parent
+
+If you look at the above graph, the side part:
+
+\
+ x
+/
+
+is redundant now as the changeset is pruned and we should remove this chain
+while evolving.
+
+This case can occur a lot of times in workflows where people make branches and
+merge them again. After getting their work done, they may want to get rid of
+that branch and they prune all their changeset, which will result in this
+case where merge commit becomes orphan with its ancestors pruned up until a
+point where the other parent of merge is the first non-pruned ancestor.
+
+  $ hg evolve -r .
+  move:[27] merged l and x
+  atop:[0] added hgignore
+  working directory is now at 57b29ecd607c
+
+  $ hg glog
+  @  28:57b29ecd607c merged l and x
+  |   () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+7) When one parent is pruned without successor and has no parent
+----------------------------------------------------------------
+
+  $ hg prune -r .
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory now at 8fa14d15e168
+  1 changesets pruned
+  $ hg up null
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg glog
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+  $ echo foo > foo
+  $ hg add foo
+  $ hg ci -m "added foo"
+  created new head
+  $ hg glog
+  @  29:f3ba8b99bb6f added foo
+      () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m "merge commit"
+
+  $ hg prune -r f3ba8b99bb6f
+  1 changesets pruned
+  1 new orphan changesets
+
+  $ hg glog
+  @    30:32beb84b9dbc merge commit
+  |\    () draft
+  | x  29:f3ba8b99bb6f added foo
+  |     () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft
+
+The current behavior seems to be the correct behavior in the above case. This is
+also another case which can arise flow merge workflow where people start a
+branch from null changeset and merge it and then prune it or get rid of it.
+
+Also if you look at the above graph, the side part:
+
+\
+ x
+
+becomes redundant as the changeset is pruned without successor and we should
+just remove that chain.
+
+  $ hg evolve -r .
+  move:[30] merge commit
+  atop:[-1] 
+  working directory is now at d2a03dd8c951
+
+  $ hg glog
+  @  31:d2a03dd8c951 merge commit
+  |   () draft
+  o  0:8fa14d15e168 added hgignore
+      () draft