bundlerepo: use early return
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 11 Nov 2017 18:55:04 -0800
changeset 35075 3eeb0a3eeaed
parent 35074 62e10bf001a9
child 35076 90609be10891
bundlerepo: use early return I like avoiding patterns that lead to the pyramid of doom. Differential Revision: https://phab.mercurial-scm.org/D1382
mercurial/bundlerepo.py
--- 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