tests/test-abort-checkin.t
author Patrick Mezard <patrick@mezard.eu>
Sat, 12 May 2012 00:24:07 +0200
changeset 16659 58edd786e96f
parent 12327 92e30e135581
child 16913 f2719b387380
permissions -rw-r--r--
phase: make if abort on nullid for the good reason The good reason being you cannot call retractboundary() on nullid, not revset.set() cannot resolve '-1'.

  $ cat > abortcommit.py <<EOF
  > from mercurial import util
  > def hook(**args):
  >     raise util.Abort("no commits allowed")
  > def reposetup(ui, repo):
  >     repo.ui.setconfig("hooks", "pretxncommit.nocommits", hook)
  > EOF
  $ abspath=`pwd`/abortcommit.py

  $ echo "[extensions]" >> $HGRCPATH
  $ echo "mq=" >> $HGRCPATH
  $ echo "abortcommit = $abspath" >> $HGRCPATH

  $ hg init foo
  $ cd foo
  $ echo foo > foo
  $ hg add foo

mq may keep a reference to the repository so __del__ will not be
called and .hg/journal.dirstate will not be deleted:

  $ hg ci -m foo
  error: pretxncommit.nocommits hook failed: no commits allowed
  transaction abort!
  rollback completed
  abort: no commits allowed
  [255]
  $ hg ci -m foo
  error: pretxncommit.nocommits hook failed: no commits allowed
  transaction abort!
  rollback completed
  abort: no commits allowed
  [255]