[PATCH V2] py3: change explicit conversion from str to pycompat.bytestr

Rishabh Madan rishabhmadan96 at gmail.com
Fri Mar 17 14:22:20 EDT 2017


The replace() function for py3 wasn't working when `value` was being
typecasted as str. When I used pycompat.bytestr the error was resolved. So
I guess it is preserved by such methods.

ᐧ

On Fri, Mar 17, 2017 at 10:45 PM, Martin von Zweigbergk <
martinvonz at google.com> wrote:

>
>
> On Fri, Mar 17, 2017 at 6:49 AM, Rishabh Madan <rishabhmadan96 at gmail.com>
> wrote:
>
>> Sorry. I didn't know that changing the changeset message for V2 forwards
>> it as a different stream.
>>>>
>> On Fri, Mar 17, 2017 at 7:14 PM, Rishabh Madan <rishabhmadan96 at gmail.com>
>> wrote:
>>
>>> # HG changeset patch
>>> # User Rishabh Madan <rishabhmadan96 at gmail.com>
>>> # Date 1489758142 -19800
>>> #      Fri Mar 17 19:12:22 2017 +0530
>>> # Node ID 3d6d9294e2247316541942c4bec5186cb5772cd6
>>> # Parent  a5bad127128d8f60060be53d161acfa7a32a17d5
>>> py3: change explicit conversion from str to pycompat.bytestr
>>>
>>> diff -r a5bad127128d -r 3d6d9294e224 mercurial/commands.py
>>> --- a/mercurial/commands.py     Wed Mar 15 15:48:57 2017 -0700
>>> +++ b/mercurial/commands.py     Fri Mar 17 19:12:22 2017 +0530
>>> @@ -1813,7 +1813,7 @@
>>>      matched = False
>>>      for section, name, value in ui.walkconfig(untrusted=untrusted):
>>>          source = ui.configsource(section, name, untrusted)
>>> -        value = str(value)
>>> +        value = pycompat.bytestr(value)
>>>          if fm.isplain():
>>>              source = source or 'none'
>>>              value = value.replace('\n', '\\n')
>>>
>>
> I thought I read that pycompat.bytestr-ness is not preserved by operations
> (such as replace() on this line). If that's correct, will the above still
> work if fm.isplain()?
>
>
>>
>>
>>
>> --
>> Rishabh Madan
>> Second Year Undergraduate student
>> Indian Institute of Technology, Kharagpur
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>>
>>
>


-- 
Rishabh Madan
Second Year Undergraduate student
Indian Institute of Technology, Kharagpur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170317/ae6dc892/attachment.html>


More information about the Mercurial-devel mailing list