tests/test-evolve-progress.t
author Anton Shestakov <av6@dwimlabs.net>
Fri, 07 Jun 2019 18:14:48 +0800
branchstable
changeset 4687 313565dd75e3
parent 4661 df41605bd26c
child 4668 194adaeb84e8
child 4670 d0d8c0e2f3fc
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.

Test Evolve progress output
===========================

  $ . "$TESTDIR/testlib/common.sh"
  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > evolve=
  > EOF

  $ hg init progress
  $ cd progress
  $ echo a > a
  $ hg ci -Aqm first
  $ echo a2 > a
  $ hg ci -m second
  $ echo b > b
  $ hg ci -Aqm third
  $ echo b2 > b
  $ hg ci -m fourth

Test progress with --all
  $ hg co -q 'desc("first")'
  $ hg amend -m 'first v2'
  3 new orphan changesets
  $ hg evolve --config progress.debug=yes --debug
  evolve: 1/3 changesets (33.33%)
  move:[1] second
  atop:[4] first v2
  hg rebase -r 4f60c78b6d58 -d fd0a2402f834
  evolve: 1/3 changesets (33.33%)
    searching for copies back to rev 0
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: a87874c6ec31, local: fd0a2402f834+, remote: 4f60c78b6d58
   a: remote is newer -> g
  getting a
  updating: a 1/1 files (100.00%)
  committing files:
  a
  committing manifest
  committing changelog
  evolve: 2/3 changesets (66.67%)
  move:[2] third
  hg rebase -r 769574b07a96 -d 5f16d91ecde0
  evolve: 2/3 changesets (66.67%)
    searching for copies back to rev 0
    unmatched files in other (from base):
     b
    unmatched files in other (from topological common ancestor):
     b
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: 4f60c78b6d58, local: 5f16d91ecde0+, remote: 769574b07a96
   b: remote created -> g
  getting b
  updating: b 1/1 files (100.00%)
  committing files:
  b
  committing manifest
  committing changelog
  evolve: 3/3 changesets (100.00%)
  move:[3] fourth
  hg rebase -r 22782fddc0ab -d 53c0008d98a0
  evolve: 3/3 changesets (100.00%)
    searching for copies back to rev 0
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: 769574b07a96, local: 53c0008d98a0+, remote: 22782fddc0ab
   b: remote is newer -> g
  getting b
  updating: b 1/1 files (100.00%)
  committing files:
  b
  committing manifest
  committing changelog
  updating the branch cache
  obscache is out of date
  invalid branchheads cache (served): tip differs
  resolving manifests
   branchmerge: False, force: False, partial: False
   ancestor: 385376d04062, local: 385376d04062+, remote: fd0a2402f834
   b: other deleted -> r
  removing b
  updating: b 1/2 files (50.00%)
   a: remote is newer -> g
  getting a
  updating: a 2/2 files (100.00%)

Test progress with -r
  $ hg co -q 'desc("first")'
  $ hg amend -m 'first v3'
  3 new orphan changesets
  $ hg evolve -r 'desc("second")' --config progress.debug=yes --debug
  evolve: 1/1 changesets (100.00%)
  move:[5] second
  atop:[8] first v3
  hg rebase -r 5f16d91ecde0 -d 152c368c622b
  evolve: 1/1 changesets (100.00%)
    searching for copies back to rev 4
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: fd0a2402f834, local: 152c368c622b+, remote: 5f16d91ecde0
   a: remote is newer -> g
  getting a
  updating: a 1/1 files (100.00%)
  committing files:
  a
  committing manifest
  committing changelog
  updating the branch cache
  obscache is out of date
  resolving manifests
   branchmerge: False, force: False, partial: False
   ancestor: df5d742141b0, local: df5d742141b0+, remote: 152c368c622b
   a: remote is newer -> g
  getting a
  updating: a 1/1 files (100.00%)

Test progress with --continue
  $ hg co -q 'desc("first")'
  $ echo conflict > a
  $ hg amend -m 'first v4'
  1 new orphan changesets
  $ hg evolve --all --config progress.debug=yes --debug
  evolve: 1/3 changesets (33.33%)
  move:[9] second
  atop:[10] first v4
  hg rebase -r df5d742141b0 -d f8d7d38c0a88
  evolve: 1/3 changesets (33.33%)
    searching for copies back to rev 8
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: 152c368c622b, local: f8d7d38c0a88+, remote: df5d742141b0
   preserving a for resolve of a
   a: versions differ -> m (premerge)
  updating: a 1/1 files (100.00%)
  picked tool ':merge' for a (binary False symlink False changedelete False)
  merging a
  my a@f8d7d38c0a88+ other a@df5d742141b0 ancestor a@152c368c622b
   a: versions differ -> m (merge)
  updating: a 2/2 files (100.00%)
  picked tool ':merge' for a (binary False symlink False changedelete False)
  my a@f8d7d38c0a88+ other a@df5d742141b0 ancestor a@152c368c622b
  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
  fix conflicts and see `hg help evolve.interrupted`
  [1]
  $ echo resolved > a
  $ hg resolve -m a
  (no more unresolved files)
  continue: hg evolve --continue
  $ hg evolve --continue --config progress.debug=yes --debug
  evolving 9:df5d742141b0 "second"
  committing files:
  a
  committing manifest
  committing changelog
  updating the branch cache
  obscache is out of date
  move:[6] third
  atop:[11] second
  hg rebase -r 53c0008d98a0 -d 60a86497fbfe
  evolve: 2/3 changesets (66.67%)
    searching for copies back to rev 4
    unmatched files in other (from base):
     b
    unmatched files in other (from topological common ancestor):
     b
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: 5f16d91ecde0, local: 60a86497fbfe+, remote: 53c0008d98a0
   b: remote created -> g
  getting b
  updating: b 1/1 files (100.00%)
  committing files:
  b
  committing manifest
  committing changelog
  move:[7] fourth
  hg rebase -r 385376d04062 -d b2de95304e32
  evolve: 3/3 changesets (100.00%)
    searching for copies back to rev 4
  resolving manifests
   branchmerge: True, force: True, partial: False
   ancestor: 53c0008d98a0, local: b2de95304e32+, remote: 385376d04062
   b: remote is newer -> g
  getting b
  updating: b 1/1 files (100.00%)
  committing files:
  b
  committing manifest
  committing changelog
  updating the branch cache
  obscache is out of date
  invalid branchheads cache (served): tip differs
  resolving manifests
   branchmerge: False, force: False, partial: False
   ancestor: c6e6fdb1d046, local: c6e6fdb1d046+, remote: f8d7d38c0a88
   b: other deleted -> r
  removing b
  updating: b 1/2 files (50.00%)
   a: remote is newer -> g
  getting a
  updating: a 2/2 files (100.00%)
  working directory is now at f8d7d38c0a88

  $ cd ..