Patchwork [1,of,1,STABLE] util: url keeps backslash in paths

login
register
mail settings
Submitter Simon Heimberg
Date Nov. 20, 2013, 9:08 p.m.
Message ID <1f9983bb44e0d664ff07.1384981682@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/3072/
State Accepted
Commit c33d9217e99df21528432b4324010fdc394ae7ea
Headers show

Comments

Simon Heimberg - Nov. 20, 2013, 9:08 p.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1384981395 -3600
# Node ID 1f9983bb44e0d664ff07a946348c97c7134dd020
# Parent  912600b53260972353613d3f97d865c7a610d049
util: url keeps backslash in paths

Backslashes (\) in paths were encoded to %C5 when converting from url to
string. This does not look nice for windows paths. And it introduces many
problems when running tests on windows.
Simon Heimberg - Nov. 20, 2013, 9:30 p.m.
Warning: By accident I did run the tests without this patch applied, so 
I do not know if they pass.

On 20.11.2013 22:08, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1384981395 -3600
> # Node ID 1f9983bb44e0d664ff07a946348c97c7134dd020
> # Parent  912600b53260972353613d3f97d865c7a610d049
> util: url keeps backslash in paths
>
> Backslashes (\) in paths were encoded to %C5 when converting from url to
> string. This does not look nice for windows paths. And it introduces many
> problems when running tests on windows.
>
> diff -r 912600b53260 -r 1f9983bb44e0 mercurial/util.py
> --- a/mercurial/util.py	Mon Nov 18 22:45:40 2013 +0100
> +++ b/mercurial/util.py	Mit Nov 20 22:03:15 2013 +0100
> @@ -1634,6 +1634,8 @@
>       <url path: '\\\\blah\\blah\\blah'>
>       >>> url(r'\\blah\blah\blah#baz')
>       <url path: '\\\\blah\\blah\\blah', fragment: 'baz'>
> +    >>> url(r'file:///C:\users\me')
> +    <url scheme: 'file', path: 'C:\\users\\me'>
>
>       Authentication credentials:
>
> @@ -1651,7 +1653,7 @@
>       """
>
>       _safechars = "!~*'()+"
> -    _safepchars = "/!~*'()+:"
> +    _safepchars = "/!~*'()+:\\"
>       _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match
>
>       def __init__(self, path, parsequery=True, parsefragment=True):
> @@ -1788,6 +1790,8 @@
>           'file:///c:/tmp/foo/bar'
>           >>> print url(r'bundle:foo\bar')
>           bundle:foo\bar
> +        >>> print url(r'file:///D:\data\hg')
> +        file:///D:\data\hg
>           """
>           if self._localpath:
>               s = self.path
>
Augie Fackler - Nov. 21, 2013, 2:47 p.m.
On Wed, Nov 20, 2013 at 10:08:02PM +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1384981395 -3600
> # Node ID 1f9983bb44e0d664ff07a946348c97c7134dd020
> # Parent  912600b53260972353613d3f97d865c7a610d049
> util: url keeps backslash in paths

looks reasonable, but someone with windows (or a windows-friendly test
setup) might want to look and/or test?

>
> Backslashes (\) in paths were encoded to %C5 when converting from url to
> string. This does not look nice for windows paths. And it introduces many
> problems when running tests on windows.
>
> diff -r 912600b53260 -r 1f9983bb44e0 mercurial/util.py
> --- a/mercurial/util.py	Mon Nov 18 22:45:40 2013 +0100
> +++ b/mercurial/util.py	Mit Nov 20 22:03:15 2013 +0100
> @@ -1634,6 +1634,8 @@
>      <url path: '\\\\blah\\blah\\blah'>
>      >>> url(r'\\blah\blah\blah#baz')
>      <url path: '\\\\blah\\blah\\blah', fragment: 'baz'>
> +    >>> url(r'file:///C:\users\me')
> +    <url scheme: 'file', path: 'C:\\users\\me'>
>
>      Authentication credentials:
>
> @@ -1651,7 +1653,7 @@
>      """
>
>      _safechars = "!~*'()+"
> -    _safepchars = "/!~*'()+:"
> +    _safepchars = "/!~*'()+:\\"
>      _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match
>
>      def __init__(self, path, parsequery=True, parsefragment=True):
> @@ -1788,6 +1790,8 @@
>          'file:///c:/tmp/foo/bar'
>          >>> print url(r'bundle:foo\bar')
>          bundle:foo\bar
> +        >>> print url(r'file:///D:\data\hg')
> +        file:///D:\data\hg
>          """
>          if self._localpath:
>              s = self.path
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - Nov. 25, 2013, 10:01 p.m.
On Wed, 2013-11-20 at 22:08 +0100, Simon Heimberg wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe@besonet.ch>
> # Date 1384981395 -3600
> # Node ID 1f9983bb44e0d664ff07a946348c97c7134dd020
> # Parent  912600b53260972353613d3f97d865c7a610d049
> util: url keeps backslash in paths

This is queued for stable, thanks.

Patch

diff -r 912600b53260 -r 1f9983bb44e0 mercurial/util.py
--- a/mercurial/util.py	Mon Nov 18 22:45:40 2013 +0100
+++ b/mercurial/util.py	Mit Nov 20 22:03:15 2013 +0100
@@ -1634,6 +1634,8 @@ 
     <url path: '\\\\blah\\blah\\blah'>
     >>> url(r'\\blah\blah\blah#baz')
     <url path: '\\\\blah\\blah\\blah', fragment: 'baz'>
+    >>> url(r'file:///C:\users\me')
+    <url scheme: 'file', path: 'C:\\users\\me'>
 
     Authentication credentials:
 
@@ -1651,7 +1653,7 @@ 
     """
 
     _safechars = "!~*'()+"
-    _safepchars = "/!~*'()+:"
+    _safepchars = "/!~*'()+:\\"
     _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match
 
     def __init__(self, path, parsequery=True, parsefragment=True):
@@ -1788,6 +1790,8 @@ 
         'file:///c:/tmp/foo/bar'
         >>> print url(r'bundle:foo\bar')
         bundle:foo\bar
+        >>> print url(r'file:///D:\data\hg')
+        file:///D:\data\hg
         """
         if self._localpath:
             s = self.path