Mercurial > hgsubversion
changeset 140:9ffde8662967
util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 11 Dec 2008 20:41:57 -0600 |
parents | 89a737852d33 |
children | 6f2d67bf3039 |
files | __init__.py fetch_command.py tests/test_utility_commands.py util.py |
diffstat | 4 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py +++ b/__init__.py @@ -23,6 +23,7 @@ def svn_fetch(ui, svn_url, hg_repo_path= hg_repo_path = hg.defaultdest(svn_url) + "-hg" ui.status("Assuming destination %s\n" % hg_repo_path) should_update = not os.path.exists(hg_repo_path) + svn_url = util.normalize_url(svn_url) res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts) if (res is None or res == 0) and should_update: repo = hg.repository(ui, hg_repo_path)
--- a/fetch_command.py +++ b/fetch_command.py @@ -28,6 +28,7 @@ def fetch_revisions(ui, svn_url, hg_repo **opts): """Pull new revisions from Subversion. """ + svn_url = util.normalize_url(svn_url) old_encoding = merc_util._encoding merc_util._encoding = 'UTF-8' skipto_rev=int(skipto_rev)
--- a/tests/test_utility_commands.py +++ b/tests/test_utility_commands.py @@ -4,7 +4,7 @@ from mercurial import ui from mercurial import hg import utility_commands - +import fetch_command import test_util expected_info_output = '''URL: file://%(repo)s/%(branch)s @@ -48,3 +48,17 @@ class UtilityTests(test_util.TestBase): utility_commands.print_wc_url(u, self.repo, self.wc_path) expected = 'file://%s\n' % urllib.quote(self.repo_path) self.assertEqual(u.stream.getvalue(), expected) + + def test_url_is_normalized(self): + """Verify url gets normalized on initial clone. + """ + test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') + fetch_command.fetch_revisions(ui.ui(), + svn_url=test_util.fileurl(self.repo_path)+'/', + hg_repo_path=self.wc_path, + stupid=False) + hg.update(self.repo, 'tip') + u = ui.ui() + utility_commands.print_wc_url(u, self.repo, self.wc_path) + expected = 'file://%s\n' % urllib.quote(self.repo_path) + self.assertEqual(u.stream.getvalue(), expected)
--- a/util.py +++ b/util.py @@ -23,6 +23,12 @@ def generate_help(): return "\n".join(ret) + '\n' +def normalize_url(svn_url): + while svn_url[-1] == '/': + svn_url = svn_url[:-1] + return svn_url + + def wipe_all_files(hg_wc_path): files = [f for f in os.listdir(hg_wc_path) if f != '.hg'] for f in files: @@ -69,10 +75,10 @@ def parse_revmap(revmap_filename): class PrefixMatch(object): def __init__(self, prefix): self.p = prefix - + def files(self): return [] - + def __call__(self, fn): return fn.startswith(self.p)