[PATCH 1 of 1] fix issue 1625: incorrect path separator and ui.slash setting handling on Windows

Stefan Rusek stefan at rusek.org
Wed Apr 29 10:01:24 CDT 2009


On Wed, Apr 29, 2009 at 16:34, Steve Borho <steve at borho.org> wrote:
> On Wed, Apr 29, 2009 at 8:41 AM, Stefan Rusek <stefan at rusek.org> wrote:
>> On Wed, Apr 29, 2009 at 15:36, Stefan Rusek <stefan at rusek.org> wrote:
>>> On Wed, Apr 29, 2009 at 03:34, Alejandro Santos <alejolp at alejolp.com> wrote:
>>>> # HG changeset patch
>>>> # User Alejandro Santos <alejolp at alejolp.com>
>>>> # Date 1240963582 10800
>>>> # Node ID 4942e4b21a262049520148f95478a05a5985b1da
>>>> # Parent  c8c231da59c36b8a19f86c090e2f9f450d7b7029
>>>> fix issue 1625: incorrect path separator and ui.slash setting handling on Windows
>>>>
>>>> diff -r c8c231da59c36b8a19f86c090e2f9f450d7b7029 -r 4942e4b21a262049520148f95478a05a5985b1da mercurial/commands.py
>>>> --- a/mercurial/commands.py     Sun Apr 26 16:49:47 2009 -0500
>>>> +++ b/mercurial/commands.py     Tue Apr 28 21:06:22 2009 -0300
>>>> @@ -1816,16 +1816,21 @@
>>>>     end = opts.get('print0') and '\0' or '\n'
>>>>     rev = opts.get('rev') or None
>>>>
>>>> +    # The slash that has to be used according to the user config
>>>> +    cfgslash = ui.configbool('ui', 'slash') and '/' or os.sep
>>>> +
>>>>
>>>
>>> It seems like this is a bit more complicated than it really needs to
>>> be. Especially since the majority of the time cfgslash is going to be
>>> the same as os.sep, which means we are doing a lot of unneeded work.
>>>
>>
>> I got the args backwards: cfgslash.join(x.split(os.sep)) is a really
>> inefficient and opaque way of doing x.replace(os.sep, cfgslash).
>
> I think util.pconvert() was made for this purpose.
>

Ale,

I would suggest replacing

cfgslash = ui.configbool('ui', 'slash') and '/' or os.sep

with

fnfixslash = ui.configbool('ui', 'slash') and util.pconvert or util.localpath

Then passing the path to fnfixslash before ui.write()ing it.

--Stefan



More information about the Mercurial-devel mailing list