changeset 636:d4f433ee709a

branchmap: reject empty mappings
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 10 Jul 2010 14:48:57 +0200
parents e2c3349b2cca
children 92f4a4b60696
files hgsubversion/maps.py tests/test_fetch_mappings.py
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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)