diff mercurial/cmdutil.py @ 15911:c654eac03452

add: fix subrepo recursion for explicit path handling When support for handling explicit paths in subrepos was added to the add command (9e99d2bbb1b1), subrepo recursion wasn't taken into account. This change adds an explicitonly argument to cmdutil.add to allow controlling which levels of recursion should include only explicit paths versus all matched paths.
author David M. Carr <david@carrclan.us>
date Tue, 17 Jan 2012 19:10:58 -0500
parents 51fc43253a52
children 2bd54ffaa27e
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Jan 17 19:10:54 2012 -0500
+++ b/mercurial/cmdutil.py	Tue Jan 17 19:10:58 2012 -0500
@@ -1162,7 +1162,7 @@
                 yield change(rev)
     return iterate()
 
-def add(ui, repo, match, dryrun, listsubrepos, prefix):
+def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly):
     join = lambda f: os.path.join(prefix, f)
     bad = []
     oldbad = match.bad
@@ -1175,7 +1175,7 @@
         cca = scmutil.casecollisionauditor(ui, abort, wctx)
     for f in repo.walk(match):
         exact = match.exact(f)
-        if exact or f not in repo.dirstate:
+        if exact or not explicitonly and f not in repo.dirstate:
             if cca:
                 cca(f)
             names.append(f)
@@ -1187,11 +1187,11 @@
         try:
             submatch = matchmod.narrowmatcher(subpath, match)
             if listsubrepos:
-                bad.extend(sub.add(ui, submatch, dryrun, prefix))
+                bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
+                                   False))
             else:
-                for f in sub.walk(submatch):
-                    if submatch.exact(f):
-                        bad.extend(sub.add(ui, submatch, dryrun, prefix))
+                bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
+                                   True))
         except error.LookupError:
             ui.status(_("skipping missing subrepository: %s\n")
                            % join(subpath))