Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 15074:64fbd0de9773 stable
url: parse fragments first (issue2997)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 10 Sep 2011 17:49:19 -0500 |
parents | 24efa83d81cb |
children | d30ec2d16c5a 94b200a11cf7 |
comparison
equal
deleted
inserted
replaced
15073:19071b04c9c1 | 15074:64fbd0de9773 |
---|---|
1432 <url scheme: 'bundle', path: '../foo'> | 1432 <url scheme: 'bundle', path: '../foo'> |
1433 >>> url(r'c:\foo\bar') | 1433 >>> url(r'c:\foo\bar') |
1434 <url path: 'c:\\foo\\bar'> | 1434 <url path: 'c:\\foo\\bar'> |
1435 >>> url(r'\\blah\blah\blah') | 1435 >>> url(r'\\blah\blah\blah') |
1436 <url path: '\\\\blah\\blah\\blah'> | 1436 <url path: '\\\\blah\\blah\\blah'> |
1437 >>> url(r'\\blah\blah\blah#baz') | |
1438 <url path: '\\\\blah\\blah\\blah', fragment: 'baz'> | |
1437 | 1439 |
1438 Authentication credentials: | 1440 Authentication credentials: |
1439 | 1441 |
1440 >>> url('ssh://joe:xyz@x/repo') | 1442 >>> url('ssh://joe:xyz@x/repo') |
1441 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> | 1443 <url scheme: 'ssh', user: 'joe', passwd: 'xyz', host: 'x', path: 'repo'> |
1459 self.scheme = self.user = self.passwd = self.host = None | 1461 self.scheme = self.user = self.passwd = self.host = None |
1460 self.port = self.path = self.query = self.fragment = None | 1462 self.port = self.path = self.query = self.fragment = None |
1461 self._localpath = True | 1463 self._localpath = True |
1462 self._hostport = '' | 1464 self._hostport = '' |
1463 self._origpath = path | 1465 self._origpath = path |
1466 | |
1467 if parsefragment and '#' in path: | |
1468 path, self.fragment = path.split('#', 1) | |
1469 if not path: | |
1470 path = None | |
1464 | 1471 |
1465 # special case for Windows drive letters and UNC paths | 1472 # special case for Windows drive letters and UNC paths |
1466 if hasdriveletter(path) or path.startswith(r'\\'): | 1473 if hasdriveletter(path) or path.startswith(r'\\'): |
1467 self.path = path | 1474 self.path = path |
1468 return | 1475 return |
1487 path = None | 1494 path = None |
1488 if self._localpath: | 1495 if self._localpath: |
1489 self.path = '' | 1496 self.path = '' |
1490 return | 1497 return |
1491 else: | 1498 else: |
1492 if parsefragment and '#' in path: | |
1493 path, self.fragment = path.split('#', 1) | |
1494 if not path: | |
1495 path = None | |
1496 if self._localpath: | 1499 if self._localpath: |
1497 self.path = path | 1500 self.path = path |
1498 return | 1501 return |
1499 | 1502 |
1500 if parsequery and '?' in path: | 1503 if parsequery and '?' in path: |