# HG changeset patch # User Patrick Mezard # Date 1306525809 -7200 # Node ID 9cb57d78b54f742336dd576a119ad9488aa8239d # Parent e39ab51937a2b2abba2bcb72fd4ce37d8fa0ce80 patch: refactor file creation/removal detection The patcher has to know if a file is being created or removed to check if the target already exists, or to actually unlink the file when a hunk emptying it is applied. This was done by embedding the creation/removal information in the first (and only) hunk attached to the file. There are two problems with this approach: - creation/removal is really a property of the file being patched and not its hunk. - for regular patches, file creation cannot be deduced at parsing time: there are case where the *stripped* file paths must be compared. Modifying hunks after their creation is clumsy and prevent further refactorings related to copies handling. Instead, we delegate this job to selectfile() which has all the relevant information, and remove the hunk createfile() and rmfile() methods. [ original upstream message ] diff -r e39ab51937a2 -r 9cb57d78b54f hgkw/keyword.py --- a/hgkw/keyword.py Fri May 27 17:46:48 2011 +0300 +++ b/hgkw/keyword.py Fri May 27 21:50:09 2011 +0200 @@ -595,11 +595,11 @@ wlock.release() # monkeypatches - def kwpatchfile_init(orig, self, ui, fname, backend, mode, + def kwpatchfile_init(orig, self, ui, fname, backend, mode, create, remove, missing=False, eolmode=None): '''Monkeypatch/wrap patch.patchfile.__init__ to avoid rejects or conflicts due to expanded keywords in working dir.''' - orig(self, ui, fname, backend, mode, missing, eolmode) + orig(self, ui, fname, backend, mode, create, remove, missing, eolmode) # shrink keywords read from working dir self.lines = kwt.shrinklines(self.fname, self.lines)