comparison 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
comparison
equal deleted inserted replaced
312:4dc197f533c1 313:942f198b8ff5
7 import test_util 7 import test_util
8 import wrappers 8 import wrappers
9 9
10 10
11 class TestFetchBranches(test_util.TestBase): 11 class TestFetchBranches(test_util.TestBase):
12 def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True): 12 def _load_fixture_and_fetch(self, fixture_name, stupid, noupdate=True,
13 subdir=''):
13 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, 14 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
14 self.wc_path, stupid=stupid, 15 self.wc_path, stupid=stupid,
15 noupdate=noupdate) 16 noupdate=noupdate, subdir=subdir)
16 17
17 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor): 18 def _load_fixture_and_fetch_with_anchor(self, fixture_name, anchor):
18 test_util.load_svndump_fixture(self.repo_path, fixture_name) 19 test_util.load_svndump_fixture(self.repo_path, fixture_name)
19 source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor) 20 source = '%s#%s' % (test_util.fileurl(self.repo_path), anchor)
20 wrappers.clone(None, ui.ui(), source=source, dest=self.wc_path) 21 wrappers.clone(None, ui.ui(), source=source, dest=self.wc_path)
82 repo = self._load_fixture_and_fetch_with_anchor( 83 repo = self._load_fixture_and_fetch_with_anchor(
83 'unorderedbranch.svndump', 'branch') 84 'unorderedbranch.svndump', 'branch')
84 self.assertEqual(repo[None].branch(), 'branch') 85 self.assertEqual(repo[None].branch(), 'branch')
85 self.assertEqual(repo[None].parents()[0], repo[repo.branchheads()[0]]) 86 self.assertEqual(repo[None].parents()[0], repo[repo.branchheads()[0]])
86 87
88 def test_branches_weird_moves(self, stupid=False):
89 repo = self._load_fixture_and_fetch('renamedproject.svndump', stupid,
90 subdir='project')
91 heads = [repo[n] for n in repo.heads()]
92 heads = dict((ctx.branch(), ctx) for ctx in heads)
93 mdefault = sorted(heads['default'].manifest().keys())
94 mbranch = sorted(heads['branch'].manifest().keys())
95 self.assertEqual(mdefault, ['a', 'b', 'd/a'])
96 self.assertEqual(mbranch, ['a'])
97
98 def test_branches_weird_moves_stupid(self):
99 self.test_branches_weird_moves(True)
100
87 def suite(): 101 def suite():
88 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches), 102 all = [unittest.TestLoader().loadTestsFromTestCase(TestFetchBranches),
89 ] 103 ]
90 return unittest.TestSuite(all) 104 return unittest.TestSuite(all)