comparison mercurial/wireproto.py @ 32260:d0d9a4fca59b

clone: add a server-side option to disable full getbundles (pull-based clones) For large enough repositories, pull-based clones take too long, and an attempt to use them indicates some sort of configuration or other issue or maybe an outdated Mercurial. Add a config option to disable them.
author Siddharth Agarwal <sid0@fb.com>
date Thu, 11 May 2017 10:50:05 -0700
parents 53865692a354
children bd872f64a8ba
comparison
equal deleted inserted replaced
32259:076f1ff43f0f 32260:d0d9a4fca59b
14 14
15 from .i18n import _ 15 from .i18n import _
16 from .node import ( 16 from .node import (
17 bin, 17 bin,
18 hex, 18 hex,
19 nullid,
19 ) 20 )
20 21
21 from . import ( 22 from . import (
22 bundle2, 23 bundle2,
23 changegroup as changegroupmod, 24 changegroup as changegroupmod,
839 return ooberror(bundle2required) 840 return ooberror(bundle2required)
840 raise error.Abort(bundle2requiredmain, 841 raise error.Abort(bundle2requiredmain,
841 hint=bundle2requiredhint) 842 hint=bundle2requiredhint)
842 843
843 try: 844 try:
845 if repo.ui.configbool('server', 'disablefullbundle', False):
846 # Check to see if this is a full clone.
847 clheads = set(repo.changelog.heads())
848 heads = set(opts.get('heads', set()))
849 common = set(opts.get('common', set()))
850 common.discard(nullid)
851 if not common and clheads == heads:
852 raise error.Abort(
853 _('server has pull-based clones disabled'),
854 hint=_('remove --pull if specified or upgrade Mercurial'))
855
844 chunks = exchange.getbundlechunks(repo, 'serve', **opts) 856 chunks = exchange.getbundlechunks(repo, 'serve', **opts)
845 except error.Abort as exc: 857 except error.Abort as exc:
846 # cleanly forward Abort error to the client 858 # cleanly forward Abort error to the client
847 if not exchange.bundle2requested(opts.get('bundlecaps')): 859 if not exchange.bundle2requested(opts.get('bundlecaps')):
848 if proto.name == 'http': 860 if proto.name == 'http':