tests/test-evolve-issue5958.t
author Martin von Zweigbergk <martinvonz@google.com>
Thu, 30 Apr 2020 10:05:14 -0700
changeset 5341 13376ca93fa3
parent 5323 417503ef667d
child 5345 a73cdef2e33f
permissions -rw-r--r--
evolve: always create commit when resolving divergence When resolving content-divergence, the final commit we create may end up empty (which means that Mercurial won't even create it). We've had code for handling that in evolve ever since 41bf6c27a122 (evolve: stabilize now handle conflicting changeset, 2012-08-23). However, that resolved the issue by marking on the divergent commits as successor. As Pierre-Yves has pointed out (in other code reviews), we should instead be creating a new successor. So that's what this patch does. It does that by setting `ui.allowemptycommit` while creating the final commit. However, that is not enough, because we may end up creating the same nodeid as already existed (we'd then end up trying to mark the "new" commit a successor of itself). To solve that, we add some salt to the commit extras. That salt affects lots of tests.

Content divergence and trying to relocate a node on top of itself (issue5958)
https://bz.mercurial-scm.org/show_bug.cgi?id=5958

  $ . $TESTDIR/testlib/common.sh

  $ cat << EOF >> $HGRCPATH
  > [extensions]
  > rebase =
  > evolve =
  > EOF

  $ hg init issue5958
  $ cd issue5958

  $ echo hi > r0
  $ hg ci -qAm 'add r0'
  $ echo hi > foo.txt
  $ hg ci -qAm 'add foo.txt'
  $ hg metaedit -r . -d '0 2'
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

(Make changes in unrelated files so that we don't have any merge conflicts
during the rebase, but the two touched revisions aren't identical)

  $ echo hi > bar.txt
  $ hg add -q bar.txt
  $ hg amend -q
  $ hg metaedit -r 1 -d '0 1' --hidden
  2 new content-divergent changesets
  $ hg log -r tip
  changeset:   4:c17bf400a278
  tag:         tip
  parent:      0:a24ed8ad918c
  user:        test
  date:        Wed Dec 31 23:59:59 1969 -0000
  instability: content-divergent
  summary:     add foo.txt
  
  $ echo hi > baz.txt
  $ hg add -q baz.txt
  $ hg amend -q
  $ hg rebase -qr tip -d 4
  $ hg log -G
  @  changeset:   6:08bc7ba82799
  |  tag:         tip
  |  parent:      4:c17bf400a278
  |  user:        test
  |  date:        Wed Dec 31 23:59:58 1969 -0000
  |  instability: content-divergent
  |  summary:     add foo.txt
  |
  *  changeset:   4:c17bf400a278
  |  parent:      0:a24ed8ad918c
  |  user:        test
  |  date:        Wed Dec 31 23:59:59 1969 -0000
  |  instability: content-divergent
  |  summary:     add foo.txt
  |
  o  changeset:   0:a24ed8ad918c
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     add r0
  
  $ hg debugobsolete
  cc71ffbc7c002d7b45fb694f9c060bf2e6920672 0065551bd38fe59ea4a069a4db378550c60122d3 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '32', 'operation': 'metaedit', 'user': 'test'}
  0065551bd38fe59ea4a069a4db378550c60122d3 a25dd7af6cf6731ff93708abb2b1b889eae848a0 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
  cc71ffbc7c002d7b45fb694f9c060bf2e6920672 c17bf400a2782394b1ca5fbbe59e30494f16dfdc 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '32', 'operation': 'metaedit', 'user': 'test'}
  a25dd7af6cf6731ff93708abb2b1b889eae848a0 1d1fc409af989f5c0843507e202d69a1ad16c5ef 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
  1d1fc409af989f5c0843507e202d69a1ad16c5ef 08bc7ba82799f1e419190b0dac1b0e1c4b1355f9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'rebase', 'user': 'test'}
  $ hg obslog -a -r .
  @  08bc7ba82799 (6) add foo.txt
  |
  | *  c17bf400a278 (4) add foo.txt
  | |
  x |  1d1fc409af98 (5) add foo.txt
  | |    rewritten(parent, content) as 08bc7ba82799 using rebase by test (Thu Jan 01 00:00:00 1970 +0000)
  | |
  x |  a25dd7af6cf6 (3) add foo.txt
  | |    amended(content) as 1d1fc409af98 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
  | |
  x |  0065551bd38f (2) add foo.txt
  |/     amended(content) as a25dd7af6cf6 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  x  cc71ffbc7c00 (1) add foo.txt
       date-changed(date) as 0065551bd38f using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
       date-changed(date) as c17bf400a278 using metaedit by test (Thu Jan 01 00:00:00 1970 +0000)
  
  $ hg evolve --content-divergent
  merge:[6] add foo.txt
  with: [4] add foo.txt
  base: [1] add foo.txt
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  1 new orphan changesets
  working directory is now at 8b11b92203c7