Mercurial > hg
changeset 35075:3eeb0a3eeaed
bundlerepo: use early return
I like avoiding patterns that lead to the pyramid of doom.
Differential Revision: https://phab.mercurial-scm.org/D1382
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 11 Nov 2017 18:55:04 -0800 |
parents | 62e10bf001a9 |
children | 90609be10891 |
files | mercurial/bundlerepo.py |
diffstat | 1 files changed, 12 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Sun Nov 05 08:23:12 2017 +0100 +++ b/mercurial/bundlerepo.py Sat Nov 11 18:55:04 2017 -0800 @@ -319,19 +319,19 @@ [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