incoming: recurse into subrepositories with --subrepos/-S flag
authorMartin Geisler <mg@lazybytes.net>
Mon, 13 Sep 2010 13:09:31 +0200
changeset 12274 c02e1ed3d407
parent 12273 e392d00ab5b0
child 12275 88a42bf5fa46
incoming: recurse into subrepositories with --subrepos/-S flag As with push and outgoing, the optional source path is ignored for the subrepositories. Fixing this is Issue1852.
mercurial/commands.py
mercurial/subrepo.py
tests/test-debugcomplete.t
tests/test-subrepo-recursion.t
--- a/mercurial/commands.py	Mon Sep 13 13:09:30 2010 +0200
+++ b/mercurial/commands.py	Mon Sep 13 13:09:31 2010 +0200
@@ -2357,7 +2357,16 @@
 
     Returns 0 if there are incoming changes, 1 otherwise.
     """
-    return hg.incoming(ui, repo, source, opts)
+    if opts.get('bundle') and opts.get('subrepos'):
+        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):
     """create a new repository in the given directory
@@ -4191,7 +4200,7 @@
            _('a remote changeset intended to be added'), _('REV')),
           ('b', 'branch', [],
            _('a specific branch you would like to pull'), _('BRANCH')),
-         ] + logopts + remoteopts,
+         ] + logopts + remoteopts + subrepoopts,
          _('[-p] [-n] [-M] [-f] [-r REV]...'
            ' [--bundle FILENAME] [SOURCE]')),
     "^init":
--- a/mercurial/subrepo.py	Mon Sep 13 13:09:30 2010 +0200
+++ b/mercurial/subrepo.py	Mon Sep 13 13:09:31 2010 +0200
@@ -267,6 +267,9 @@
     def outgoing(self, ui, dest, opts):
         return 1
 
+    def incoming(self, ui, source, opts):
+        return 1
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
@@ -400,6 +403,9 @@
     def outgoing(self, ui, dest, opts):
         return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts)
 
+    def incoming(self, ui, source, opts):
+        return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts)
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         self._path = path
--- a/tests/test-debugcomplete.t	Mon Sep 13 13:09:30 2010 +0200
+++ b/tests/test-debugcomplete.t	Mon Sep 13 13:09:31 2010 +0200
@@ -227,7 +227,7 @@
   help: 
   identify: rev, num, id, branch, tags
   import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
-  incoming: force, newest-first, bundle, rev, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd
+  incoming: force, newest-first, bundle, rev, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, subrepos
   locate: rev, print0, fullpath, include, exclude
   manifest: rev
   outgoing: force, rev, newest-first, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, subrepos
--- a/tests/test-subrepo-recursion.t	Mon Sep 13 13:09:30 2010 +0200
+++ b/tests/test-subrepo-recursion.t	Mon Sep 13 13:09:31 2010 +0200
@@ -287,3 +287,33 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     3-4-2
   
+
+Switch to original repo and setup default path:
+
+  $ cd ../repo
+  $ echo '[paths]' >> .hg/hgrc
+  $ echo 'default = ../repo2' >> .hg/hgrc
+
+Test incoming:
+
+  $ hg incoming -S
+  comparing with .*/test-subrepo-recursion.t/repo2
+  searching for changes
+  changeset:   3:2655b8ecc4ee
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     3-4-2
+  
+  comparing with .*/test-subrepo-recursion.t/repo2/foo
+  searching for changes
+  changeset:   4:e96193d6cb36
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     3-4-2
+  
+  $ hg incoming -S --bundle incoming.hg
+  abort: cannot combine --bundle and --subrepos
+
+  $ exit 0