Patchwork D10380: outgoing: remove some early return

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 2:52 p.m.
Message ID <differential-rev-PHID-DREV-5hnzl3cyvc7sb2crldvl-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48697/
State Superseded
Headers show

Comments

phabricator - April 13, 2021, 2:52 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Since 066b8d8f75b8 <https://phab.mercurial-scm.org/rHG066b8d8f75b873ecd1b8a1c4633c4a121c95d57d>, the push command accept multiple destination. However `hg
  outgoing` does not. On the way to fix this, we need to clean up the outgoing
  code. We start with removing some early return to make the code ready to house
  more changes.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10380

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1360,28 +1360,28 @@ 
 
     limit = logcmdutil.getlimit(opts)
     o, other = _outgoing(ui, repo, dest, opts)
+    ret = 1
     try:
-        if not o:
-            cmdutil.outgoinghooks(ui, repo, other, opts, o)
-            return recurse()
+        if o:
+            ret = 0
 
-        if opts.get(b'newest_first'):
-            o.reverse()
-        ui.pager(b'outgoing')
-        displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
-        count = 0
-        for n in o:
-            if limit is not None and count >= limit:
-                break
-            parents = [p for p in repo.changelog.parents(n) if p != nullid]
-            if opts.get(b'no_merges') and len(parents) == 2:
-                continue
-            count += 1
-            displayer.show(repo[n])
-        displayer.close()
+            if opts.get(b'newest_first'):
+                o.reverse()
+            ui.pager(b'outgoing')
+            displayer = logcmdutil.changesetdisplayer(ui, repo, opts)
+            count = 0
+            for n in o:
+                if limit is not None and count >= limit:
+                    break
+                parents = [p for p in repo.changelog.parents(n) if p != nullid]
+                if opts.get(b'no_merges') and len(parents) == 2:
+                    continue
+                count += 1
+                displayer.show(repo[n])
+            displayer.close()
         cmdutil.outgoinghooks(ui, repo, other, opts, o)
-        recurse()
-        return 0  # exit code is zero since we found outgoing changes
+        ret = min(ret, recurse())
+        return ret  # exit code is zero since we found outgoing changes
     finally:
         other.close()