[PATCH] hg Incoming/Outgoing: Recursion on sub repositories

Erik Zielke ez at aragost.com
Fri Sep 24 06:54:15 CDT 2010


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1285322455 -7200
# Node ID f4620cbb6d5a56227c8d54ee23254b04dc5bf9ff
# Parent  f540780feaa426182a4bfd8a598899edd412b2e6
hg Incoming/Outgoing: Recursion on sub repositories

hg incoming and outgoing fixed so they go through the whole three of
repositories, when sub repositories are shown, instead of only
visiting first level of sub repositories.

diff -r f540780feaa4 -r f4620cbb6d5a mercurial/commands.py
--- a/mercurial/commands.py	Thu Sep 23 16:58:37 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):
diff -r f540780feaa4 -r f4620cbb6d5a mercurial/hg.py
--- a/mercurial/hg.py	Thu Sep 23 16:58:37 2010 +0200
+++ b/mercurial/hg.py	Fri Sep 24 12:00:55 2010 +0200
@@ -414,6 +414,8 @@
     other = repository(remoteui(repo, opts), source)
     ui.status(_('comparing with %s\n') % url.hidepassword(source))
     revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
+    ret = None
+
     if revs:
         revs = [other.lookup(rev) for rev in revs]
 
@@ -426,49 +428,60 @@
         except:
             pass
         ui.status(_("no changes found\n"))
-        return 1
+        ret = 1
+    else:
 
-    cleanup = None
-    try:
-        fname = opts["bundle"]
-        if fname or not other.local():
-            # create a bundle (uncompressed if other repo is not local)
+        cleanup = None
+        try:
+            fname = opts["bundle"]
+            if fname or not other.local():
+                # create a bundle (uncompressed if other repo is not local)
 
-            if revs is None and other.capable('changegroupsubset'):
-                revs = rheads
+                if revs is None and other.capable('changegroupsubset'):
+                    revs = rheads
 
-            if revs is None:
-                cg = other.changegroup(incoming, "incoming")
-            else:
-                cg = other.changegroupsubset(incoming, revs, 'incoming')
-            bundletype = other.local() and "HG10BZ" or "HG10UN"
-            fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
-            # keep written bundle?
-            if opts["bundle"]:
-                cleanup = None
-            if not other.local():
-                # use the created uncompressed bundlerepo
-                other = bundlerepo.bundlerepository(ui, repo.root, fname)
+                if revs is None:
+                    cg = other.changegroup(incoming, "incoming")
+                else:
+                    cg = other.changegroupsubset(incoming, revs, 'incoming')
+                bundletype = other.local() and "HG10BZ" or "HG10UN"
+                fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
+                # keep written bundle?
+                if opts["bundle"]:
+                    cleanup = None
+                if not other.local():
+                    # use the created uncompressed bundlerepo
+                    other = bundlerepo.bundlerepository(ui, repo.root, fname)
 
-        o = other.changelog.nodesbetween(incoming, revs)[0]
-        if opts.get('newest_first'):
-            o.reverse()
-        displayer = cmdutil.show_changeset(ui, other, opts)
-        count = 0
-        for n in o:
-            if limit is not None and count >= limit:
-                break
-            parents = [p for p in other.changelog.parents(n) if p != nullid]
-            if opts.get('no_merges') and len(parents) == 2:
-                continue
-            count += 1
-            displayer.show(other[n])
-        displayer.close()
-    finally:
-        if hasattr(other, 'close'):
-            other.close()
-        if cleanup:
-            os.unlink(cleanup)
+
+
+            o = other.changelog.nodesbetween(incoming, revs)[0]
+            if opts.get('newest_first'):
+                o.reverse()
+            displayer = cmdutil.show_changeset(ui, other, opts)
+            count = 0
+            for n in o:
+                if limit is not None and count >= limit:
+                    break
+                parents = [p for p in other.changelog.parents(n) if p != nullid]
+                if opts.get('no_merges') and len(parents) == 2:
+                    continue
+                count += 1
+                displayer.show(other[n])
+            displayer.close()
+        finally:
+            if hasattr(other, 'close'):
+                other.close()
+            if cleanup:
+                os.unlink(cleanup)
+
+    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 outgoing(ui, repo, dest, opts):
     limit = cmdutil.loglimit(opts)
@@ -477,27 +490,35 @@
     revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
     if revs:
         revs = [repo.lookup(rev) for rev in revs]
-
+    ret = None
     other = repository(remoteui(repo, opts), dest)
     ui.status(_('comparing with %s\n') % url.hidepassword(dest))
     o = discovery.findoutgoing(repo, other, force=opts.get('force'))
     if not o:
         ui.status(_("no changes found\n"))
-        return 1
-    o = repo.changelog.nodesbetween(o, revs)[0]
-    if opts.get('newest_first'):
-        o.reverse()
-    displayer = cmdutil.show_changeset(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('no_merges') and len(parents) == 2:
-            continue
-        count += 1
-        displayer.show(repo[n])
-    displayer.close()
+        ret = 1
+    else:
+        o = repo.changelog.nodesbetween(o, revs)[0]
+        if opts.get('newest_first'):
+            o.reverse()
+        displayer = cmdutil.show_changeset(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('no_merges') and len(parents) == 2:
+                continue
+            count += 1
+            displayer.show(repo[n])
+        displayer.close()
+    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 revert(repo, node, choose):
     """revert changes to revision in node without updating dirstate"""
diff -r f540780feaa4 -r f4620cbb6d5a tests/test-subrepo-recursion.t
--- a/tests/test-subrepo-recursion.t	Thu Sep 23 16:58:37 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]


More information about the Mercurial-devel mailing list