Mercurial > evolve
view tests/test-evolve-obshistory-content-divergent.t @ 4687:313565dd75e3 stable
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 07 Jun 2019 18:14:48 +0800 |
parents | 11b775fddda8 |
children | f7afd3a158e3 f16274729530 |
line wrap: on
line source
This test file test the various messages when accessing obsolete revisions. Global setup ============ $ . $TESTDIR/testlib/obshistory_setup.sh Test output with content-divergence =================================== Test setup ---------- $ hg init $TESTTMP/local-divergence $ cd $TESTTMP/local-divergence $ mkcommit ROOT $ mkcommit A0 $ hg amend -m "A1" $ hg log --hidden -G @ changeset: 2:fdf9bde5129a | tag: tip | parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | summary: A1 | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 | obsolete: reworded using amend as 2:fdf9bde5129a | summary: A0 | o changeset: 0:ea207398892e user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: ROOT $ hg update --hidden 'desc(A0)' 0 files updated, 0 files merged, 0 files removed, 0 files unresolved updated to hidden changeset 471f378eab4c (hidden revision '471f378eab4c' was rewritten as: fdf9bde5129a) working directory parent is obsolete! (471f378eab4c) (use 'hg evolve' to update to its successor: fdf9bde5129a) $ hg amend -m "A2" 2 new content-divergent changesets $ hg log --hidden -G @ changeset: 3:65b757b745b9 | tag: tip | parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | instability: content-divergent | summary: A2 | | * changeset: 2:fdf9bde5129a |/ parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 | instability: content-divergent | summary: A1 | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 | obsolete: reworded using amend as 2:fdf9bde5129a | obsolete: reworded using amend as 3:65b757b745b9 | summary: A0 | o changeset: 0:ea207398892e user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: ROOT Actual test ----------- Check that debugobshistory on the divergent revision show both destinations $ hg obslog --hidden 471f378eab4c --patch x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 Check that with all option, every changeset is shown $ hg obslog --hidden --all 471f378eab4c --patch @ 65b757b745b9 (3) A2 | | * fdf9bde5129a (2) A1 |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 $ hg obslog --hidden 471f378eab4c --no-graph -Tjson | python -m json.tool [ { "markers": [ { "date": [ *, (glob) 0 (glob) ], "effect": [ "description" ], "operation": "amend", "succnodes": [ "65b757b745b9" ], "user": "test", "verb": "rewritten" }, { "date": [ *, (glob) 0 (glob) ], "effect": [ "description" ], "operation": "amend", "succnodes": [ "fdf9bde5129a" ], "user": "test", "verb": "rewritten" } ], "node": "471f378eab4c", "rev": 1, "shortdescription": "A0" } ] Check that debugobshistory on the first diverged revision show the revision and the diverent one $ hg obslog fdf9bde5129a --patch * fdf9bde5129a (2) A1 | x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 Check that all option show all of them $ hg obslog fdf9bde5129a -a --patch @ 65b757b745b9 (3) A2 | | * fdf9bde5129a (2) A1 |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 Check that debugobshistory on the second diverged revision show the revision and the diverent one $ hg obslog 65b757b745b9 --patch @ 65b757b745b9 (3) A2 | x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 Check that all option show all of them $ hg obslog 65b757b745b9 -a --patch @ 65b757b745b9 (3) A2 | | * fdf9bde5129a (2) A1 |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 Check that debugobshistory on the both diverged revision show a coherent graph $ hg obslog '65b757b745b9+fdf9bde5129a' --patch @ 65b757b745b9 (3) A2 | | * fdf9bde5129a (2) A1 |/ x 471f378eab4c (1) A0 rewritten(description) as 65b757b745b9 using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r 65b757b745b9 changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A2 rewritten(description) as fdf9bde5129a using amend by test (Thu Jan 01 00:00:00 1970 +0000) diff -r 471f378eab4c -r fdf9bde5129a changeset-description --- a/changeset-description +++ b/changeset-description @@ -1,1 +1,1 @@ -A0 +A1 $ hg obslog '65b757b745b9+fdf9bde5129a' --no-graph -Tjson | python -m json.tool [ { "markers": [], "node": "65b757b745b9", "rev": 3, "shortdescription": "A2" }, { "markers": [ { "date": [ *, (glob) 0 (glob) ], "effect": [ "description" ], "operation": "amend", "succnodes": [ "65b757b745b9" ], "user": "test", "verb": "rewritten" }, { "date": [ *, (glob) 0 (glob) ], "effect": [ "description" ], "operation": "amend", "succnodes": [ "fdf9bde5129a" ], "user": "test", "verb": "rewritten" } ], "node": "471f378eab4c", "rev": 1, "shortdescription": "A0" }, { "markers": [], "node": "fdf9bde5129a", "rev": 2, "shortdescription": "A1" } ] $ hg update 471f378eab4c abort: hidden revision '471f378eab4c' has diverged! (use --hidden to access hidden revisions) [255] $ hg update --hidden 'desc(A0)' 0 files updated, 0 files merged, 0 files removed, 0 files unresolved updated to hidden changeset 471f378eab4c (hidden revision '471f378eab4c' has diverged) working directory parent is obsolete! (471f378eab4c) (471f378eab4c has diverged, use 'hg evolve --list --content-divergent' to resolve the issue)