comparison mercurial/cmdutil.py @ 22491:5e16fe6fdd32

revert: add a `drop` action This prevents the need for a try except in the `_performrevert` code.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 30 Aug 2014 02:25:23 +0200
parents bcab7bc7280e
children 8d707da26f9b
comparison
equal deleted inserted replaced
22490:bcab7bc7280e 22491:5e16fe6fdd32
2611 # action to be actually performed by revert 2611 # action to be actually performed by revert
2612 # (<list of file>, message>) tuple 2612 # (<list of file>, message>) tuple
2613 actions = {'revert': ([], _('reverting %s\n')), 2613 actions = {'revert': ([], _('reverting %s\n')),
2614 'add': ([], _('adding %s\n')), 2614 'add': ([], _('adding %s\n')),
2615 'remove': ([], _('removing %s\n')), 2615 'remove': ([], _('removing %s\n')),
2616 'drop': ([], _('removing %s\n')),
2616 'forget': ([], _('forgetting %s\n')), 2617 'forget': ([], _('forgetting %s\n')),
2617 'undelete': ([], _('undeleting %s\n')), 2618 'undelete': ([], _('undeleting %s\n')),
2618 'noop': (None, _('no changes needed to %s\n')), 2619 'noop': (None, _('no changes needed to %s\n')),
2619 'unknown': (None, _('file not managed: %s\n')), 2620 'unknown': (None, _('file not managed: %s\n')),
2620 } 2621 }
2640 # Added since target 2641 # Added since target
2641 (added, actions['remove'], discard), 2642 (added, actions['remove'], discard),
2642 # Added in working directory 2643 # Added in working directory
2643 (dsadded, actions['forget'], discard), 2644 (dsadded, actions['forget'], discard),
2644 # Added since target but file is missing in working directory 2645 # Added since target but file is missing in working directory
2645 (deladded, actions['remove'], discard), 2646 (deladded, actions['drop'], discard),
2646 # Removed since target, before working copy parent 2647 # Removed since target, before working copy parent
2647 (removed, actions['add'], discard), 2648 (removed, actions['add'], discard),
2648 # Same as `removed` but an unknown file exists at the same path 2649 # Same as `removed` but an unknown file exists at the same path
2649 (removunk, actions['add'], backup), 2650 (removunk, actions['add'], backup),
2650 # Removed since targe, marked as such in working copy parent 2651 # Removed since targe, marked as such in working copy parent
2719 audit_path = pathutil.pathauditor(repo.root) 2720 audit_path = pathutil.pathauditor(repo.root)
2720 for f in actions['forget'][0]: 2721 for f in actions['forget'][0]:
2721 repo.dirstate.drop(f) 2722 repo.dirstate.drop(f)
2722 for f in actions['remove'][0]: 2723 for f in actions['remove'][0]:
2723 audit_path(f) 2724 audit_path(f)
2724 try: 2725 util.unlinkpath(repo.wjoin(f))
2725 util.unlinkpath(repo.wjoin(f)) 2726 repo.dirstate.remove(f)
2726 except OSError: 2727 for f in actions['drop'][0]:
2727 pass 2728 audit_path(f)
2728 repo.dirstate.remove(f) 2729 repo.dirstate.remove(f)
2729 2730
2730 normal = None 2731 normal = None
2731 if node == parent: 2732 if node == parent:
2732 # We're reverting to our parent. If possible, we'd like status 2733 # We're reverting to our parent. If possible, we'd like status