changeset 13897:375872fdadba

hg: make parseurl() consistently return normalised path Before this the path was only normalised when a fragment was used.
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 06 Apr 2011 12:48:59 +0200
parents 3b4025dcb223
children 77b09a7fc8fc
files mercurial/hg.py tests/test-hg-parseurl.py tests/test-hg-parseurl.py.out
diffstat 3 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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', [])