comparison mercurial/cmdutil.py @ 22490:bcab7bc7280e

revert: explicitly track added but deleted file Added + deleted file are files that need to be untracked from the dirstate but that are already missing on disk. The current `_performrevert` code is handling that with exception catching. We will be able to do better with a dedicated set.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 30 Aug 2014 02:23:25 +0200
parents 0d57bf80c7cb
children 5e16fe6fdd32
comparison
equal deleted inserted replaced
22489:0d57bf80c7cb 22490:bcab7bc7280e
2521 2521
2522 # split between files known in target manifest and the others 2522 # split between files known in target manifest and the others
2523 smf = set(mf) 2523 smf = set(mf)
2524 2524
2525 # determine the exact nature of the deleted changesets 2525 # determine the exact nature of the deleted changesets
2526 _deletedadded = _deleted - smf 2526 deladded = _deleted - smf
2527 deleted = _deleted - _deletedadded 2527 deleted = _deleted - deladded
2528 added |= _deletedadded
2529 2528
2530 # We need to account for the state of file in the dirstate 2529 # We need to account for the state of file in the dirstate
2531 # 2530 #
2532 # Even, when we revert agains something else than parent. this will 2531 # Even, when we revert agains something else than parent. this will
2533 # slightly alter the behavior of revert (doing back up or not, delete 2532 # slightly alter the behavior of revert (doing back up or not, delete
2584 for abs in dsadded: 2583 for abs in dsadded:
2585 if repo.dirstate[abs] != 'a': 2584 if repo.dirstate[abs] != 'a':
2586 added.add(abs) 2585 added.add(abs)
2587 dsadded -= added 2586 dsadded -= added
2588 2587
2588 for abs in deladded:
2589 if repo.dirstate[abs] == 'a':
2590 dsadded.add(abs)
2591 deladded -= dsadded
2592
2589 # For files marked as removed, we check if an unknown file is present at 2593 # For files marked as removed, we check if an unknown file is present at
2590 # the same path. If a such file exists it may need to be backed up. 2594 # the same path. If a such file exists it may need to be backed up.
2591 # Making the distinction at this stage helps have simpler backup 2595 # Making the distinction at this stage helps have simpler backup
2592 # logic. 2596 # logic.
2593 removunk = set() 2597 removunk = set()
2635 (dsmodified, actions['revert'], backup), 2639 (dsmodified, actions['revert'], backup),
2636 # Added since target 2640 # Added since target
2637 (added, actions['remove'], discard), 2641 (added, actions['remove'], discard),
2638 # Added in working directory 2642 # Added in working directory
2639 (dsadded, actions['forget'], discard), 2643 (dsadded, actions['forget'], discard),
2644 # Added since target but file is missing in working directory
2645 (deladded, actions['remove'], discard),
2640 # Removed since target, before working copy parent 2646 # Removed since target, before working copy parent
2641 (removed, actions['add'], discard), 2647 (removed, actions['add'], discard),
2642 # Same as `removed` but an unknown file exists at the same path 2648 # Same as `removed` but an unknown file exists at the same path
2643 (removunk, actions['add'], backup), 2649 (removunk, actions['add'], backup),
2644 # Removed since targe, marked as such in working copy parent 2650 # Removed since targe, marked as such in working copy parent