comparison hgext/keyword.py @ 14451:c78d41db6f88

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.
author Patrick Mezard <pmezard@gmail.com>
date Fri, 27 May 2011 21:50:09 +0200
parents 468d7d1744b4
children ee574cfd0c32
comparison
equal deleted inserted replaced
14450:d1a1578c5f78 14451:c78d41db6f88
593 return ret 593 return ret
594 finally: 594 finally:
595 wlock.release() 595 wlock.release()
596 596
597 # monkeypatches 597 # monkeypatches
598 def kwpatchfile_init(orig, self, ui, fname, backend, mode, 598 def kwpatchfile_init(orig, self, ui, fname, backend, mode, create, remove,
599 missing=False, eolmode=None): 599 missing=False, eolmode=None):
600 '''Monkeypatch/wrap patch.patchfile.__init__ to avoid 600 '''Monkeypatch/wrap patch.patchfile.__init__ to avoid
601 rejects or conflicts due to expanded keywords in working dir.''' 601 rejects or conflicts due to expanded keywords in working dir.'''
602 orig(self, ui, fname, backend, mode, missing, eolmode) 602 orig(self, ui, fname, backend, mode, create, remove, missing, eolmode)
603 # shrink keywords read from working dir 603 # shrink keywords read from working dir
604 self.lines = kwt.shrinklines(self.fname, self.lines) 604 self.lines = kwt.shrinklines(self.fname, self.lines)
605 605
606 def kw_diff(orig, repo, node1=None, node2=None, match=None, changes=None, 606 def kw_diff(orig, repo, node1=None, node2=None, match=None, changes=None,
607 opts=None, prefix=''): 607 opts=None, prefix=''):