Comments
Patch
@@ -758,5 +758,11 @@ def handlereplycaps(op, inpart):
@parthandler('b2x:error:unknownpart')
def handlereplycaps(op, inpart):
"""Used to transmit unknown part error over the wire"""
manargs = dict(inpart.mandatoryparams)
raise UnknownPartError(manargs['parttype'])
+
+@parthandler('b2x:error:pushraced')
+def handlereplycaps(op, inpart):
+ """Used to transmit push race error over the wire"""
+ manargs = dict(inpart.mandatoryparams)
+ raise error.ResponseError(_('push failed:'), manargs['message'])
@@ -825,6 +825,13 @@ def unbundle(repo, proto, heads):
return streamres(bundler.getchunks())
else:
sys.stderr.write("abort: %s\n" % inst)
return pushres(0)
except error.PushRaced, exc:
- return pusherr(str(exc))
+ if getattr(exc, 'duringunbundle2', False):
+ bundler = bundle2.bundle20(repo.ui)
+ part = bundle2.bundlepart('B2X:ERROR:PUSHRACED',
+ [('message', str(exc))])
+ bundler.addpart(part)
+ return streamres(bundler.getchunks())
+ else:
+ return pusherr(str(exc))
@@ -925,10 +925,13 @@ Setting up
> part = None
> if reason == 'abort':
> part = bundle2.bundlepart('test:abort')
> if reason == 'unknown':
> part = bundle2.bundlepart('TEST:UNKNOWN')
+ > if reason == 'race':
+ > # 20 Bytes of crap
+ > part = bundle2.bundlepart('b2x:check:heads', data='01234567890123456789')
> if part is not None:
> bundler.addpart(part)
> return extradata
>
> @bundle2.parthandler("test:abort")
@@ -1010,5 +1013,33 @@ Doing the actual push: unknown mandatory
$ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
pushing to http://localhost:$HGPORT2/
searching for changes
abort: missing support for "'test:unknown'"
[255]
+
+Doing the actual push: race
+
+ $ cat << EOF >> $HGRCPATH
+ > [failpush]
+ > reason = race
+ > EOF
+
+ $ hg -R main push other -r e7ec4e813ba6
+ pushing to other
+ searching for changes
+ abort: push failed:
+ 'repository changed while pushing - please try again'
+ [255]
+
+ $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
+ pushing to ssh://user@dummy/other
+ searching for changes
+ abort: push failed:
+ 'repository changed while pushing - please try again'
+ [255]
+
+ $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
+ pushing to http://localhost:$HGPORT2/
+ searching for changes
+ abort: push failed:
+ 'repository changed while pushing - please try again'
+ [255]