Mercurial > public > mercurial-scm > hg-stable
diff mercurial/patch.py @ 16112:d7829b2ecf32 stable
import: handle git renames and --similarity (issue3187)
There is no reason to discard copy sources from the set of files considered by
addremove(). It was done to handle the case where a first patch would create
'a' and a second one would move 'a' to 'b'. If these patches were applied with
--no-commit, 'a' would first be marked as added, then unlinked and dropped from
the dirstate but still passed to addremove(). A better fix is thus to exclude
removed files which ends being dropped from the dirstate instead of removed.
Reported by Jason Harris <jason@jasonfharris.com>
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Thu, 16 Feb 2012 13:03:42 +0100 |
parents | 089ee59a8658 |
children | ccba74472af2 |
line wrap: on
line diff
--- a/mercurial/patch.py Thu Feb 16 12:56:48 2012 +0100 +++ b/mercurial/patch.py Thu Feb 16 13:03:42 2012 +0100 @@ -475,9 +475,15 @@ addremoved = set(self.changed) for src, dst in self.copied: scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst) - addremoved.discard(src) - if (not self.similarity) and self.removed: + if self.removed: wctx.forget(sorted(self.removed)) + for f in self.removed: + if f not in self.repo.dirstate: + # File was deleted and no longer belongs to the + # dirstate, it was probably marked added then + # deleted, and should not be considered by + # addremove(). + addremoved.discard(f) if addremoved: cwd = self.repo.getcwd() if cwd: