# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1278766137 -7200 # Node ID d4f433ee709ab327b4b5f426a65cc2a7a03c079c # Parent e2c3349b2cca4823e3de84a74b7d2db4ef91d7e5 branchmap: reject empty mappings diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -339,7 +339,13 @@ class BranchMap(dict): src = src.strip() dst = dst.strip() self.ui.debug('adding branch %s to branch map\n' % src) - if src in self and dst != self[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]: msg = 'overriding branch: "%s" to "%s" (%s)\n' self.ui.status(msg % (self[src], dst, src)) self[src] = dst 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 @@ -5,6 +5,7 @@ import unittest from mercurial import commands from mercurial import node +from mercurial import util as hgutil import test_util @@ -151,5 +152,20 @@ class MapTests(test_util.TestBase): '''test mapping an empty commit on a renamed branch (stupid)''' self.test_branchmap_empty_commit(True) + def test_branchmap_no_replacement(self): + ''' + test that empty mappings are rejected + + Empty mappings are lines like 'this ='. The most sensible thing to do + is to not convert the 'this' branches. Until we can do that, we settle + with aborting. + ''' + test_util.load_svndump_fixture(self.repo_path, 'propset-branch.svndump') + branchmap = open(self.branchmap, 'w') + branchmap.write("closeme =\n") + branchmap.close() + self.assertRaises(hgutil.Abort, + maps.BranchMap, self.ui(), self.branchmap) + def suite(): return unittest.TestLoader().loadTestsFromTestCase(MapTests)