Changeset View
Changeset View
Standalone View
Standalone View
mercurial/bundle2.py
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | from . import ( | ||||
pycompat, | pycompat, | ||||
requirements, | requirements, | ||||
scmutil, | scmutil, | ||||
streamclone, | streamclone, | ||||
tags, | tags, | ||||
url, | url, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import stringutil | from .utils import ( | ||||
stringutil, | |||||
urlutil, | |||||
) | |||||
urlerr = util.urlerr | urlerr = util.urlerr | ||||
urlreq = util.urlreq | urlreq = util.urlreq | ||||
_pack = struct.pack | _pack = struct.pack | ||||
_unpack = struct.unpack | _unpack = struct.unpack | ||||
_fstreamparamsize = b'>i' | _fstreamparamsize = b'>i' | ||||
▲ Show 20 Lines • Show All 1879 Lines • ▼ Show 20 Line(s) | parameters. The parameters include: | ||||
the client matches what the server knows about the bundle. | the client matches what the server knows about the bundle. | ||||
When multiple digest types are given, all of them are checked. | When multiple digest types are given, all of them are checked. | ||||
""" | """ | ||||
try: | try: | ||||
raw_url = inpart.params[b'url'] | raw_url = inpart.params[b'url'] | ||||
except KeyError: | except KeyError: | ||||
raise error.Abort(_(b'remote-changegroup: missing "%s" param') % b'url') | raise error.Abort(_(b'remote-changegroup: missing "%s" param') % b'url') | ||||
parsed_url = util.url(raw_url) | parsed_url = urlutil.url(raw_url) | ||||
if parsed_url.scheme not in capabilities[b'remote-changegroup']: | if parsed_url.scheme not in capabilities[b'remote-changegroup']: | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'remote-changegroup does not support %s urls') | _(b'remote-changegroup does not support %s urls') | ||||
% parsed_url.scheme | % parsed_url.scheme | ||||
) | ) | ||||
try: | try: | ||||
size = int(inpart.params[b'size']) | size = int(inpart.params[b'size']) | ||||
Show All 20 Lines | def handleremotechangegroup(op, inpart): | ||||
real_part = util.digestchecker(url.open(op.ui, raw_url), size, digests) | real_part = util.digestchecker(url.open(op.ui, raw_url), size, digests) | ||||
tr = op.gettransaction() | tr = op.gettransaction() | ||||
from . import exchange | from . import exchange | ||||
cg = exchange.readbundle(op.repo.ui, real_part, raw_url) | cg = exchange.readbundle(op.repo.ui, real_part, raw_url) | ||||
if not isinstance(cg, changegroup.cg1unpacker): | if not isinstance(cg, changegroup.cg1unpacker): | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'%s: not a bundle version 1.0') % util.hidepassword(raw_url) | _(b'%s: not a bundle version 1.0') % urlutil.hidepassword(raw_url) | ||||
) | ) | ||||
ret = _processchangegroup(op, cg, tr, op.source, b'bundle2') | ret = _processchangegroup(op, cg, tr, op.source, b'bundle2') | ||||
if op.reply is not None: | if op.reply is not None: | ||||
# This is definitely not the final form of this | # This is definitely not the final form of this | ||||
# return. But one need to start somewhere. | # return. But one need to start somewhere. | ||||
part = op.reply.newpart(b'reply:changegroup') | part = op.reply.newpart(b'reply:changegroup') | ||||
part.addparam( | part.addparam( | ||||
b'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False | b'in-reply-to', pycompat.bytestr(inpart.id), mandatory=False | ||||
) | ) | ||||
part.addparam(b'return', b'%i' % ret, mandatory=False) | part.addparam(b'return', b'%i' % ret, mandatory=False) | ||||
try: | try: | ||||
real_part.validate() | real_part.validate() | ||||
except error.Abort as e: | except error.Abort as e: | ||||
raise error.Abort( | raise error.Abort( | ||||
_(b'bundle at %s is corrupted:\n%s') | _(b'bundle at %s is corrupted:\n%s') | ||||
% (util.hidepassword(raw_url), e.message) | % (urlutil.hidepassword(raw_url), e.message) | ||||
) | ) | ||||
assert not inpart.read() | assert not inpart.read() | ||||
@parthandler(b'reply:changegroup', (b'return', b'in-reply-to')) | @parthandler(b'reply:changegroup', (b'return', b'in-reply-to')) | ||||
def handlereplychangegroup(op, inpart): | def handlereplychangegroup(op, inpart): | ||||
ret = int(inpart.params[b'return']) | ret = int(inpart.params[b'return']) | ||||
replyto = int(inpart.params[b'in-reply-to']) | replyto = int(inpart.params[b'in-reply-to']) | ||||
▲ Show 20 Lines • Show All 455 Lines • Show Last 20 Lines |