# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1283862836 -7200 # Node ID 841399d10c79a4e9e3c998644f5a4be214f3d2a9 # Parent 3b8088de027dff1f167f4aeda061853579649135 verify: fix verifying mapped branches. diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -29,27 +29,27 @@ def verify(ui, repo, *args, **opts): if 'close' in ctx.extra(): ui.write('cannot verify closed branch') return 0 - srev = ctx.extra().get('convert_revision') - if srev is None: + convert_revision = ctx.extra().get('convert_revision') + if convert_revision is None or not convert_revision.startswith('svn:'): raise hgutil.Abort('revision %s not from SVN' % ctx) - srev = int(srev.split('@')[1]) - ui.write('verifying %s against r%i\n' % (ctx, srev)) - - url = repo.ui.expandpath('default') if args: - url = args[0] + url = repo.ui.expandpath(args[0]) + else: + url = repo.ui.expandpath('default') + svn = svnrepo.svnremoterepo(ui, url).svn meta = repo.svnmeta(svn.uuid, svn.subdir) + srev, branch, branchpath = meta.get_source_rev(ctx=ctx) + + branchpath = branchpath[len(svn.subdir.lstrip('/')):] + + ui.write('verifying %s against r%i\n' % (ctx, srev)) - btypes = {'default': 'trunk'} - if meta.layout == 'standard': - branchpath = btypes.get(ctx.branch(), 'branches/%s' % ctx.branch()) - else: - branchpath = '' svnfiles = set() result = 0 - for fn, type in svn.list_files(posixpath.normpath(branchpath), srev): + + for fn, type in svn.list_files(branchpath, srev): if type != 'f': continue svnfiles.add(fn) diff --git a/tests/test_fetch_mappings.py b/tests/test_fetch_mappings.py --- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -208,6 +208,26 @@ class MapTests(test_util.TestBase): '''test rebuildmeta on a branchmapped clone (stupid)''' self.test_branchmap_rebuildmeta(True) + def test_branchmap_verify(self, stupid=False): + '''test verify on a branchmapped clone''' + test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump') + branchmap = open(self.branchmap, 'w') + branchmap.write("badname = dit\n") + branchmap.write("feature = dah\n") + branchmap.close() + ui = self.ui(stupid) + ui.setconfig('hgsubversion', 'branchmap', self.branchmap) + commands.clone(ui, test_util.fileurl(self.repo_path), + self.wc_path, branchmap=self.branchmap) + repo = self.repo + + for r in repo: + self.assertEquals(svncommands.verify(ui, repo, rev=r), 0) + + def test_branchmap_verify_stupid(self): + '''test verify on a branchmapped clone (stupid)''' + self.test_branchmap_verify(True) + def test_branchmap_no_replacement(self): ''' test that empty mappings are rejected