def kwpatchfile_init(orig, self, ui, gp, backend, store, eolmode=None):
    """Monkeypatch/wrap patch.patchfile.__init__ to avoid
    rejects or conflicts due to expanded keywords in working dir."""
    orig(self, ui, gp, backend, store, eolmode)
    kwt = getattr(getattr(backend, 'repo', None), '_keywordkwt', None)
    if kwt:
        self.lines = kwt.shrinklines(self.fname, self.lines)
