# HG changeset patch # User Peter Arrenbrecht # Date 1305211316 -7200 # Node ID a389dd2852825d153ad96af4fbf71fe157a0e04d # Parent ba883fa211f336cd98bcec44ae6952f4e65ba972 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 diff -r ba883fa211f3 -r a389dd285282 mercurial/util.py --- a/mercurial/util.py Thu May 12 18:35:04 2011 -0500 +++ b/mercurial/util.py Thu May 12 16:41:56 2011 +0200 @@ -1500,6 +1500,8 @@ 'bundle:../foo' >>> str(url('path')) 'path' + >>> str(url('file:///tmp/foo/bar')) + 'file:///tmp/foo/bar' >>> print url(r'bundle:foo\bar') bundle:foo\bar """ @@ -1512,8 +1514,9 @@ return s s = self.scheme + ':' - if (self.user or self.passwd or self.host or - self.scheme and not self.path): + if self.user or self.passwd or self.host: + s += '//' + elif self.scheme and (not self.path or self.path.startswith('/')): s += '//' if self.user: s += urllib.quote(self.user, safe=self._safechars) diff -r ba883fa211f3 -r a389dd285282 tests/test-url.py --- a/tests/test-url.py Thu May 12 18:35:04 2011 -0500 +++ b/tests/test-url.py Thu May 12 16:41:56 2011 +0200 @@ -191,11 +191,23 @@ >>> str(u) 'http://foo/bar' + >>> u = url('file:/foo/bar/baz') + >>> u + + >>> str(u) + 'file:///foo/bar/baz' + >>> u = url('file:///foo/bar/baz') >>> u >>> str(u) - 'file:/foo/bar/baz' + 'file:///foo/bar/baz' + + >>> u = url('file:foo/bar/baz') + >>> u + + >>> str(u) + 'file:foo/bar/baz' """ doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)