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

Benoit Boissinot benoit.boissinot at ens-lyon.org
Wed Sep 15 03:11:27 CDT 2010


On Tue, Sep 14, 2010 at 11:56:33AM +0200, Sune Foldager wrote:
> # 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

I'm wondering, how much does it cost to duplicate the meta keys, put
them in both the delta, and in the text (so no need to have the special
handling to keep the order, and to remove "copylw").

> 
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

-- 
:wq


More information about the Mercurial-devel mailing list