Patchwork D10381: outgoing: make `recurse` a real function

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 2:52 p.m.
Message ID <differential-rev-PHID-DREV-pkux4gyuznohackiul22-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48698/
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
  If we want to use this in a loop, we need to be able to pass argument.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -1348,15 +1348,17 @@ 
         raise
 
 
+def _outgoing_recurse(ui, repo, dest, opts):
+    ret = 1
+    if opts.get(b'subrepos'):
+        ctx = repo[None]
+        for subpath in sorted(ctx.substate):
+            sub = ctx.sub(subpath)
+            ret = min(ret, sub.outgoing(ui, dest, opts))
+    return ret
+
+
 def outgoing(ui, repo, dest, opts):
-    def recurse():
-        ret = 1
-        if opts.get(b'subrepos'):
-            ctx = repo[None]
-            for subpath in sorted(ctx.substate):
-                sub = ctx.sub(subpath)
-                ret = min(ret, sub.outgoing(ui, dest, opts))
-        return ret
 
     limit = logcmdutil.getlimit(opts)
     o, other = _outgoing(ui, repo, dest, opts)
@@ -1380,7 +1382,7 @@ 
                 displayer.show(repo[n])
             displayer.close()
         cmdutil.outgoinghooks(ui, repo, other, opts, o)
-        ret = min(ret, recurse())
+        ret = min(ret, _outgoing_recurse(ui, repo, dest, opts))
         return ret  # exit code is zero since we found outgoing changes
     finally:
         other.close()