comparison mercurial/util.py @ 15611:ec8a49c46d7e

merge with stable
author Matt Mackall <mpm@selenic.com>
date Mon, 05 Dec 2011 17:48:40 -0600
parents 646759147717 8f4bad72d8b1
children 4f5a78fa4917
comparison
equal deleted inserted replaced
15606:2ad4e9b44d8b 15611:ec8a49c46d7e
1627 'bundle:../foo' 1627 'bundle:../foo'
1628 >>> str(url('path')) 1628 >>> str(url('path'))
1629 'path' 1629 'path'
1630 >>> str(url('file:///tmp/foo/bar')) 1630 >>> str(url('file:///tmp/foo/bar'))
1631 'file:///tmp/foo/bar' 1631 'file:///tmp/foo/bar'
1632 >>> str(url('file:///c:/tmp/foo/bar'))
1633 'file:///c:/tmp/foo/bar'
1632 >>> print url(r'bundle:foo\bar') 1634 >>> print url(r'bundle:foo\bar')
1633 bundle:foo\bar 1635 bundle:foo\bar
1634 """ 1636 """
1635 if self._localpath: 1637 if self._localpath:
1636 s = self.path 1638 s = self.path
1641 return s 1643 return s
1642 1644
1643 s = self.scheme + ':' 1645 s = self.scheme + ':'
1644 if self.user or self.passwd or self.host: 1646 if self.user or self.passwd or self.host:
1645 s += '//' 1647 s += '//'
1646 elif self.scheme and (not self.path or self.path.startswith('/')): 1648 elif self.scheme and (not self.path or self.path.startswith('/')
1649 or hasdriveletter(self.path)):
1647 s += '//' 1650 s += '//'
1651 if hasdriveletter(self.path):
1652 s += '/'
1648 if self.user: 1653 if self.user:
1649 s += urllib.quote(self.user, safe=self._safechars) 1654 s += urllib.quote(self.user, safe=self._safechars)
1650 if self.passwd: 1655 if self.passwd:
1651 s += ':' + urllib.quote(self.passwd, safe=self._safechars) 1656 s += ':' + urllib.quote(self.passwd, safe=self._safechars)
1652 if self.user or self.passwd: 1657 if self.user or self.passwd:
1714 1719
1715 def hasscheme(path): 1720 def hasscheme(path):
1716 return bool(url(path).scheme) 1721 return bool(url(path).scheme)
1717 1722
1718 def hasdriveletter(path): 1723 def hasdriveletter(path):
1719 return path[1:2] == ':' and path[0:1].isalpha() 1724 return path and path[1:2] == ':' and path[0:1].isalpha()
1720 1725
1721 def urllocalpath(path): 1726 def urllocalpath(path):
1722 return url(path, parsequery=False, parsefragment=False).localpath() 1727 return url(path, parsequery=False, parsefragment=False).localpath()
1723 1728
1724 def hidepassword(u): 1729 def hidepassword(u):