comparison mercurial/cmdutil.py @ 22188:0ad619c5e1a4

revert: use "remove" information from both statuses Using status information against the target to make sure we are catching all files that need to be re-added. We still need to distinguish fresh removal because they use a different message.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 24 Jun 2014 16:53:22 +0100
parents aee5385e4bae
children cde6b489365c
comparison
equal deleted inserted replaced
22187:aee5385e4bae 22188:0ad619c5e1a4
2408 dsadded = set(changes[1]) 2408 dsadded = set(changes[1])
2409 dsremoved = set(changes[2]) 2409 dsremoved = set(changes[2])
2410 dsadded |= _deletedadded 2410 dsadded |= _deletedadded
2411 dsmodified |= _deletedmodified 2411 dsmodified |= _deletedmodified
2412 2412
2413 # only take into account for removes between wc and target
2414 clean |= dsremoved - removed
2415 dsremoved &= removed
2416 # distinct between dirstate remove and other
2417 removed -= dsremoved
2418
2413 # if f is a rename, update `names` to also revert the source 2419 # if f is a rename, update `names` to also revert the source
2414 cwd = repo.getcwd() 2420 cwd = repo.getcwd()
2415 for f in dsadded: 2421 for f in dsadded:
2416 src = repo.dirstate.copied(f) 2422 src = repo.dirstate.copied(f)
2417 if src and src not in names and repo.dirstate[src] == 'r': 2423 if src and src not in names and repo.dirstate[src] == 'r':
2427 2433
2428 missingmodified = dsmodified - smf 2434 missingmodified = dsmodified - smf
2429 dsmodified -= missingmodified 2435 dsmodified -= missingmodified
2430 missingadded = dsadded - smf 2436 missingadded = dsadded - smf
2431 dsadded -= missingadded 2437 dsadded -= missingadded
2432 clean |= dsremoved - smf
2433 dsremoved -= clean
2434 2438
2435 # action to be actually performed by revert 2439 # action to be actually performed by revert
2436 # (<list of file>, message>) tuple 2440 # (<list of file>, message>) tuple
2437 actions = {'revert': ([], _('reverting %s\n')), 2441 actions = {'revert': ([], _('reverting %s\n')),
2438 'add': ([], _('adding %s\n')), 2442 'add': ([], _('adding %s\n')),
2446 # make backup 2450 # make backup
2447 (dsmodified, (actions['revert'], True)), 2451 (dsmodified, (actions['revert'], True)),
2448 (missingmodified, (actions['remove'], True)), 2452 (missingmodified, (actions['remove'], True)),
2449 (dsadded, (actions['revert'], True)), 2453 (dsadded, (actions['revert'], True)),
2450 (missingadded, (actions['remove'], False)), 2454 (missingadded, (actions['remove'], False)),
2455 (removed, (actions['add'], True)),
2451 (dsremoved, (actions['undelete'], True)), 2456 (dsremoved, (actions['undelete'], True)),
2452 (clean, (None, False)), 2457 (clean, (None, False)),
2453 ) 2458 )
2454 2459
2455 for abs, (rel, exact) in sorted(names.items()): 2460 for abs, (rel, exact) in sorted(names.items()):