view tests/test-abort-checkin.t @ 27475:a2e2a8fa5fd1

revlog: avoid string slice when decompressing u* chunks Revlog chunks can be stored uncompressed. If the first byte of the raw data is \0, we store the data as is. Else we prefix it with 'u'. Before, we performed a string slice to strip out the 'u' prefix. With this patch, we use a buffer to avoid an extra memory copy and associated garbage collection overhead. I was unable to verify any performance impact of this patch. For both mozilla-central and the hg repos, the number of manifest revisions with 'u' prefixes is very small - under 1%. So this change likely isn't called enough to have an impact on manifest reading. However, the reasoning behind this change is solid, so it should be safe.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Dec 2015 16:00:27 -0800
parents 56b2bcea2529
children f798709eb4b9
line wrap: on
line source

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

  $ cat <<EOF >> $HGRCPATH
  > [extensions]
  > mq =
  > abortcommit = $abspath
  > EOF

  $ 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]

  $ cd ..