213 hg.clean(repo, node, show_stats=False) |
213 hg.clean(repo, node, show_stats=False) |
214 revert_opts = opts.copy() |
214 revert_opts = opts.copy() |
215 revert_opts['date'] = None |
215 revert_opts['date'] = None |
216 revert_opts['all'] = True |
216 revert_opts['all'] = True |
217 revert_opts['rev'] = hex(parent) |
217 revert_opts['rev'] = hex(parent) |
|
218 revert_opts['no_backup'] = None |
218 revert(ui, repo, **revert_opts) |
219 revert(ui, repo, **revert_opts) |
219 commit_opts = opts.copy() |
220 commit_opts = opts.copy() |
220 commit_opts['addremove'] = False |
221 commit_opts['addremove'] = False |
221 if not commit_opts['message'] and not commit_opts['logfile']: |
222 if not commit_opts['message'] and not commit_opts['logfile']: |
222 commit_opts['message'] = _("Backed out changeset %s") % (short(node)) |
223 commit_opts['message'] = _("Backed out changeset %s") % (short(node)) |
2325 # need all matching names in dirstate and manifest of target rev, |
2326 # need all matching names in dirstate and manifest of target rev, |
2326 # so have to walk both. do not print errors if files exist in one |
2327 # so have to walk both. do not print errors if files exist in one |
2327 # but not other. |
2328 # but not other. |
2328 |
2329 |
2329 names = {} |
2330 names = {} |
2330 target_only = {} |
|
2331 |
2331 |
2332 wlock = repo.wlock() |
2332 wlock = repo.wlock() |
2333 try: |
2333 try: |
2334 # walk dirstate. |
2334 # walk dirstate. |
2335 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
2335 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
2336 badmatch=mf.has_key): |
2336 badmatch=mf.has_key): |
2337 names[abs] = (rel, exact) |
2337 names[abs] = (rel, exact) |
2338 if src == 'b': |
|
2339 target_only[abs] = True |
|
2340 |
2338 |
2341 # walk target manifest. |
2339 # walk target manifest. |
2342 |
2340 |
2343 def badmatch(path): |
2341 def badmatch(path): |
2344 if path in names: |
2342 if path in names: |
2352 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, |
2350 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node, |
2353 badmatch=badmatch): |
2351 badmatch=badmatch): |
2354 if abs in names or src == 'b': |
2352 if abs in names or src == 'b': |
2355 continue |
2353 continue |
2356 names[abs] = (rel, exact) |
2354 names[abs] = (rel, exact) |
2357 target_only[abs] = True |
2355 |
2358 |
2356 changes = repo.status(match=names.has_key)[:4] |
2359 changes = repo.status(match=names.has_key)[:5] |
2357 modified, added, removed, deleted = map(dict.fromkeys, changes) |
2360 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) |
|
2361 |
2358 |
2362 # if f is a rename, also revert the source |
2359 # if f is a rename, also revert the source |
2363 cwd = repo.getcwd() |
2360 cwd = repo.getcwd() |
2364 for f in added: |
2361 for f in added: |
2365 src = repo.dirstate.copied(f) |
2362 src = repo.dirstate.copied(f) |
2383 # make backup if not in target manifest |
2380 # make backup if not in target manifest |
2384 (modified, revert, remove, True, True), |
2381 (modified, revert, remove, True, True), |
2385 (added, revert, forget, True, False), |
2382 (added, revert, forget, True, False), |
2386 (removed, undelete, None, False, False), |
2383 (removed, undelete, None, False, False), |
2387 (deleted, revert, remove, False, False), |
2384 (deleted, revert, remove, False, False), |
2388 (unknown, add, None, True, False), |
|
2389 (target_only, add, None, False, False), |
|
2390 ) |
2385 ) |
2391 |
2386 |
2392 entries = names.items() |
2387 entries = names.items() |
2393 entries.sort() |
2388 entries.sort() |
2394 |
2389 |
2411 # file has changed in dirstate |
2406 # file has changed in dirstate |
2412 if mfentry: |
2407 if mfentry: |
2413 handle(hitlist, backuphit) |
2408 handle(hitlist, backuphit) |
2414 elif misslist is not None: |
2409 elif misslist is not None: |
2415 handle(misslist, backupmiss) |
2410 handle(misslist, backupmiss) |
2416 else: |
|
2417 if exact: ui.warn(_('file not managed: %s\n') % rel) |
|
2418 break |
2411 break |
2419 else: |
2412 else: |
|
2413 if abs not in repo.dirstate: |
|
2414 if mfentry: |
|
2415 handle(add, True) |
|
2416 elif exact: |
|
2417 ui.warn(_('file not managed: %s\n') % rel) |
|
2418 continue |
2420 # file has not changed in dirstate |
2419 # file has not changed in dirstate |
2421 if node == parent: |
2420 if node == parent: |
2422 if exact: ui.warn(_('no changes needed to %s\n') % rel) |
2421 if exact: ui.warn(_('no changes needed to %s\n') % rel) |
2423 continue |
2422 continue |
2424 if pmf is None: |
2423 if pmf is None: |