The use of early return makes the control flow of this function much
easier to reason about IMO.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
The use of early return makes the control flow of this function much
easier to reason about IMO.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/exchange.py (50 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Jul 2 2018, 9:39 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
@getbundle2partsgenerator('stream2') | @getbundle2partsgenerator('stream2') | ||||
def _getbundlestream2(bundler, repo, *args, **kwargs): | def _getbundlestream2(bundler, repo, *args, **kwargs): | ||||
return bundle2.addpartbundlestream2(bundler, repo, **kwargs) | return bundle2.addpartbundlestream2(bundler, repo, **kwargs) | ||||
@getbundle2partsgenerator('changegroup') | @getbundle2partsgenerator('changegroup') | ||||
def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, heads=None, common=None, **kwargs): | b2caps=None, heads=None, common=None, **kwargs): | ||||
"""add a changegroup part to the requested bundle""" | """add a changegroup part to the requested bundle""" | ||||
cgstream = None | if not kwargs.get(r'cg', True): | ||||
if kwargs.get(r'cg', True): | return | ||||
# build changegroup bundle here. | |||||
version = '01' | version = '01' | ||||
cgversions = b2caps.get('changegroup') | cgversions = b2caps.get('changegroup') | ||||
if cgversions: # 3.1 and 3.2 ship with an empty value | if cgversions: # 3.1 and 3.2 ship with an empty value | ||||
cgversions = [v for v in cgversions | cgversions = [v for v in cgversions | ||||
if v in changegroup.supportedoutgoingversions(repo)] | if v in changegroup.supportedoutgoingversions(repo)] | ||||
if not cgversions: | if not cgversions: | ||||
raise ValueError(_('no common changegroup version')) | raise ValueError(_('no common changegroup version')) | ||||
version = max(cgversions) | version = max(cgversions) | ||||
outgoing = _computeoutgoing(repo, heads, common) | outgoing = _computeoutgoing(repo, heads, common) | ||||
if outgoing.missing: | if not outgoing.missing: | ||||
return | |||||
cgstream = changegroup.makestream(repo, outgoing, version, source, | cgstream = changegroup.makestream(repo, outgoing, version, source, | ||||
bundlecaps=bundlecaps) | bundlecaps=bundlecaps) | ||||
if cgstream: | |||||
part = bundler.newpart('changegroup', data=cgstream) | part = bundler.newpart('changegroup', data=cgstream) | ||||
if cgversions: | if cgversions: | ||||
part.addparam('version', version) | part.addparam('version', version) | ||||
part.addparam('nbchanges', '%d' % len(outgoing.missing), | part.addparam('nbchanges', '%d' % len(outgoing.missing), | ||||
mandatory=False) | mandatory=False) | ||||
if 'treemanifest' in repo.requirements: | if 'treemanifest' in repo.requirements: | ||||
part.addparam('treemanifest', '1') | part.addparam('treemanifest', '1') | ||||
@getbundle2partsgenerator('bookmarks') | @getbundle2partsgenerator('bookmarks') | ||||
def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, | def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None, | ||||
b2caps=None, **kwargs): | b2caps=None, **kwargs): | ||||
"""add a bookmark part to the requested bundle""" | """add a bookmark part to the requested bundle""" | ||||
if not kwargs.get(r'bookmarks', False): | if not kwargs.get(r'bookmarks', False): | ||||
return | return | ||||
if 'bookmarks' not in b2caps: | if 'bookmarks' not in b2caps: |