Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
15910:2b8d5c55ae67 | 15911:c654eac03452 |
---|---|
1160 prepare(ctx, fns) | 1160 prepare(ctx, fns) |
1161 for rev in nrevs: | 1161 for rev in nrevs: |
1162 yield change(rev) | 1162 yield change(rev) |
1163 return iterate() | 1163 return iterate() |
1164 | 1164 |
1165 def add(ui, repo, match, dryrun, listsubrepos, prefix): | 1165 def add(ui, repo, match, dryrun, listsubrepos, prefix, explicitonly): |
1166 join = lambda f: os.path.join(prefix, f) | 1166 join = lambda f: os.path.join(prefix, f) |
1167 bad = [] | 1167 bad = [] |
1168 oldbad = match.bad | 1168 oldbad = match.bad |
1169 match.bad = lambda x, y: bad.append(x) or oldbad(x, y) | 1169 match.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
1170 names = [] | 1170 names = [] |
1173 abort, warn = scmutil.checkportabilityalert(ui) | 1173 abort, warn = scmutil.checkportabilityalert(ui) |
1174 if abort or warn: | 1174 if abort or warn: |
1175 cca = scmutil.casecollisionauditor(ui, abort, wctx) | 1175 cca = scmutil.casecollisionauditor(ui, abort, wctx) |
1176 for f in repo.walk(match): | 1176 for f in repo.walk(match): |
1177 exact = match.exact(f) | 1177 exact = match.exact(f) |
1178 if exact or f not in repo.dirstate: | 1178 if exact or not explicitonly and f not in repo.dirstate: |
1179 if cca: | 1179 if cca: |
1180 cca(f) | 1180 cca(f) |
1181 names.append(f) | 1181 names.append(f) |
1182 if ui.verbose or not exact: | 1182 if ui.verbose or not exact: |
1183 ui.status(_('adding %s\n') % match.rel(join(f))) | 1183 ui.status(_('adding %s\n') % match.rel(join(f))) |
1185 for subpath in wctx.substate: | 1185 for subpath in wctx.substate: |
1186 sub = wctx.sub(subpath) | 1186 sub = wctx.sub(subpath) |
1187 try: | 1187 try: |
1188 submatch = matchmod.narrowmatcher(subpath, match) | 1188 submatch = matchmod.narrowmatcher(subpath, match) |
1189 if listsubrepos: | 1189 if listsubrepos: |
1190 bad.extend(sub.add(ui, submatch, dryrun, prefix)) | 1190 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix, |
1191 False)) | |
1191 else: | 1192 else: |
1192 for f in sub.walk(submatch): | 1193 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix, |
1193 if submatch.exact(f): | 1194 True)) |
1194 bad.extend(sub.add(ui, submatch, dryrun, prefix)) | |
1195 except error.LookupError: | 1195 except error.LookupError: |
1196 ui.status(_("skipping missing subrepository: %s\n") | 1196 ui.status(_("skipping missing subrepository: %s\n") |
1197 % join(subpath)) | 1197 % join(subpath)) |
1198 | 1198 |
1199 if not dryrun: | 1199 if not dryrun: |