tests/test-issue-5720.t
author Pulkit Goyal <7895pulkit@gmail.com>
Wed, 13 Jun 2018 17:15:10 +0530
changeset 3846 f9dad99a90d5
parent 3843 f0096db2a7b1
child 3852 629558d09898
permissions -rw-r--r--
evolve: create a new commit instead of amending one of the divergents This patch changes the behavior of evolve command while resolving content-divergence to create a new commit instead of amending one of the divergent ones. In past, I have made this change, backed out this change and now today again I am doing this change, so let's dive in some history. Using cmdrewrite.amend() was never a good option as that requires hack to delete the evolvestate and also gives us less control over things. We can't make the commit on top of different parents as that of content-divergent ones. Due to all these, I first made this change to create a new commit instead of amending one. But, after few days, there was flakiness observed in the tests and turned out that we need to do some dirstate dance as repo.dirstate.setparents() does not always fix the dirstate. That flakiness was a blocker for progress at that time and we decided to switch to amend back so that we can have things working with some hacks and we can later fix the implementation part. Now, yesterday while tackling resolving content-divergence of a stack which is as follows: C1 C2 | | B1 B2 | | A1 A2 \/ base where, A1-A2, B1-B2, C1-C2 are content-divergent with each other. Now we can resolve A1-A2 very well because they have the same parent and let's say that resolution leads to A3. Now, we want to resolve B1-B2 and make the new resolution commit on top of A3 so that we can end up something like: C3 | B3 | A3 | base however, amending one of the divergent changesets, it's not possible to create a commit on a different parent like A3 here without some relocation. We should prevent relocation as that may leads to some conflicts and should change the parent before committing. So, looking ahead, we can't move with using amend as still using that we will need some relocation hacks making code ugly and prone to bad behaviors, bugs. Let's change back to creating a new commit so that we can move forward in a good way. About repo.dirstate.setparents() not setting the dirstate, I have researched yesterday night about how we can do that and found out that we can use cmdrewrite._uncommitdirstate() here. Expect upcoming patches to improve the documentation of that function. There are lot of test changes because of change in hash but there is no behavior change. The only behavior change is in test-evolve-abort-contentdiv.t which is nice because creating a new commit helps us in stripping that while aborting. We have a lot of testing of content-divergence and no behavior change gives enough confidence for making this change. I reviewed the patch carefully to make sure there is no behavior change and I suggest reviewer to do the same.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     1
This test file test the #5720 issue
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     2
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     3
Check that `hg evolve --continue` doesn't change changeset phase from secret
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     4
to draft after a merge conflict.
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     5
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     6
https://bz.mercurial-scm.org/show_bug.cgi?id=5720
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     7
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     8
Global setup
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
     9
============
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    10
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    11
  $ . $TESTDIR/testlib/common.sh
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    12
  $ cat >> $HGRCPATH <<EOF
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    13
  > [ui]
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    14
  > interactive = true
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    15
  > [phases]
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    16
  > publish=False
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    17
  > [extensions]
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    18
  > evolve =
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    19
  > EOF
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    20
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    21
Test
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    22
====
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    23
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    24
  $ hg init $TESTTMP/issue-5720
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    25
  $ cd $TESTTMP/issue-5720
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    26
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    27
Create two drafts commits and one secret
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    28
  $ echo a > a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    29
  $ hg commit -Am a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    30
  adding a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    31
  $ echo b > a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    32
  $ hg commit -m b
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    33
  $ echo c > a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    34
  $ hg commit --secret -m c
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    35
  $ hg log -G -T "{rev}: {phase}"
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    36
  @  2: secret
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    37
  |
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    38
  o  1: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    39
  |
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    40
  o  0: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    41
  
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    42
Amend the second draft with new content
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    43
  $ hg prev
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    44
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    45
  [1] b
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    46
  $ echo b2 > a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    47
  $ hg amend
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    48
  1 new orphan changesets
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    49
  $ hg log -G -T "{rev}: {phase}"
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    50
  @  3: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    51
  |
3417
d3a17c67f85c branching: merge stable back into default
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 3411
diff changeset
    52
  | *  2: secret
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    53
  | |
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    54
  | x  1: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    55
  |/
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    56
  o  0: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    57
  
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    58
Evolve which triggers a conflict
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    59
  $ hg evolve
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    60
  move:[2] c
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    61
  atop:[3] b
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    62
  merging a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    63
  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
3843
f0096db2a7b1 evolve: improve error messages when conflicts occur
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3821
diff changeset
    64
  abort: fix conflicts and see `hg help evolve.interrupted`
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    65
  [255]
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    66
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    67
Fix the conflict
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    68
  $ echo c2 > a
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    69
  $ hg resolve -m
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    70
  (no more unresolved files)
3472
05bd493d496d evolve: add evolve info to cmdutil.afterresolvedstates
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3417
diff changeset
    71
  continue: hg evolve --continue
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    72
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    73
Continue the evolution
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    74
  $ hg evolve --continue
3386
2a51107e60cf evolve: add a utility fn to check validity of opts passed to `hg evolve`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3379
diff changeset
    75
  evolving 2:13833940840c "c"
3494
14cd04ff968e evolve: show the updated working directory after `hg evolve --continue`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3472
diff changeset
    76
  working directory is now at 3d2080c198e5
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    77
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    78
Tip should stay in secret phase
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    79
  $ hg log -G -T "{rev}: {phase}"
3388
be41e4740a25 evolve: use phases.new-commit config to retain phase information (issue5720)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3386
diff changeset
    80
  @  4: secret
3379
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    81
  |
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    82
  o  3: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    83
  |
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    84
  o  0: draft
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    85
  
ef475fce0dd2 test: add a test to reproduce issue 5720
Boris Feld <boris.feld@octobus.net>
parents:
diff changeset
    86
  $ hg log -r . -T '{phase}\n'
3388
be41e4740a25 evolve: use phases.new-commit config to retain phase information (issue5720)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 3386
diff changeset
    87
  secret