outgoing: make `recurse` a real function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 11 Apr 2021 19:31:03 +0200
changeset 46913 b2740c547243
parent 46912 627bb1875fee
child 46914 50b79f8b802d
outgoing: make `recurse` a real function If we want to use this in a loop, we need to be able to pass argument. Differential Revision: https://phab.mercurial-scm.org/D10381
mercurial/hg.py
--- a/mercurial/hg.py	Sun Apr 11 19:20:14 2021 +0200
+++ b/mercurial/hg.py	Sun Apr 11 19:31:03 2021 +0200
@@ -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()