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

Sune Foldager cryo at cyanite.org
Mon Feb 7 05:32:11 CST 2011


On 01-02-2011 01:02, Matt Mackall wrote:
> 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.

I'll take a deeper look at that, then.

Yes, lwcopies might (although it's almost pathological) end up being 
stored as deltas. This will not be a problem, though, and likely take up 
less space than a proper lwcopy store would for that entry. For copies 
introduced locally, they will never be deltafied.

-Sune


More information about the Mercurial-devel mailing list