[PATCH stable] filectx: fix cmp() of file starting with '\1\n'

Yuya Nishihara yuya at tcha.org
Wed Jan 11 09:39:13 CST 2012


Matt Mackall wrote:
> On Wed, 2012-01-11 at 01:46 +0900, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1326213787 -32400
> > # Branch stable
> > # Node ID fc9a58eeb4a6d74768fe8a184638e2d247603d3c
> > # Parent  e4fc0f0b4f7e73f6cbfa132cf09b7027a909d08c
> > filectx: fix cmp() of file starting with '\1\n'
> > 
> > Because filelog.size() returns size+4 for data starting with '\1\n',
> > fctx.cmp(workingfcx) happens to return True wrongly. As the result,
> > `hg status` of a file starting with '\1\n' is always M, even if it isn't
> > modified.
> 
> This took me a while to understand:
> 
> If file data starts with '\1\n', it will be escaped in the revlog to
> create an empty metadata block, thus adding four bytes to the size in
> the revlog size index. There's no way to detect that this has happened
> in filelog.size() faster than decompressing each revision.
> 
> For filectx.cmp(), we have the size of the file in the working directory
> available. If it differs by exactly four bytes, it may be this case, so
> do a full comparison.

Thanks Matt. It's very clear and detailed description.
I'll resend the patch soon with updated commit message and if-condition.

Regards,


More information about the Mercurial-devel mailing list