comparison mercurial/cmdutil.py @ 15410:9e99d2bbb1b1

add: support adding explicit files in subrepos Change the behavior of the add command such that explicit paths in subrepos are always added. This eliminates the previous behavior where if you called "hg add" for an explicit path in a subrepo without specifying the -S option, it would be silently ignored. If you specify patterns, or no arguments at all, the -S option will still be needed to activate recursion into subrepos.
author David M. Carr <david@carrclan.us>
date Wed, 02 Nov 2011 01:17:11 -0400
parents cd6f10dccf16
children 36d7a0c7505f
comparison
equal deleted inserted replaced
15409:83c2e6772408 15410:9e99d2bbb1b1
1163 cca(f) 1163 cca(f)
1164 names.append(f) 1164 names.append(f)
1165 if ui.verbose or not exact: 1165 if ui.verbose or not exact:
1166 ui.status(_('adding %s\n') % match.rel(join(f))) 1166 ui.status(_('adding %s\n') % match.rel(join(f)))
1167 1167
1168 if listsubrepos: 1168 for subpath in wctx.substate:
1169 for subpath in wctx.substate: 1169 sub = wctx.sub(subpath)
1170 sub = wctx.sub(subpath) 1170 try:
1171 try: 1171 submatch = matchmod.narrowmatcher(subpath, match)
1172 submatch = matchmod.narrowmatcher(subpath, match) 1172 if listsubrepos:
1173 bad.extend(sub.add(ui, submatch, dryrun, prefix)) 1173 bad.extend(sub.add(ui, submatch, dryrun, prefix))
1174 except error.LookupError: 1174 else:
1175 ui.status(_("skipping missing subrepository: %s\n") 1175 for f in sub.walk(submatch):
1176 % join(subpath)) 1176 if submatch.exact(f):
1177 bad.extend(sub.add(ui, submatch, dryrun, prefix))
1178 except error.LookupError:
1179 ui.status(_("skipping missing subrepository: %s\n")
1180 % join(subpath))
1177 1181
1178 if not dryrun: 1182 if not dryrun:
1179 rejected = wctx.add(names, prefix) 1183 rejected = wctx.add(names, prefix)
1180 bad.extend(f for f in rejected if f in match.files()) 1184 bad.extend(f for f in rejected if f in match.files())
1181 return bad 1185 return bad