pushrebase: throw if prechangegroup fails

Summary:
The prechangegroup hook didn't have throw=True set, so if the hooks
failed we ignored it. This seems to have been the case for a long time, but we
only recently hit it.

Reviewed By: kulshrax

Differential Revision: D15038494

fbshipit-source-id: 4fa9ed4924c02732e3e4070e747a80fbe63564c9
This commit is contained in:
Durham Goode 2019-04-22 17:07:21 -07:00 committed by Facebook Github Bot
parent 6745729cbd
commit bf9fd13411
2 changed files with 42 additions and 2 deletions

View File

@ -1199,7 +1199,7 @@ def bundle2rebase(op, part):
# Enter the critical section! This triggers a hgsql sync.
tr = op.gettransaction()
hookargs = dict(tr.hookargs)
op.repo.hook("prechangegroup", **hookargs)
op.repo.hook("prechangegroup", throw=True, **hookargs)
# ontoctx could move. Fetch the new one.
# Print rebase source and destination.
@ -1237,7 +1237,7 @@ def bundle2rebase(op, part):
setrecordingparams(op.repo, ontoparam, onto)
revs, oldonto = _getrevs(op, bundle, onto, renamesrccache)
op.repo.hook("prechangegroup", **hookargs)
op.repo.hook("prechangegroup", throw=True, **hookargs)
log(
getpushmessage(

View File

@ -653,6 +653,46 @@ Test that hooks are fired with the correct variables
$ cd ../
Test that failing prechangegroup hooks block the push
$ hg init hookserver2
$ cd hookserver2
$ cat >> .hg/hgrc <<EOF
> [hooks]
> prechangegroup = exit 1
> [extensions]
> pushrebase=
> EOF
$ touch file && hg ci -Aqm initial
$ hg bookmark master
$ cd ../
$ hg clone hookserver2 hookclient2
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd hookclient2
$ cat >> .hg/hgrc <<EOF
> [extensions]
> pushrebase=
> EOF
$ hg update master
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(activating bookmark master)
$ echo >> file && hg ci -Aqm first
$ echo >> file && hg ci -Aqm second
$ echo >> file && hg ci -Aqm last
$ hg push --to master -B master
pushing to $TESTTMP/hookserver2
searching for changes
pushing 3 changesets:
4fcee35c508c first
11be4ca7f3f4 second
a5e72ac0df88 last
abort: prechangegroup hook exited with status 1
[255]
$ cd ..
Test date rewriting
$ hg init rewritedate