Mercurial > hgsubversion
changeset 1356:57d65269d30c
maps: allow an empty map to not convert specific branches
The test, test_fetch_mappings, has been updated as well.
author | Sean Farley <sean@farley.io> |
---|---|
date | Mon, 24 Mar 2014 11:20:57 -0500 |
parents | 79e319fe767d |
children | d28bfd2c6e32 |
files | hgsubversion/editor.py hgsubversion/maps.py hgsubversion/replay.py hgsubversion/stupid.py tests/test_fetch_mappings.py |
diffstat | 5 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -578,6 +578,12 @@ class HgEditor(svnwrap.Editor): try: if not self.meta.is_path_valid(path): return + + # are we skipping this branch entirely? + br_path, branch = self.meta.split_branch_path(path)[:2] + if self.meta.skipbranch(branch): + return + try: handler(window) except AssertionError, e: # pragma: no cover
--- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -425,12 +425,7 @@ class BranchMap(dict): dst = dst.strip() self.meta.ui.debug('adding branch %s to branch map\n' % src) - if not dst: - # prevent people from assuming such lines are valid - raise hgutil.Abort('removing branches is not supported, yet\n' - '(line %i in branch map %s)' - % (number, path)) - elif src in self and dst != self[src]: + if dst and src in self and dst != self[src]: msg = 'overriding branch: "%s" to "%s" (%s)\n' self.meta.ui.status(msg % (self[src], dst, src)) self[src] = dst
--- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -121,6 +121,12 @@ def _convert_rev(ui, meta, svn, r, tbdel if branch in current.emptybranches and files: del current.emptybranches[branch] + if meta.skipbranch(branch): + # make sure we also get rid of it from emptybranches + if branch in current.emptybranches: + del current.emptybranches[branch] + continue + files = dict(files) parents = meta.get_parent_revision(rev.revnum, branch), revlog.nullid if parents[0] in closedrevs and branch in meta.closebranches: @@ -195,6 +201,9 @@ def _convert_rev(ui, meta, svn, r, tbdel # 2. handle branches that need to be committed without any files for branch in current.emptybranches: + if meta.skipbranch(branch): + continue + ha = meta.get_parent_revision(rev.revnum, branch) if ha == node.nullid: continue
--- a/hgsubversion/stupid.py +++ b/hgsubversion/stupid.py @@ -684,6 +684,10 @@ def convert_rev(ui, meta, svn, r, tbdelt date = meta.fixdate(r.date) check_deleted_branches = set(tbdelta['branches'][1]) for b in branches: + + if meta.skipbranch(b): + continue + parentctx = meta.repo[meta.get_parent_revision(r.revnum, b)] tag = meta.get_path_tag(meta.remotename(b)) kind = svn.checkpath(branches[b], r.revnum)
--- a/tests/test_fetch_mappings.py +++ b/tests/test_fetch_mappings.py @@ -290,6 +290,23 @@ class MapTests(test_util.TestBase): for r in repo: self.assertEquals(verify.verify(ui, repo, rev=r), 0) + def test_branchmap_no_replacement(self): + '''test that empty mappings are accepted + + Empty mappings are lines like 'this ='. We check that such branches are + not converted. + ''' + repo_path = self.load_svndump('branchmap.svndump') + branchmap = open(self.branchmap, 'w') + branchmap.write("badname =\n") + branchmap.close() + ui = self.ui() + ui.setconfig('hgsubversion', 'branchmap', self.branchmap) + commands.clone(ui, test_util.fileurl(repo_path), + self.wc_path, branchmap=self.branchmap) + branches = set(self.repo[i].branch() for i in self.repo) + self.assertEquals(sorted(branches), ['default', 'feature']) + def test_tagmap(self): repo_path = self.load_svndump('basic_tag_tests.svndump') tagmap = open(self.tagmap, 'w')