# HG changeset patch # User Patrick Mezard # Date 1247967873 18000 # Node ID 037bba1c673617b2582caf206ef02de0b5fda8be # Parent 3941d73c262ee115dd6b995c9a5fde10c1622b07 svnrepo: expose the same svnurl than SubversionRepo Since the ssh+svn URLs depend on supplied credentials, and because we want to get the actual SVN URL without talking to the remote repository, we duplicate the work done by SubversionRepo. diff --git a/hgsubversion/svnrepo.py b/hgsubversion/svnrepo.py --- a/hgsubversion/svnrepo.py +++ b/hgsubversion/svnrepo.py @@ -76,18 +76,24 @@ class svnremoterepo(mercurial.repo.repos self.capabilities = set(['lookup', 'subversion']) @propertycache - def svnurl(self): - return util.normalize_url(self.path) - - @propertycache - def svn(self): + def svnauth(self): # DO NOT default the user to hg's getuser(). If you provide # *any* default username to Subversion, it won't use any remembered # username for the desired realm, breaking OS X Keychain support, # GNOME keyring support, and all similar tools. user = self.ui.config('hgsubversion', 'username') passwd = self.ui.config('hgsubversion', 'password') - return svnwrap.SubversionRepo(self.svnurl, user, passwd) + url = util.normalize_url(self.path) + user, passwd, url = svnwrap.parse_url(url, user, passwd) + return url, user, passwd + + @property + def svnurl(self): + return self.svnauth[0] + + @propertycache + def svn(self): + return svnwrap.SubversionRepo(*self.svnauth) @property def svnuuid(self): diff --git a/tests/test_urls.py b/tests/test_urls.py --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -1,6 +1,7 @@ import test_util import unittest from hgsubversion.svnwrap.svn_swig_wrapper import parse_url +from hgsubversion import svnrepo class TestSubversionUrls(test_util.TestBase): def test_standard_url(self): @@ -45,6 +46,12 @@ class TestSubversionUrls(test_util.TestB ('bob', '123abc', 'https://svn.testurl.com/repo'), parse_url('https://joe:t3stpw@svn.testurl.com/repo', 'bob', '123abc')) +class TestSvnRepo(test_util.TestBase): + def test_url_rewriting(self): + ui = test_util.ui.ui() + ui.setconfig('hgsubversion', 'username', 'bob') + repo = svnrepo.svnremoterepo(ui, 'svn+ssh://joe@foo/bar') + self.assertEqual('svn+ssh://bob@foo/bar', repo.svnurl) def suite(): all = [unittest.TestLoader().loadTestsFromTestCase(TestSubversionUrls)]