Mercurial > hg
changeset 22488:6c52ed3f888e
revert: split between newly added file and file added in other changeset
These two kinds of files are handled differently. One is deleted and the other
is just forgotten (the file is untracked but left in place). The distinction is
done in the `_performrevert` code itself and we would like to get ride of this.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 30 Aug 2014 18:20:29 +0200 |
parents | e40bb83d0989 |
children | 0d57bf80c7cb |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 12 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Tue Sep 16 22:55:49 2014 -0700 +++ b/mercurial/cmdutil.py Sat Aug 30 18:20:29 2014 +0200 @@ -2554,20 +2554,9 @@ dsmodified |= modified & dsadded # dirstate added may needs backup modified -= dsmodified - # There are three categories of added files - # - # 1. addition that just happened in the dirstate - # (should be forgotten) - # 2. file is added since target revision and has local changes - # (should be backed up and removed) - # 3. file is added since target revision and is clean - # (should be removed) - # - # However we do not need to split them yet. The current revert code - # will automatically recognize (1) when performing operation. And - # the backup system is currently unabled to handle (2). - # - # So we just put them all in the same group. + # We need to wait for some post-processing to update this set + # before making the distinction. The dirstate will be used for + # that purpose. dsadded = added # in case of merge, files that are actually added can be reported as @@ -2590,6 +2579,13 @@ dsremoved.add(src) names[src] = (repo.pathto(src, cwd), True) + # distinguish between file to forget and the other + added = set() + for abs in dsadded: + if repo.dirstate[abs] != 'a': + added.add(abs) + dsadded -= added + # For files marked as removed, we check if an unknown file is present at # the same path. If a such file exists it may need to be backed up. # Making the distinction at this stage helps have simpler backup @@ -2644,6 +2640,8 @@ # Modified compared to target, local change (dsmodified, actions['revert'], backup), # Added since target + (added, actions['remove'], discard), + # Added in working directory (dsadded, actions['remove'], discard), # Removed since target, before working copy parent (removed, actions['add'], discard),