comparison mercurial/util.py @ 14999:f6a737357195

merge with stable
author Matt Mackall <mpm@selenic.com>
date Mon, 01 Aug 2011 10:54:34 -0500
parents b7dbe957585c e6730f9e13bc
children c3114acd8ea2
comparison
equal deleted inserted replaced
14995:8d928799dab5 14999:f6a737357195
1498 self.host not in ('localhost', '127.0.0.1', '[::1]')): 1498 self.host not in ('localhost', '127.0.0.1', '[::1]')):
1499 raise Abort(_('file:// URLs can only refer to localhost')) 1499 raise Abort(_('file:// URLs can only refer to localhost'))
1500 1500
1501 self.path = path 1501 self.path = path
1502 1502
1503 # leave the query string escaped
1503 for a in ('user', 'passwd', 'host', 'port', 1504 for a in ('user', 'passwd', 'host', 'port',
1504 'path', 'query', 'fragment'): 1505 'path', 'fragment'):
1505 v = getattr(self, a) 1506 v = getattr(self, a)
1506 if v is not None: 1507 if v is not None:
1507 setattr(self, a, _urlunquote(v)) 1508 setattr(self, a, _urlunquote(v))
1508 1509
1509 def __repr__(self): 1510 def __repr__(self):
1520 1521
1521 Examples: 1522 Examples:
1522 1523
1523 >>> str(url('http://user:pw@host:80/?foo#bar')) 1524 >>> str(url('http://user:pw@host:80/?foo#bar'))
1524 'http://user:pw@host:80/?foo#bar' 1525 'http://user:pw@host:80/?foo#bar'
1526 >>> str(url('http://user:pw@host:80/?foo=bar&baz=42'))
1527 'http://user:pw@host:80/?foo=bar&baz=42'
1528 >>> str(url('http://user:pw@host:80/?foo=bar%3dbaz'))
1529 'http://user:pw@host:80/?foo=bar%3dbaz'
1525 >>> str(url('ssh://user:pw@[::1]:2200//home/joe#')) 1530 >>> str(url('ssh://user:pw@[::1]:2200//home/joe#'))
1526 'ssh://user:pw@[::1]:2200//home/joe#' 1531 'ssh://user:pw@[::1]:2200//home/joe#'
1527 >>> str(url('http://localhost:80//')) 1532 >>> str(url('http://localhost:80//'))
1528 'http://localhost:80//' 1533 'http://localhost:80//'
1529 >>> str(url('http://localhost:80/')) 1534 >>> str(url('http://localhost:80/'))
1568 if self.port: 1573 if self.port:
1569 s += ':' + urllib.quote(self.port) 1574 s += ':' + urllib.quote(self.port)
1570 if self.host: 1575 if self.host:
1571 s += '/' 1576 s += '/'
1572 if self.path: 1577 if self.path:
1578 # TODO: similar to the query string, we should not unescape the
1579 # path when we store it, the path might contain '%2f' = '/',
1580 # which we should *not* escape.
1573 s += urllib.quote(self.path, safe=self._safepchars) 1581 s += urllib.quote(self.path, safe=self._safepchars)
1574 if self.query: 1582 if self.query:
1575 s += '?' + urllib.quote(self.query, safe=self._safepchars) 1583 # we store the query in escaped form.
1584 s += '?' + self.query
1576 if self.fragment is not None: 1585 if self.fragment is not None:
1577 s += '#' + urllib.quote(self.fragment, safe=self._safepchars) 1586 s += '#' + urllib.quote(self.fragment, safe=self._safepchars)
1578 return s 1587 return s
1579 1588
1580 def authinfo(self): 1589 def authinfo(self):