tests/test-journal-exists.t
author Mitchell Plamann <mplamann@janestreet.com>
Mon, 05 Oct 2020 13:23:16 -0400
changeset 45736 2c6b054e22d0
parent 44389 7a4e1d245f19
child 45921 95c4cca641f6
permissions -rw-r--r--
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression When an hg push is interrupted with C-c, the remote [hg serve] command receives SIGPIPE. If a pretxnchangegroup hook fails, the remote hg then tries to rollback the transaction. It begins by printing "transaction abort!\n". This returns EPIPE, but ui.py ignores that error. In python3 (but not python2), this "transaction abort!\n" message stays in a buffer, so future flushes of stderr will try to print the message again, and so those flushes will also hit EPIPE. This test demonstrates such a case where this EPIPE causes the transaction rollback to fail, leaving behind an abandoned transaction. Differential Revision: https://phab.mercurial-scm.org/D9151

  $ hg init
  $ echo a > a
  $ hg ci -Am0
  adding a

  $ hg -q clone . foo

  $ touch .hg/store/journal

  $ echo foo > a
  $ hg ci -Am0
  abort: abandoned transaction found!
  (run 'hg recover' to clean up transaction)
  [255]

  $ hg recover
  rolling back interrupted transaction
  (verify step skipped, run `hg verify` to check your repository content)

recover, explicit verify

  $ touch .hg/store/journal
  $ hg ci -Am0
  abort: abandoned transaction found!
  (run 'hg recover' to clean up transaction)
  [255]
  $ hg recover --verify
  rolling back interrupted transaction
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
  checked 1 changesets with 1 changes to 1 files

recover, no verify

  $ touch .hg/store/journal
  $ hg ci -Am0
  abort: abandoned transaction found!
  (run 'hg recover' to clean up transaction)
  [255]
  $ hg recover --no-verify
  rolling back interrupted transaction
  (verify step skipped, run `hg verify` to check your repository content)


Check that zero-size journals are correctly aborted:

#if unix-permissions no-root
  $ hg bundle -qa repo.hg
  $ chmod -w foo/.hg/store/00changelog.i

  $ hg -R foo unbundle repo.hg
  adding changesets
  abort: Permission denied: '$TESTTMP/foo/.hg/store/.00changelog.i-*' (glob)
  [255]

  $ if test -f foo/.hg/store/journal; then echo 'journal exists :-('; fi
#endif