diff hgsubversion/util.py @ 555:cbd7065e6ab4

util: add parseurl method to abstract away differences between 1.4 and 1.5
author Augie Fackler <durin42@gmail.com>
date Sun, 07 Feb 2010 08:43:32 -0600
parents ac9c9e1a8022
children 35529f736fa2
line wrap: on
line diff
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -78,13 +78,27 @@ def version(ui):
 def normalize_url(url):
     if url.startswith('svn+http://') or url.startswith('svn+https://'):
         url = url[4:]
-    url, revs, checkout = hg.parseurl(url)
+    url, revs, checkout = parseurl(url)
     url = url.rstrip('/')
     if checkout:
         url = '%s#%s' % (url, checkout)
     return url
 
 
+def parseurl(url, heads=[]):
+    parsed = hg.parseurl(url, heads)
+    if len(parsed) == 3:
+        # old hg, remove when we can be 1.5-only
+        svn_url, heads, checkout = parsed
+    else:
+        svn_url, heads = parsed
+        if heads:
+            checkout = heads[0]
+        else:
+            checkout = None
+    return svn_url, heads, checkout
+
+
 class PrefixMatch(object):
     def __init__(self, prefix):
         self.p = prefix