incoming/outgoing: Fix recursion on sub repositories
authorErik Zielke <ez@aragost.com>
Fri, 24 Sep 2010 12:00:55 +0200
changeset 12400 40852b4b910c
parent 12399 4fee1fd3de9a
child 12401 4cdaf1adafc8
incoming/outgoing: Fix recursion on sub repositories Incoming and outgoing are fixed so they go through the whole three of repositories instead of only visiting first level of sub repositories.
mercurial/commands.py
mercurial/hg.py
tests/test-subrepo-recursion.t
--- a/mercurial/commands.py	Fri Sep 24 10:13:49 2010 +0200
+++ b/mercurial/commands.py	Fri Sep 24 12:00:55 2010 +0200
@@ -2363,11 +2363,6 @@
         raise util.Abort(_('cannot combine --bundle and --subrepos'))
 
     ret = hg.incoming(ui, repo, source, opts)
-    if opts.get('subrepos'):
-        ctx = repo[None]
-        for subpath in sorted(ctx.substate):
-            sub = ctx.sub(subpath)
-            ret = min(ret, sub.incoming(ui, source, opts))
     return ret
 
 def init(ui, dest=".", **opts):
@@ -2630,11 +2625,6 @@
     Returns 0 if there are outgoing changes, 1 otherwise.
     """
     ret = hg.outgoing(ui, repo, dest, opts)
-    if opts.get('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 parents(ui, repo, file_=None, **opts):
--- a/mercurial/hg.py	Fri Sep 24 10:13:49 2010 +0200
+++ b/mercurial/hg.py	Fri Sep 24 12:00:55 2010 +0200
@@ -409,6 +409,15 @@
     return stats[3] > 0
 
 def incoming(ui, repo, source, opts):
+    def recurse():
+        ret = 1
+        if opts.get('subrepos'):
+            ctx = repo[None]
+            for subpath in sorted(ctx.substate):
+                sub = ctx.sub(subpath)
+                ret = min(ret, sub.incoming(ui, source, opts))
+        return ret
+
     limit = cmdutil.loglimit(opts)
     source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
     other = repository(remoteui(repo, opts), source)
@@ -426,7 +435,7 @@
         except:
             pass
         ui.status(_("no changes found\n"))
-        return 1
+        return recurse()
 
     cleanup = None
     try:
@@ -469,8 +478,19 @@
             other.close()
         if cleanup:
             os.unlink(cleanup)
+    recurse()
+    return 0 # exit code is zero since we found incoming changes
 
 def outgoing(ui, repo, dest, opts):
+    def recurse():
+        ret = 1
+        if opts.get('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 = cmdutil.loglimit(opts)
     dest = ui.expandpath(dest or 'default-push', dest or 'default')
     dest, branches = parseurl(dest, opts.get('branch'))
@@ -483,7 +503,8 @@
     o = discovery.findoutgoing(repo, other, force=opts.get('force'))
     if not o:
         ui.status(_("no changes found\n"))
-        return 1
+        return recurse()
+
     o = repo.changelog.nodesbetween(o, revs)[0]
     if opts.get('newest_first'):
         o.reverse()
@@ -498,6 +519,8 @@
         count += 1
         displayer.show(repo[n])
     displayer.close()
+    recurse()
+    return 0 # exit code is zero since we found outgoing changes
 
 def revert(repo, node, choose):
     """revert changes to revision in node without updating dirstate"""
--- a/tests/test-subrepo-recursion.t	Fri Sep 24 10:13:49 2010 +0200
+++ b/tests/test-subrepo-recursion.t	Fri Sep 24 12:00:55 2010 +0200
@@ -273,6 +273,9 @@
   comparing with */test-subrepo-recursion.t/repo/foo (glob)
   searching for changes
   no changes found
+  comparing with */test-subrepo-recursion.t/repo/foo/bar (glob)
+  searching for changes
+  no changes found
   [1]
 
 Make nested change:
@@ -306,6 +309,9 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     3-4-2
   
+  comparing with */test-subrepo-recursion.t/repo/foo/bar (glob)
+  searching for changes
+  no changes found
 
 Switch to original repo and setup default path:
 
@@ -332,6 +338,10 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     3-4-2
   
+  comparing with */test-subrepo-recursion.t/repo2/foo/bar (glob)
+  searching for changes
+  no changes found
+
   $ hg incoming -S --bundle incoming.hg
   abort: cannot combine --bundle and --subrepos
   [255]