Mercurial > hg
view tests/test-revlog-v2.t @ 45825:8f07f5a9c3de
worker: raise exception instead of calling sys.exit() with child's code
When a worker process returns an error code, we would call
`sys.exit()` with that exit code on the main process. The `SystemExit`
exception would then get caught in `scmutil.callcatch()`, which would
return that error code. The comment there says "Commands shouldn't
sys.exit directly", which I agree with. This patch changes it so we
raise a specific exception when a worker fails so we can catch
instead. I think that means that `SystemExit` is now always an
internal error.
(I had earlier thought that this call to `sys.exit()` was from within
the child process until Matt Harbison made me look again, so thanks
for that!)
Differential Revision: https://phab.mercurial-scm.org/D9287
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sat, 07 Nov 2020 21:50:28 -0800 |
parents | 15d35f2ba474 |
children | 95c4cca641f6 |
line wrap: on
line source
#require reporevlogstore A repo with unknown revlogv2 requirement string cannot be opened $ hg init invalidreq $ cd invalidreq $ echo exp-revlogv2.unknown >> .hg/requires $ hg log abort: repository requires features unknown to this Mercurial: exp-revlogv2.unknown! (see https://mercurial-scm.org/wiki/MissingRequirement for more information) [255] $ cd .. Can create and open repo with revlog v2 requirement $ cat >> $HGRCPATH << EOF > [experimental] > revlogv2 = enable-unstable-format-and-corrupt-my-data > EOF $ hg init empty-repo $ cd empty-repo $ cat .hg/requires dotencode exp-revlogv2.1 fncache sparserevlog store $ hg log Unknown flags to revlog are rejected >>> with open('.hg/store/00changelog.i', 'wb') as fh: ... fh.write(b'\xff\x00\xde\xad') and None $ hg log abort: unknown flags (0xff00) in version 57005 revlog 00changelog.i! [255] $ cd .. Writing a simple revlog v2 works $ hg init simple $ cd simple $ touch foo $ hg -q commit -A -m initial $ hg log changeset: 0:96ee1d7354c4 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: initial Header written as expected $ f --hexdump --bytes 4 .hg/store/00changelog.i .hg/store/00changelog.i: 0000: 00 01 de ad |....| $ f --hexdump --bytes 4 .hg/store/data/foo.i .hg/store/data/foo.i: 0000: 00 01 de ad |....|