diff tests/test_fetch_branches.py @ 313:942f198b8ff5

hg_delta_editor: detect new branches issued from non-branch directories This fix solves the following case: let's /dumb/layout/project be an existing project. To normalize the trunk/branches/tags layout, people may do: $ mkdir /project $ mv /dumb/layout/project /project/project # Oups, should have been trunk! $ mv /project/project /project/trunk trunk creation was ignore because: - update_branch_map() sees it come from a non-branch copy source and ignores it (case #3). - since it is not in self.branches, add_directory() ignores the non-existing path. Then trunk is left uninitialized. To solve this, we allow update_branch_map() to detect branches copied from non-canonical locations.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 03 May 2009 21:42:42 -0500
parents f8f9a2993705
children 33736e2e25f0
line wrap: on
line diff
--- a/tests/test_fetch_branches.py
+++ b/tests/test_fetch_branches.py
@@ -9,10 +9,11 @@ import wrappers
 
 
 class TestFetchBranches(test_util.TestBase):
-    def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True):
+    def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True,
+                                subdir=''):
         return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
                                                 self.wc_path, stupid=stupid,
-                                                noupdate=noupdate)
+                                                noupdate=noupdate, subdir=subdir)
 
     def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor):
         test_util.load_svndump_fixture(self.repo_path, fixture_name)
@@ -84,6 +85,19 @@ class TestFetchBranches(test_util.TestBa
         self.assertEqual(repo[None].branch(), 'branch')
         self.assertEqual(repo[None].parents()[0], repo[repo.branchheads()[0]])
 
+    def test_branches_weird_moves(self, stupid=False):
+        repo = self._load_fixture_and_fetch('renamedproject.svndump', stupid,
+                                            subdir='project')
+        heads = [repo[n] for n in repo.heads()]
+        heads = dict((ctx.branch(), ctx) for ctx in heads)
+        mdefault = sorted(heads['default'].manifest().keys())
+        mbranch = sorted(heads['branch'].manifest().keys())
+        self.assertEqual(mdefault, ['a', 'b', 'd/a'])
+        self.assertEqual(mbranch, ['a'])
+
+    def test_branches_weird_moves_stupid(self):
+        self.test_branches_weird_moves(True)
+
 def suite():
     all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches),
           ]