Mercurial > hgsubversion
changeset 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 | d2d5c09b33d0 |
children | 8522f8ef799e |
files | hgsubversion/util.py hgsubversion/wrappers.py |
diffstat | 2 files changed, 18 insertions(+), 4 deletions(-) [+] |
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
--- a/hgsubversion/wrappers.py +++ b/hgsubversion/wrappers.py @@ -57,7 +57,7 @@ def incoming(orig, ui, repo, source='def """show incoming revisions from Subversion """ - source, revs, checkout = hg.parseurl(ui.expandpath(source)) + source, revs, checkout = util.parseurl(ui.expandpath(source)) other = hg.repository(ui, source) if 'subversion' not in other.capabilities: return orig(ui, repo, source, **opts) @@ -81,7 +81,7 @@ def outgoing(repo, dest=None, heads=None assert dest.capable('subversion') # split off #rev; TODO implement --revision/#rev support - svnurl, revs, checkout = hg.parseurl(dest.svnurl, heads) + svnurl, revs, checkout = util.parseurl(dest.svnurl, heads) meta = repo.svnmeta() parent = repo.parents()[0].node() hashes = meta.revmap.hashes() @@ -210,7 +210,7 @@ def pull(repo, source, heads=[], force=F svn_url = source.svnurl # Split off #rev - svn_url, heads, checkout = hg.parseurl(svn_url, heads) + svn_url, heads, checkout = util.parseurl(svn_url, heads) old_encoding = util.swap_out_encoding() # TODO implement skipto support