Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/util.py @ 14313:a389dd285282
util: make str(url) return file:/// for abs paths again
str(url) was recently changed to return only file:/. However, the
canonical way to represent absolute local paths is file:/// [1], which
is also expected by at least hgsubversion.
Relative paths are returned as file:the/relative/path.
[1] http://en.wikipedia.org/wiki/File_URI_scheme
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Thu, 12 May 2011 16:41:56 +0200 |
parents | 4030630fb59c |
children | 76f295eaed86 |
comparison
equal
deleted
inserted
replaced
14312:ba883fa211f3 | 14313:a389dd285282 |
---|---|
1498 'bundle:foo' | 1498 'bundle:foo' |
1499 >>> str(url('bundle://../foo')) | 1499 >>> str(url('bundle://../foo')) |
1500 'bundle:../foo' | 1500 'bundle:../foo' |
1501 >>> str(url('path')) | 1501 >>> str(url('path')) |
1502 'path' | 1502 'path' |
1503 >>> str(url('file:///tmp/foo/bar')) | |
1504 'file:///tmp/foo/bar' | |
1503 >>> print url(r'bundle:foo\bar') | 1505 >>> print url(r'bundle:foo\bar') |
1504 bundle:foo\bar | 1506 bundle:foo\bar |
1505 """ | 1507 """ |
1506 if self._localpath: | 1508 if self._localpath: |
1507 s = self.path | 1509 s = self.path |
1510 if self.fragment: | 1512 if self.fragment: |
1511 s += '#' + self.fragment | 1513 s += '#' + self.fragment |
1512 return s | 1514 return s |
1513 | 1515 |
1514 s = self.scheme + ':' | 1516 s = self.scheme + ':' |
1515 if (self.user or self.passwd or self.host or | 1517 if self.user or self.passwd or self.host: |
1516 self.scheme and not self.path): | 1518 s += '//' |
1519 elif self.scheme and (not self.path or self.path.startswith('/')): | |
1517 s += '//' | 1520 s += '//' |
1518 if self.user: | 1521 if self.user: |
1519 s += urllib.quote(self.user, safe=self._safechars) | 1522 s += urllib.quote(self.user, safe=self._safechars) |
1520 if self.passwd: | 1523 if self.passwd: |
1521 s += ':' + urllib.quote(self.passwd, safe=self._safechars) | 1524 s += ':' + urllib.quote(self.passwd, safe=self._safechars) |