hg: make parseurl() consistently return normalised path
authorThomas Arendsen Hein <thomas@intevation.de>
Wed, 06 Apr 2011 12:48:59 +0200
changeset 13897 375872fdadba
parent 13896 3b4025dcb223
child 13898 77b09a7fc8fc
hg: make parseurl() consistently return normalised path Before this the path was only normalised when a fragment was used.
mercurial/hg.py
tests/test-hg-parseurl.py
tests/test-hg-parseurl.py.out
--- a/mercurial/hg.py	Wed Apr 06 11:30:08 2011 +0100
+++ b/mercurial/hg.py	Wed Apr 06 12:48:59 2011 +0200
@@ -55,10 +55,10 @@
     '''parse url#branch, returning (url, (branch, branches))'''
 
     u = url.url(path)
-    if not u.fragment:
-        return path, (None, branches or [])
-    branch = u.fragment
-    u.fragment = None
+    branch = None
+    if u.fragment:
+        branch = u.fragment
+        u.fragment = None
     return str(u), (branch, branches or [])
 
 schemes = {
--- a/tests/test-hg-parseurl.py	Wed Apr 06 11:30:08 2011 +0100
+++ b/tests/test-hg-parseurl.py	Wed Apr 06 12:48:59 2011 +0200
@@ -8,3 +8,6 @@
 testparse('http://example.com/no/anchor/branches', branch=['foo'])
 testparse('http://example.com/an/anchor/branches#bar', branch=['foo'])
 testparse('http://example.com/an/anchor/branches-None#foo', branch=None)
+testparse('http://example.com/')
+testparse('http://example.com')
+testparse('http://example.com#foo')
--- a/tests/test-hg-parseurl.py.out	Wed Apr 06 11:30:08 2011 +0100
+++ b/tests/test-hg-parseurl.py.out	Wed Apr 06 12:48:59 2011 +0200
@@ -3,3 +3,6 @@
 http://example.com/no/anchor/branches, branches: (None, ['foo'])
 http://example.com/an/anchor/branches, branches: ('bar', ['foo'])
 http://example.com/an/anchor/branches-None, branches: ('foo', [])
+http://example.com/, branches: (None, [])
+http://example.com/, branches: (None, [])
+http://example.com/, branches: ('foo', [])