[PATCH 4 of 6] filelog: add support for unpacking lwcopy entries

Matt Mackall mpm at selenic.com
Tue Feb 1 00:02:41 UTC 2011


On Mon, 2011-01-31 at 11:21 +0100, Sune Foldager wrote:
> # HG changeset patch
> # User Sune Foldager <cryo at cyanite.org>
> # Date 1296295857 -3600
> # Node ID b973580739760fc25f971b947864a890abf5eb2c
> # Parent  c53628efd882402813e98fc86bde1bf825ad1c79
> 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):
> @@ -67,6 +67,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)

As I mentioned before, I introduced _checkhash for this purpose.
_chunk/_chunkbase is actually not in the right place - a lightweight
copy may end up getting stored as a delta in the target revlog.

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial-devel mailing list