[PATCH 20 of 21 RFC] censor: new "record" function commits to .hgcensored, returns tombstone data

Durham Goode durham at fb.com
Wed Sep 10 21:09:16 CDT 2014


On 9/10/14, 5:26 PM, michaeljedgar at gmail.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar at google.com>
> # Date 1410323971 14400
> #      Wed Sep 10 00:39:31 2014 -0400
> # Node ID eff2398c409bcd7b70335f57563095fb63adf270
> # Parent  41b44791ab7feaeceaaf4b1031564526d497e945
> censor: new "record" function commits to .hgcensored, returns tombstone data
>
> +def record(repo, f, fnode, message, user, date):
> +    """Record censoring the file `f` at its filelog revision `fnode`"""
> +    entry = '%s %s' % (repo.store.encode(f), hex(fnode))
>
I'm not sure you need to encode the file path here?  Every filelog has a 
specific casing, and the encoding is just used to disambiguate when 
reading filelogs off disk.  So you can assume the path here has the 
appropriate casing and just write the string directly.  Just like how 
the manifest doesn't encode the file paths before storing them.  In 
other words, writing the string directly to .hgcensored doesn't lose any 
casing data, so encoding it seems superfluous.

You probably also need to sanitize the path given to the censor command, 
before saving it to .hgcensored.  To make sure it exactly matches an 
existing filelog's casing, rather than just accepting what the user typed.

Not encoding here would get rid of patch 19.


More information about the Mercurial-devel mailing list