Mercurial > hgsubversion
changeset 641:67513cca972f
rebuildmeta: handle mapped branch names.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 13 Jul 2010 12:19:16 +0200 |
parents | a3d20d6e96b0 |
children | c2d606a1dc6f |
files | hgsubversion/svncommands.py tests/test_fetch_mappings.py |
diffstat | 2 files changed, 56 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -219,15 +219,36 @@ def rebuildmeta(ui, repo, args, **opts): last_rev = revision # deal with branches - if ctx.extra().get('close'): - continue - branch = ctx.branch() - if branch == 'default': + if not commitpath: branch = None + elif not commitpath.startswith('../'): + branch = commitpath + elif ctx.parents()[0].node() != node.nullid: + parent = ctx + while parent.node() != node.nullid: + parentextra = parent.extra() + parentinfo = parentextra.get('convert_revision') + assert parentinfo + parent = parent.parents()[0] + + parentpath = parentinfo[40:].split('@')[0][len(subdir) + 1:] + + if parentpath.startswith('tags/') and parentextra.get('close'): + continue + elif parentpath.startswith('branches/'): branch = parentpath[len('branches/'):] + elif parentpath == 'trunk': + branch = None + else: + branch = '../' + parentpath + break + else: + branch = commitpath if rev in closed: # a direct child of this changeset closes the branch; drop it branchinfo.pop(branch, None) + elif ctx.extra().get('close'): + pass elif branch not in branchinfo: parent = ctx.parents()[0] if (parent.node() in noderevnums
--- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -4,12 +4,14 @@ import os import unittest from mercurial import commands +from mercurial import hg from mercurial import node from mercurial import util as hgutil import test_util from hgsubversion import maps +from hgsubversion import svncommands class MapTests(test_util.TestBase): @property @@ -177,6 +179,35 @@ class MapTests(test_util.TestBase): '''test combining two branches, but retaining heads (stupid)''' self.test_branchmap_combine(True) + def test_branchmap_rebuildmeta(self, stupid=False): + '''test rebuildmeta 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) + originfo = self.repo.svnmeta().branches + + # clone & rebuild + ui = self.ui(stupid) + src, dest = hg.clone(ui, self.wc_path, self.wc_path + '_clone', + update=False) + svncommands.rebuildmeta(ui, dest, + args=[test_util.fileurl(self.repo_path)]) + + # just check the keys; assume the contents are unaffected by the branch + # map and thus properly tested by other tests + self.assertEquals(sorted(src.svnmeta().branches), + sorted(dest.svnmeta().branches)) + + def test_branchmap_rebuildmeta_stupid(self): + '''test rebuildmeta on a branchmapped clone (stupid)''' + self.test_branchmap_rebuildmeta(True) + def test_branchmap_no_replacement(self): ''' test that empty mappings are rejected