RFC: pattern handling in subpaths

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Apr 9 03:30:51 CDT 2012


Hi, devels.

Current '[subpaths]' implementation doesn't allow you to map some URL
into the path which has the path component starting with digit on Win
environment (e.g.: 'C:\1st\2nd'), because of automatic escaping below:

            # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub
            # does a string decode.
            repl = repl.encode('string-escape')
            # However, we still want to allow back references to go
            # through unharmed, so we turn r'\\1' into r'\1'. Again,
            # extra escapes are needed because re.sub string decodes.
            repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl)

# introduced by f3075ffa6b30

This escaping is certainly convenient, but not useful in such case.

So, I'm planning to introduce r'...' notation into '[subpaths]' to
avoid escaping in subpaths specific rule.

Here, which is better for users ?

(1) - naked string to escape in subpaths specific rule
    - r'...' notation to avoid any escaping

(2) users should aware of pattern escaping in substitution, so go
    backward to pre-f3075ffa6b30 (and r'...' is not needed)

(3) or other ....


BTW:

I also thought about '...'(or "...") notation which is escaped as same
as Python string literal.

But, for example, users should write '\\\\' in this notation to get
'\' in substitution result, because it is escaped twice (once by
subpaths, and once by "re.sub()"). It is very difficult for a lot of
users.

So, I omitted this notation: does someone need this notation ?

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list