tests/test-push-checkheads-pruned-B6.t
author Anton Shestakov <av6@dwimlabs.net>
Fri, 07 Jun 2019 18:14:48 +0800
branchstable
changeset 4687 313565dd75e3
parent 2754 21f06d932231
child 2798 2280461343e5
child 4840 62b60fc1983d
permissions -rw-r--r--
pick: remove transaction on the whole command (issue6037) At its core, pick is a pretty straightforward and well-behaving command, it uses functions already in core hg, it checks that wdir is clean and that changeset to pick is not public, it checks if there happen to be merge conflicts and can be --continue'd later, etc. It is very similar to graft in core (it also uses mergemod.graft function), but it obsoletes the original changeset. However, graft does not experience this incorrect behavior from issue 6037. What happens in the test case for this issue when we pick a revision that touches both "a" and "b": mergemod.graft() takes the original changeset and tries to apply it to the wdir, which results in "b" being marked as newly added and ready to be committed, "a" updated with the new content and being marked as modified, but "a" also has conflicts. Pick correctly notices this and saves its state before asking for user intervention. So far so good. However, when the command raises InterventionRequired to print a user-facing message and exit while being wrapped in repo.transaction() context manager, the latter partially undoes what mergemod.graft() did: it unmarks "b" as added. And when user continues pick, "b" is therefore not tracked and is not included in the resulting commit. The transaction is not useful here, because it doesn't touch wdir (it's still dirty), it doesn't remove pickstate (and other commands will refuse to work until pick --abort or --continue), it just makes "b" untracked. The solution is to use repo.transaction() only to wrap code that writes data to hg store in the final stages of the command after all checks have passed and is not expected to fail on trivial cases like merge conflicts. For example, committing the picked changeset. But since pick uses repo.commit() for that, and because that function already uses a transaction, wrapping it in another transaction doesn't make sense.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     1
====================================
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     2
Testing head checking code: Case B-6
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     3
====================================
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     4
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
     5
Mercurial checks for the introduction of new heads on push. Evolution comes
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
     6
into play to detect if existing branches on the server are being replaced by
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
     7
some of the new one we push.
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
     8
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
     9
This case is part of a series of tests checking this behavior.
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    10
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    11
Category B: simple case involving pruned changesets
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    12
TestCase 6: single changesets, pruned then superseeded (on a new changeset)
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    13
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    14
.. old-state:
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    15
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    16
.. * 1 changeset branch
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    17
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    18
.. new-state:
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    19
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    20
.. * old branch is rewritten onto another one,
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    21
.. * the new version is then pruned.
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    22
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    23
.. expected-result:
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    24
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    25
.. * push allowed
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    26
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    27
.. graph-summary:
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    28
..
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    29
..   A ø⇠⊗ A'
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    30
..     | |
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    31
..     | ◔ B
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    32
..     |/
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    33
..     ●
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    34
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    35
  $ . $TESTDIR/testlib/push-checkheads-util.sh
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    36
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    37
Test setup
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    38
----------
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    39
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    40
  $ mkdir B6
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    41
  $ cd B6
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    42
  $ setuprepos
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    43
  creating basic server and client repo
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    44
  updating to branch default
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    45
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    46
  $ cd client
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    47
  $ hg up 0
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    48
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    49
  $ mkcommit B0
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    50
  created new head
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    51
  $ mkcommit A1
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    52
  $ hg up 'desc(B0)'
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    53
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    54
  $ hg debugobsolete `getid "desc(A0)"` `getid "desc(A1)"`
2754
21f06d932231 test: update test output to match b11e8c67fb0f
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2710
diff changeset
    55
  obsoleted 1 changesets
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    56
  $ hg debugobsolete --record-parents `getid "desc(A1)"`
2754
21f06d932231 test: update test output to match b11e8c67fb0f
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2710
diff changeset
    57
  obsoleted 1 changesets
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    58
  $ hg log -G --hidden
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    59
  x  ba93660aff8d (draft): A1
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    60
  |
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    61
  @  74ff5441d343 (draft): B0
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    62
  |
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    63
  | x  8aaa48160adc (draft): A0
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    64
  |/
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    65
  o  1e4be0697311 (public): root
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    66
  
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    67
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    68
Actual testing
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    69
--------------
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    70
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    71
  $ hg push
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    72
  pushing to $TESTTMP/B6/server (glob)
2254
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    73
  searching for changes
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    74
  adding changesets
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    75
  adding manifests
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    76
  adding file changes
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    77
  added 1 changesets with 1 changes to 1 files (+1 heads)
446ed4c21bf6 check-heads: add tests about old heads indirectly pruned
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
    78
  2 new obsolescence markers
2710
e22de367fc74 compat: adapt to change in 53b3a1968aa6-core
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 2277
diff changeset
    79
  obsoleted 1 changesets
2277
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    80
61d885899466 checkheads: update tests to match the one in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 2254
diff changeset
    81
  $ cd ../..