Mercurial > hg
changeset 22185:afead12e724b
revert: triage "deleted" files into more appropriate categories
Status can return file as "deleted". This is only a special case
related to working directory state: file is recorded as tracked but no
file exists on disk. This will never be a state obtainable from
manifest comparisons.
"Deleted" files have another working directory status shadowed by the lack of
file. They will -alway- be touched by revert. The "lack of file" can be seen as
a modification. The file will never match the same "content" as in the revert
target. From there we have two options:
1. The file exists in the target and can be seen as "modified".
2. The file does not exist in the target and can be seen as "added".
So now we just dispatch elements from delete into appropriate categories.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 01 Aug 2014 18:57:53 -0700 |
parents | fb8065de47b0 |
children | a89bc7833e0d |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Aug 15 10:54:15 2014 -0500 +++ b/mercurial/cmdutil.py Fri Aug 01 18:57:53 2014 -0700 @@ -2380,7 +2380,16 @@ modified = set(changes[0]) added = set(changes[1]) removed = set(changes[2]) - deleted = set(changes[3]) + _deleted = set(changes[3]) + + # split between files known in target manifest and the others + smf = set(mf) + + # determine the exact nature of the deleted changesets + _deletedadded = _deleted - smf + _deletedmodified = _deleted - _deletedadded + added |= _deletedadded + modified |= _deletedmodified # We need to account for the state of file in the dirstate # @@ -2397,6 +2406,8 @@ dsmodified = set(changes[0]) dsadded = set(changes[1]) dsremoved = set(changes[2]) + dsadded |= _deletedadded + dsmodified |= _deletedmodified # if f is a rename, update `names` to also revert the source cwd = repo.getcwd() @@ -2413,17 +2424,12 @@ return _('forgetting %s\n') return _('removing %s\n') - # split between files known in target manifest and the others - smf = set(mf) - missingmodified = dsmodified - smf dsmodified -= missingmodified missingadded = dsadded - smf dsadded -= missingadded missingremoved = dsremoved - smf dsremoved -= missingremoved - missingdeleted = deleted - smf - deleted -= missingdeleted # action to be actually performed by revert # (<list of file>, message>) tuple @@ -2443,8 +2449,6 @@ (missingadded, (actions['remove'], False)), (dsremoved, (actions['undelete'], True)), (missingremoved, (None, False)), - (deleted, (actions['revert'], False)), - (missingdeleted, (actions['remove'], False)), ) for abs, (rel, exact) in sorted(names.items()):