comparison 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
comparison
equal deleted inserted replaced
16111:131d1a09108a 16112:d7829b2ecf32
473 def close(self): 473 def close(self):
474 wctx = self.repo[None] 474 wctx = self.repo[None]
475 addremoved = set(self.changed) 475 addremoved = set(self.changed)
476 for src, dst in self.copied: 476 for src, dst in self.copied:
477 scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst) 477 scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst)
478 addremoved.discard(src) 478 if self.removed:
479 if (not self.similarity) and self.removed:
480 wctx.forget(sorted(self.removed)) 479 wctx.forget(sorted(self.removed))
480 for f in self.removed:
481 if f not in self.repo.dirstate:
482 # File was deleted and no longer belongs to the
483 # dirstate, it was probably marked added then
484 # deleted, and should not be considered by
485 # addremove().
486 addremoved.discard(f)
481 if addremoved: 487 if addremoved:
482 cwd = self.repo.getcwd() 488 cwd = self.repo.getcwd()
483 if cwd: 489 if cwd:
484 addremoved = [util.pathto(self.repo.root, cwd, f) 490 addremoved = [util.pathto(self.repo.root, cwd, f)
485 for f in addremoved] 491 for f in addremoved]