[PATCH 10 of 10 py3] help: when looking for exclusion kws, convert doc to sysbytes

Augie Fackler raf at durin42.com
Wed May 31 15:18:18 EDT 2017


> On May 30, 2017, at 08:56, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> On Mon, 29 May 2017 10:32:32 -0400, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <raf at durin42.com>
>> # Date 1496001043 14400
>> #      Sun May 28 15:50:43 2017 -0400
>> # Node ID 6e1f46fb198dbe5ec45d01a34cea43c541bd7233
>> # Parent  f1be99397daee2fa8bd9d04cb1296cb7e0260c0d
>> help: when looking for exclusion kws, convert doc to sysbytes
>> 
>> There's one spot where doc is sometimes a unicode - I haven't figured
>> out when that happens, but it was easy enough to work around that I
>> just did so.
>> 
>> diff --git a/mercurial/help.py b/mercurial/help.py
>> --- a/mercurial/help.py
>> +++ b/mercurial/help.py
>> @@ -114,6 +114,8 @@ def indicateomitted(rst, omitted, notomi
>> def filtercmd(ui, cmd, kw, doc):
>>     if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
>>         return True
>> +    if doc and not isinstance(doc, bytes):
>> +        doc = pycompat.sysbytes(doc)
>>     if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
>>         return True
>>     return False
>> @@ -266,7 +268,8 @@ def makeitemsdoc(ui, topic, doc, marker,
>>     for name in sorted(items):
>>         text = (items[name].__doc__ or '').rstrip()
>>         if (not text
>> -            or not ui.verbose and any(w in text for w in _exclkeywords)):
>> +            or not ui.verbose
>> +            and any(w in pycompat.sysbytes(text) for w in _exclkeywords)):
> 
> That's probably because __doc__ is unicode. We'll need to convert every __doc__
> back to bytes.

Seems likely, but it also has to stay unicode until we're ready to use it for python internals reasons.

Does the approach in this patch seem reasonable-ish?



More information about the Mercurial-devel mailing list