##// END OF EJS Templates
bundle2: gracefully handle hook abort...
Pierre-Yves David -
r21187:bcfd44ab stable
parent child Browse files
Show More
@@ -738,16 +738,20 b' def unbundle(repo, cg, heads, source, ur'
738 check_heads(repo, heads, 'uploading changes')
738 check_heads(repo, heads, 'uploading changes')
739 # push can proceed
739 # push can proceed
740 if util.safehasattr(cg, 'params'):
740 if util.safehasattr(cg, 'params'):
741 tr = repo.transaction('unbundle')
741 try:
742 tr.hookargs['bundle2-exp'] = '1'
742 tr = repo.transaction('unbundle')
743 r = bundle2.processbundle(repo, cg, lambda: tr).reply
743 tr.hookargs['bundle2-exp'] = '1'
744 cl = repo.unfiltered().changelog
744 r = bundle2.processbundle(repo, cg, lambda: tr).reply
745 p = cl.writepending() and repo.root or ""
745 cl = repo.unfiltered().changelog
746 repo.hook('b2x-pretransactionclose', throw=True, source=source,
746 p = cl.writepending() and repo.root or ""
747 url=url, pending=p, **tr.hookargs)
747 repo.hook('b2x-pretransactionclose', throw=True, source=source,
748 tr.close()
748 url=url, pending=p, **tr.hookargs)
749 repo.hook('b2x-transactionclose', source=source, url=url,
749 tr.close()
750 **tr.hookargs)
750 repo.hook('b2x-transactionclose', source=source, url=url,
751 **tr.hookargs)
752 except Exception, exc:
753 exc.duringunbundle2 = True
754 raise
751 else:
755 else:
752 r = changegroup.addchangegroup(repo, cg, source, url)
756 r = changegroup.addchangegroup(repo, cg, source, url)
753 finally:
757 finally:
@@ -1043,3 +1043,40 b' Doing the actual push: race'
1043 abort: push failed:
1043 abort: push failed:
1044 'repository changed while pushing - please try again'
1044 'repository changed while pushing - please try again'
1045 [255]
1045 [255]
1046
1047 Doing the actual push: hook abort
1048
1049 $ cat << EOF >> $HGRCPATH
1050 > [failpush]
1051 > reason =
1052 > [hooks]
1053 > b2x-pretransactionclose.failpush = false
1054 > EOF
1055
1056 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1057 $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
1058 $ cat other.pid >> $DAEMON_PIDS
1059
1060 $ hg -R main push other -r e7ec4e813ba6
1061 pushing to other
1062 searching for changes
1063 transaction abort!
1064 rollback completed
1065 abort: b2x-pretransactionclose.failpush hook exited with status 1
1066 [255]
1067
1068 $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
1069 pushing to ssh://user@dummy/other
1070 searching for changes
1071 abort: b2x-pretransactionclose.failpush hook exited with status 1
1072 remote: transaction abort!
1073 remote: rollback completed
1074 [255]
1075
1076 $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
1077 pushing to http://localhost:$HGPORT2/
1078 searching for changes
1079 abort: b2x-pretransactionclose.failpush hook exited with status 1
1080 [255]
1081
1082
General Comments 0
You need to be logged in to leave comments. Login now