Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 20106:c33d9217e99d stable
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.
author | Simon Heimberg <simohe@besonet.ch> |
---|---|
date | Wed, 20 Nov 2013 22:03:15 +0100 |
parents | 0849d280663e |
children | af12f58e2aa0 |
comparison
equal
deleted
inserted
replaced
20105:c5a0f899e47b | 20106:c33d9217e99d |
---|---|
1631 <url path: 'c:\\foo\\bar'> | 1631 <url path: 'c:\\foo\\bar'> |
1632 >>> url(r'\\blah\blah\blah') | 1632 >>> url(r'\\blah\blah\blah') |
1633 <url path: '\\\\blah\\blah\\blah'> | 1633 <url path: '\\\\blah\\blah\\blah'> |
1634 >>> url(r'\\blah\blah\blah#baz') | 1634 >>> url(r'\\blah\blah\blah#baz') |
1635 <url path: '\\\\blah\\blah\\blah', fragment: 'baz'> | 1635 <url path: '\\\\blah\\blah\\blah', fragment: 'baz'> |
1636 >>> url(r'file:///C:\users\me') | |
1637 <url scheme: 'file', path: 'C:\\users\\me'> | |
1636 | 1638 |
1637 Authentication credentials: | 1639 Authentication credentials: |
1638 | 1640 |
1639 >>> url('ssh://joe:xyz@x/repo') | 1641 >>> url('ssh://joe:xyz@x/repo') |
1640 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> | 1642 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> |
1648 >>> url('http://host/a?b#c', parsequery=False, parsefragment=False) | 1650 >>> url('http://host/a?b#c', parsequery=False, parsefragment=False) |
1649 <url scheme: 'http', host: 'host', path: 'a?b#c'> | 1651 <url scheme: 'http', host: 'host', path: 'a?b#c'> |
1650 """ | 1652 """ |
1651 | 1653 |
1652 _safechars = "!~*'()+" | 1654 _safechars = "!~*'()+" |
1653 _safepchars = "/!~*'()+:" | 1655 _safepchars = "/!~*'()+:\\" |
1654 _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match | 1656 _matchscheme = re.compile(r'^[a-zA-Z0-9+.\-]+:').match |
1655 | 1657 |
1656 def __init__(self, path, parsequery=True, parsefragment=True): | 1658 def __init__(self, path, parsequery=True, parsefragment=True): |
1657 # We slowly chomp away at path until we have only the path left | 1659 # We slowly chomp away at path until we have only the path left |
1658 self.scheme = self.user = self.passwd = self.host = None | 1660 self.scheme = self.user = self.passwd = self.host = None |
1785 'file:///tmp/foo/bar' | 1787 'file:///tmp/foo/bar' |
1786 >>> str(url('file:///c:/tmp/foo/bar')) | 1788 >>> str(url('file:///c:/tmp/foo/bar')) |
1787 'file:///c:/tmp/foo/bar' | 1789 'file:///c:/tmp/foo/bar' |
1788 >>> print url(r'bundle:foo\bar') | 1790 >>> print url(r'bundle:foo\bar') |
1789 bundle:foo\bar | 1791 bundle:foo\bar |
1792 >>> print url(r'file:///D:\data\hg') | |
1793 file:///D:\data\hg | |
1790 """ | 1794 """ |
1791 if self._localpath: | 1795 if self._localpath: |
1792 s = self.path | 1796 s = self.path |
1793 if self.scheme == 'bundle': | 1797 if self.scheme == 'bundle': |
1794 s = 'bundle:' + s | 1798 s = 'bundle:' + s |