changeset 702:841399d10c79

verify: fix verifying mapped branches.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Tue, 07 Sep 2010 14:33:56 +0200
parents 3b8088de027d
children ccac5ac68e71
files hgsubversion/svncommands.py tests/test_fetch_mappings.py
diffstat 2 files changed, 33 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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