stack: return from behindcount() early draft
authorAnton Shestakov <av6@dwimlabs.net>
Thu, 12 Sep 2019 15:22:50 +0700
changeset 5222 13ca3810a105
parent 5221 34494a5ba69b
child 5223 cc9b6e64027c
stack: return from behindcount() early Reduces indentation.
hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py	Thu Sep 12 14:44:19 2019 +0700
+++ b/hgext3rd/topic/stack.py	Thu Sep 12 15:22:50 2019 +0700
@@ -200,21 +200,21 @@
 
     @util.propertycache
     def behindcount(self):
+        if not self._revs:
+            return 0
         deps, rdeps = self._dependencies
-        if self._revs:
-            minroot = [min(r for r in self._revs if not deps[r])]
-            try:
-                dest = destutil.destmerge(self._repo, action=b'rebase',
-                                          sourceset=minroot,
-                                          onheadcheck=False)
-                return len(self._repo.revs(b"only(%d, %ld)", dest, minroot))
-            except error.NoMergeDestAbort:
-                return 0
-            except error.ManyMergeDestAbort as exc:
-                # XXX we should make it easier for upstream to provide the information
-                self.behinderror = pycompat.bytestr(exc).split(b'-', 1)[0].rstrip()
-                return -1
-        return 0
+        minroot = [min(r for r in self._revs if not deps[r])]
+        try:
+            dest = destutil.destmerge(self._repo, action=b'rebase',
+                                      sourceset=minroot,
+                                      onheadcheck=False)
+            return len(self._repo.revs(b"only(%d, %ld)", dest, minroot))
+        except error.NoMergeDestAbort:
+            return 0
+        except error.ManyMergeDestAbort as exc:
+            # XXX we should make it easier for upstream to provide the information
+            self.behinderror = pycompat.bytestr(exc).split(b'-', 1)[0].rstrip()
+            return -1
 
     @util.propertycache
     def branches(self):