# HG changeset patch # User Patrick Mezard # Date 2011-06-14 21:24:34 # Node ID f53dc0787424b7783d037e25f9bb7c694019715b # Parent 4aef71839337c5548eba07f6e76d9b002d31ad70 patch: extend filtestore to store an optional copy source This will help wrapping filestores in memctx. diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -491,7 +491,7 @@ class filestore(object): self.files = {} self.created = 0 - def setfile(self, fname, data, mode): + def setfile(self, fname, data, mode, copied=None): if self.opener is None: root = tempfile.mkdtemp(prefix='hg-patch-') self.opener = scmutil.opener(root) @@ -499,13 +499,13 @@ class filestore(object): fn = str(self.created) self.opener.write(fn, data) self.created += 1 - self.files[fname] = (fn, mode) + self.files[fname] = (fn, mode, copied) def getfile(self, fname): if fname not in self.files: raise IOError() - fn, mode = self.files[fname] - return self.opener.read(fn), mode + fn, mode, copied = self.files[fname] + return self.opener.read(fn), mode, copied def close(self): if self.opener: @@ -535,7 +535,7 @@ class patchfile(object): data, mode = backend.getfile(self.fname) self.exists = True else: - data, mode = store.getfile(self.copysource) + data, mode = store.getfile(self.copysource)[:2] self.exists = backend.exists(self.fname) self.missing = False if data: @@ -1248,7 +1248,7 @@ def _applydiff(ui, fp, patcher, backend, continue data, mode = None, None if gp.op in ('RENAME', 'COPY'): - data, mode = store.getfile(gp.oldpath) + data, mode = store.getfile(gp.oldpath)[:2] if gp.mode: mode = gp.mode if gp.op == 'ADD':