# HG changeset patch # User Gregory Szorc # Date 2017-11-12 02:55:04 # Node ID 3eeb0a3eeaedc7d65501a3253e82ee134f40b8f0 # Parent 62e10bf001a9014d181966c6bca9958d105ef359 bundlerepo: use early return I like avoiding patterns that lead to the pyramid of doom. Differential Revision: https://phab.mercurial-scm.org/D1382 diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -319,19 +319,19 @@ class bundlerepository(localrepo.localre [ctx.node() for ctx in self[self.firstnewrev:]]) def _handlebundle2part(self, bundle, part): - if part.type == 'changegroup': - cgstream = part - version = part.params.get('version', '01') - legalcgvers = changegroup.supportedincomingversions(self) - if version not in legalcgvers: - msg = _('Unsupported changegroup version: %s') - raise error.Abort(msg % version) - if bundle.compressed(): - cgstream = self._writetempbundle(part.read, - ".cg%sun" % version) + if part.type != 'changegroup': + return - self._cgunpacker = changegroup.getunbundler(version, cgstream, - 'UN') + cgstream = part + version = part.params.get('version', '01') + legalcgvers = changegroup.supportedincomingversions(self) + if version not in legalcgvers: + msg = _('Unsupported changegroup version: %s') + raise error.Abort(msg % version) + if bundle.compressed(): + cgstream = self._writetempbundle(part.read, '.cg%sun' % version) + + self._cgunpacker = changegroup.getunbundler(version, cgstream, 'UN') def _writetempbundle(self, readfn, suffix, header=''): """Write a temporary file to disk