Mercurial > hg
comparison mercurial/wireproto.py @ 26857:e5a1df51bb25 stable
wireproto: move clonebundles command from extension (issue4931)
The SSH peer class accesses wireproto.commands[cmd] as part of encoding
command arguments. Previously, the wire protocol command was defined in
the clonebundles extension. If the client didn't have this extension
enabled (which it likely doesn't since it is meant as a server-side
extension), then clients attempting to clone via ssh:// would get a
crash due to a KeyError accessing wireproto.commands['clonebundles']
when cloning from a server that is advertising clone bundles.
Moving the definition of the wire protocol command to wireproto.py makes
this problem go away.
A side effect of this code move is servers will always respond to
"clonebundles" wire protocol command requests. This should be fine: the
server will return an empty response unless a clone bundles manifest
file is present and clients shouldn't call the command unless the server
is advertising the capability, which only happens if the clonebundles
extension is enabled and the manifest file exists.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 03 Nov 2015 12:31:33 -0800 |
parents | 704818fb170d |
children | d7e5e4da8394 |
comparison
equal
deleted
inserted
replaced
26856:baa77652be68 | 26857:e5a1df51bb25 |
---|---|
547 r = [] | 547 r = [] |
548 for b in repo.branches(nodes): | 548 for b in repo.branches(nodes): |
549 r.append(encodelist(b) + "\n") | 549 r.append(encodelist(b) + "\n") |
550 return "".join(r) | 550 return "".join(r) |
551 | 551 |
552 @wireprotocommand('clonebundles', '') | |
553 def clonebundles(repo, proto): | |
554 """Server command for returning info for available bundles to seed clones. | |
555 | |
556 Clients will parse this response and determine what bundle to fetch. | |
557 | |
558 Extensions may wrap this command to filter or dynamically emit data | |
559 depending on the request. e.g. you could advertise URLs for the closest | |
560 data center given the client's IP address. | |
561 """ | |
562 return repo.opener.tryread('clonebundles.manifest') | |
552 | 563 |
553 wireprotocaps = ['lookup', 'changegroupsubset', 'branchmap', 'pushkey', | 564 wireprotocaps = ['lookup', 'changegroupsubset', 'branchmap', 'pushkey', |
554 'known', 'getbundle', 'unbundlehash', 'batch'] | 565 'known', 'getbundle', 'unbundlehash', 'batch'] |
555 | 566 |
556 def _capabilities(repo, proto): | 567 def _capabilities(repo, proto): |