tests/test-evolve-noupdate.t
author Anton Shestakov <av6@dwimlabs.net>
Fri, 07 Jun 2019 18:14:48 +0800
branchstable
changeset 4687 313565dd75e3
parent 4577 bcd52ce0916d
child 4675 79bc0f1a832e
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.

Testing the `--no-update` flag to `hg evolve` command
=====================================================

There is an `--update` flag to `hg evolve` command which defaults to False. The
`--update` flag updates to the head of the evolved revisions. If you don't want
to change your working directory or update your working directory to its
successor after hg evolve, `hg evolve --no-update` is the thing for you.

This patch tests that flag.

Setup
-----

  $ cat >> $HGRCPATH <<EOF
  > [alias]
  > glog = log -GT "{rev}:{node|short} {desc}\n ({bookmarks}) {phase}"
  > [extensions]
  > EOF
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH

  $ hg init stoprepo
  $ cd stoprepo
  $ echo ".*\.orig" > .hgignore
  $ hg add .hgignore
  $ hg ci -m "added hgignore"
  $ for ch in a b c d; do echo foo > $ch; hg add $ch; hg ci -qm "added "$ch; done;

  $ hg glog
  @  4:c41c793e0ef1 added d
  |   () draft
  o  3:ca1b80f7960a added c
  |   () draft
  o  2:b1661037fa25 added b
  |   () draft
  o  1:c7586e2a9264 added a
  |   () draft
  o  0:8fa14d15e168 added hgignore
      () draft

Making sure we stay where we were if current wdir parent was not obsoleted
--------------------------------------------------------------------------

  $ hg up .^^
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ echo bar > b
  $ hg amend
  2 new orphan changesets
  $ hg glog
  @  5:7ed0642d644b added b
  |   () draft
  | *  4:c41c793e0ef1 added d
  | |   () draft
  | *  3:ca1b80f7960a added c
  | |   () draft
  | x  2:b1661037fa25 added b
  |/    () draft
  o  1:c7586e2a9264 added a
  |   () draft
  o  0:8fa14d15e168 added hgignore
      () draft

There is no 'working directory is now at' message because we didn't update
  $ hg evolve --all --no-update
  move:[3] added c
  atop:[5] added b
  move:[4] added d

  $ hg glog
  o  7:b6b20b8eefdc added d
  |   () draft
  o  6:7c46f743e62f added c
  |   () draft
  @  5:7ed0642d644b added b
  |   () draft
  o  1:c7586e2a9264 added a
  |   () draft
  o  0:8fa14d15e168 added hgignore
      () draft

Updating to successor when working directory parent is obsoleted by evolution
-----------------------------------------------------------------------------

  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added a
  $ echo bar > a
  $ hg amend
  3 new orphan changesets
  $ hg up 7ed0642d644b
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ hg glog
  o  8:3d41537b44ca added a
  |   () draft
  | *  7:b6b20b8eefdc added d
  | |   () draft
  | *  6:7c46f743e62f added c
  | |   () draft
  | @  5:7ed0642d644b added b
  | |   () draft
  | x  1:c7586e2a9264 added a
  |/    () draft
  o  0:8fa14d15e168 added hgignore
      () draft

  $ hg evolve --all --any --no-update
  move:[5] added b
  atop:[8] added a
  move:[6] added c
  move:[7] added d
  working directory is now at 12c720cb3782

  $ hg glog
  o  11:a74d9f22ba3f added d
  |   () draft
  o  10:958f5155e8cd added c
  |   () draft
  @  9:12c720cb3782 added b
  |   () draft
  o  8:3d41537b44ca added a
  |   () draft
  o  0:8fa14d15e168 added hgignore
      () draft