[PATCH 4 of 7] filelog: add support for unpacking lwcopy entries
Sune Foldager
cryo at cyanite.org
Tue Sep 14 04:56:33 CDT 2010
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1284157797 -7200
# Node ID a216867d6bb6f768ebeca2140d36c207e08264d1
# Parent 6d45223c5d5b9c6375f111d95ae711e689d0ecd1
filelog: add support for unpacking lwcopy entries
diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import revlog
+import revlog, mdiff
import re
class filelog(revlog.revlog):
@@ -69,6 +69,23 @@
return True
+ def _ptext(self, meta):
+ return filelog(self.opener, meta["copy"]).read(revlog.bin(meta["copyrev"]))
+
+ def _unpack_text(self, text):
+ meta, keys, mdlen = _parsemeta(text)
+ if meta and "copylw" in meta:
+ ptext = self._ptext(meta)
+ text = mdiff.patches(ptext, [buffer(text, mdlen)])
+ # delete copylw entry to get just what we should get without lwcopy
+ keys.remove("copylw")
+ text = "\1\n%s\1\n%s" % (_packmeta(meta, keys), text)
+ return text
+
+ def _chunkbase(self, rev):
+ text = revlog.revlog._chunkbase(self, rev)
+ return self._unpack_text(text)
+
_mdre = re.compile('\1\n')
def _parsemeta(text):
# text can be buffer, so we can't use .startswith or .index
More information about the Mercurial-devel
mailing list