1199 if not dryrun: |
1199 if not dryrun: |
1200 rejected = wctx.add(names, prefix) |
1200 rejected = wctx.add(names, prefix) |
1201 bad.extend(f for f in rejected if f in match.files()) |
1201 bad.extend(f for f in rejected if f in match.files()) |
1202 return bad |
1202 return bad |
1203 |
1203 |
|
1204 def forget(ui, repo, match, prefix, explicitonly): |
|
1205 join = lambda f: os.path.join(prefix, f) |
|
1206 bad = [] |
|
1207 oldbad = match.bad |
|
1208 match.bad = lambda x, y: bad.append(x) or oldbad(x, y) |
|
1209 wctx = repo[None] |
|
1210 forgot = [] |
|
1211 s = repo.status(match=match, clean=True) |
|
1212 forget = sorted(s[0] + s[1] + s[3] + s[6]) |
|
1213 if explicitonly: |
|
1214 forget = [f for f in forget if match.exact(f)] |
|
1215 |
|
1216 for subpath in wctx.substate: |
|
1217 sub = wctx.sub(subpath) |
|
1218 try: |
|
1219 submatch = matchmod.narrowmatcher(subpath, match) |
|
1220 subbad, subforgot = sub.forget(ui, submatch, prefix) |
|
1221 bad.extend([subpath + '/' + f for f in subbad]) |
|
1222 forgot.extend([subpath + '/' + f for f in subforgot]) |
|
1223 except error.LookupError: |
|
1224 ui.status(_("skipping missing subrepository: %s\n") |
|
1225 % join(subpath)) |
|
1226 |
|
1227 for f in match.files(): |
|
1228 if match.exact(f) or not explicitonly: |
|
1229 if f not in repo.dirstate and not os.path.isdir(match.rel(join(f))): |
|
1230 if f not in forgot: |
|
1231 if os.path.exists(match.rel(join(f))): |
|
1232 ui.warn(_('not removing %s: ' |
|
1233 'file is already untracked\n') |
|
1234 % match.rel(join(f))) |
|
1235 bad.append(f) |
|
1236 |
|
1237 for f in forget: |
|
1238 if ui.verbose or not match.exact(f): |
|
1239 ui.status(_('removing %s\n') % match.rel(join(f))) |
|
1240 |
|
1241 rejected = wctx.forget(forget, prefix) |
|
1242 bad.extend(f for f in rejected if f in match.files()) |
|
1243 forgot.extend(forget) |
|
1244 return bad, forgot |
|
1245 |
1204 def duplicatecopies(repo, rev, p1): |
1246 def duplicatecopies(repo, rev, p1): |
1205 "Reproduce copies found in the source revision in the dirstate for grafts" |
1247 "Reproduce copies found in the source revision in the dirstate for grafts" |
1206 for dst, src in copies.pathcopies(repo[p1], repo[rev]).iteritems(): |
1248 for dst, src in copies.pathcopies(repo[p1], repo[rev]).iteritems(): |
1207 repo.dirstate.copy(src, dst) |
1249 repo.dirstate.copy(src, dst) |
1208 |
1250 |