2008-10-08 03:42:43 +04:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from mercurial import hg
|
|
|
|
from mercurial import node
|
2009-01-22 05:29:23 +03:00
|
|
|
from mercurial import ui
|
2008-10-08 03:42:43 +04:00
|
|
|
|
2008-10-08 07:13:14 +04:00
|
|
|
import test_util
|
2008-10-08 03:42:43 +04:00
|
|
|
|
2008-10-08 17:14:31 +04:00
|
|
|
|
2008-11-15 01:52:30 +03:00
|
|
|
class TestBasicRepoLayout(test_util.TestBase):
|
2008-10-08 03:42:43 +04:00
|
|
|
def test_fresh_fetch_single_rev(self):
|
2008-10-09 05:09:28 +04:00
|
|
|
repo = self._load_fixture_and_fetch('single_rev.svndump')
|
2008-10-09 03:17:29 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
|
|
|
self.assertEqual(repo['tip'].extra()['convert_revision'],
|
|
|
|
'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@2')
|
2008-10-08 03:42:43 +04:00
|
|
|
self.assertEqual(repo['tip'], repo[0])
|
|
|
|
|
|
|
|
def test_fresh_fetch_two_revs(self):
|
2008-10-09 05:09:28 +04:00
|
|
|
repo = self._load_fixture_and_fetch('two_revs.svndump')
|
2008-10-08 03:42:43 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self.assertEqual(node.hex(repo[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-08 03:42:43 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'c95251e0dd04697deee99b79cc407d7db76e6a5f')
|
2008-10-08 03:42:43 +04:00
|
|
|
self.assertEqual(repo['tip'], repo[1])
|
2008-10-08 05:43:44 +04:00
|
|
|
|
|
|
|
def test_branches(self):
|
2008-10-09 05:09:28 +04:00
|
|
|
repo = self._load_fixture_and_fetch('simple_branch.svndump')
|
2008-10-08 05:43:44 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self.assertEqual(node.hex(repo[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(len(repo['tip'].parents()), 1)
|
|
|
|
self.assertEqual(repo['tip'].parents()[0], repo['default'])
|
2008-12-23 20:10:32 +03:00
|
|
|
self.assertEqual(repo['tip'].extra()['convert_revision'],
|
|
|
|
'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@4')
|
|
|
|
self.assertEqual(repo['default'].extra()['convert_revision'],
|
|
|
|
'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@3')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(len(repo.heads()), 1)
|
|
|
|
|
|
|
|
def test_two_branches_with_heads(self):
|
2008-10-09 05:09:28 +04:00
|
|
|
repo = self._load_fixture_and_fetch('two_heads.svndump')
|
2008-10-08 05:43:44 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self.assertEqual(node.hex(repo[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'4e256962fc5df545e2e0a51d0d1dc61c469127e6')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
|
2008-10-08 05:43:44 +04:00
|
|
|
self.assertEqual(len(repo['tip'].parents()), 1)
|
|
|
|
self.assertEqual(repo['tip'], repo['default'])
|
|
|
|
self.assertEqual(len(repo.heads()), 2)
|
2008-10-08 07:13:14 +04:00
|
|
|
|
2008-10-09 03:17:29 +04:00
|
|
|
def test_many_special_cases_replay(self):
|
2008-10-09 05:09:28 +04:00
|
|
|
repo = self._load_fixture_and_fetch('many_special_cases.svndump')
|
2008-10-09 03:17:29 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self._many_special_cases_checks(repo)
|
|
|
|
|
|
|
|
|
|
|
|
def test_many_special_cases_diff(self):
|
2008-12-12 02:19:43 +03:00
|
|
|
repo = self._load_fixture_and_fetch('many_special_cases.svndump',
|
|
|
|
stupid=True)
|
2008-10-09 03:17:29 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self._many_special_cases_checks(repo)
|
|
|
|
|
|
|
|
def _many_special_cases_checks(self, repo):
|
|
|
|
self.assertEqual(node.hex(repo[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-09 03:17:29 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'b7bdc73041b1852563deb1ef3f4153c2fe4484f2')
|
2008-10-09 03:17:29 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'4e256962fc5df545e2e0a51d0d1dc61c469127e6')
|
2008-10-09 03:17:29 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
|
2008-10-09 03:17:29 +04:00
|
|
|
self.assertEqual(len(repo['tip'].parents()), 1)
|
|
|
|
self.assertEqual(repo['tip'], repo['default'])
|
|
|
|
self.assertEqual(len(repo.heads()), 2)
|
|
|
|
|
2008-10-27 06:12:46 +03:00
|
|
|
def test_file_mixed_with_branches(self):
|
|
|
|
repo = self._load_fixture_and_fetch('file_mixed_with_branches.svndump')
|
2009-03-03 08:58:38 +03:00
|
|
|
self.assertEqual(node.hex(repo['default'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-27 06:12:46 +03:00
|
|
|
assert 'README' not in repo
|
2009-03-03 08:58:38 +03:00
|
|
|
self.assertEqual(repo['tip'].branch(),
|
|
|
|
'../branches')
|
|
|
|
|
2008-10-27 06:12:46 +03:00
|
|
|
|
2008-10-27 06:39:17 +03:00
|
|
|
def test_files_copied_from_outside_btt(self):
|
|
|
|
repo = self._load_fixture_and_fetch(
|
|
|
|
'test_files_copied_from_outside_btt.svndump')
|
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'3c78170e30ddd35f2c32faa0d8646ab75bba4f73')
|
2009-03-28 00:56:07 +03:00
|
|
|
self.assertEqual(len(repo.changelog), 3)
|
2008-10-09 03:17:29 +04:00
|
|
|
|
2008-10-27 20:33:52 +03:00
|
|
|
def test_file_renamed_in_from_outside_btt(self):
|
|
|
|
repo = self._load_fixture_and_fetch(
|
|
|
|
'file_renamed_in_from_outside_btt.svndump')
|
2009-03-28 00:56:07 +03:00
|
|
|
self.assert_('LICENSE.file' in repo['default'])
|
2008-10-27 20:33:52 +03:00
|
|
|
|
2008-11-26 01:21:57 +03:00
|
|
|
def test_renamed_dir_in_from_outside_btt_not_repo_root(self):
|
|
|
|
repo = self._load_fixture_and_fetch(
|
|
|
|
'fetch_missing_files_subdir.svndump', subdir='foo')
|
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'269dcdd4361b2847e9f4288d4500e55d35df1f52')
|
2008-11-26 01:21:57 +03:00
|
|
|
self.assert_('bar/alpha' in repo['tip'])
|
|
|
|
self.assert_('foo' in repo['tip'])
|
|
|
|
self.assert_('bar/alpha' not in repo['tip'].parents()[0])
|
|
|
|
self.assert_('foo' in repo['tip'].parents()[0])
|
|
|
|
|
2008-11-05 01:38:16 +03:00
|
|
|
def test_oldest_not_trunk_and_tag_vendor_branch(self):
|
|
|
|
repo = self._load_fixture_and_fetch(
|
|
|
|
'tagged_vendor_and_oldest_not_trunk.svndump')
|
|
|
|
self.assertEqual(node.hex(repo['oldest'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'926671740dec045077ab20f110c1595f935334fa')
|
2008-11-05 01:38:16 +03:00
|
|
|
self.assertEqual(repo['tip'].parents()[0].parents()[0],
|
|
|
|
repo['oldest'])
|
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
|
2008-11-25 18:45:38 +03:00
|
|
|
|
2008-12-12 02:34:33 +03:00
|
|
|
def test_propedit_with_nothing_else(self, stupid=False):
|
|
|
|
repo = self._load_fixture_and_fetch('branch_prop_edit.svndump',
|
|
|
|
stupid=stupid)
|
|
|
|
self.assertEqual(repo['tip'].description(), 'Commit bogus propchange.')
|
|
|
|
self.assertEqual(repo['tip'].branch(), 'dev_branch')
|
|
|
|
|
|
|
|
def test_propedit_with_nothing_else_stupid(self):
|
|
|
|
self.test_propedit_with_nothing_else(stupid=True)
|
|
|
|
|
2008-12-16 06:39:35 +03:00
|
|
|
def test_entry_deletion(self, stupid=False):
|
|
|
|
repo = self._load_fixture_and_fetch('delentries.svndump',
|
|
|
|
stupid=stupid)
|
|
|
|
files = list(sorted(repo['tip'].manifest()))
|
|
|
|
self.assertEqual(['aa', 'd1/c', 'd1/d2prefix'], files)
|
|
|
|
|
|
|
|
def test_entry_deletion_stupid(self):
|
|
|
|
self.test_entry_deletion(stupid=True)
|
|
|
|
|
2009-03-09 20:01:40 +03:00
|
|
|
def test_fetch_when_trunk_has_no_files(self, stupid=False):
|
|
|
|
repo = self._load_fixture_and_fetch('file_not_in_trunk_root.svndump', stupid=stupid)
|
|
|
|
print repo['tip'].branch()
|
|
|
|
print repo['tip']
|
|
|
|
print repo['tip'].files()
|
|
|
|
self.assertEqual(repo['tip'].branch(), 'default')
|
|
|
|
|
|
|
|
def test_fetch_when_trunk_has_no_files_stupid(self):
|
|
|
|
self.test_fetch_when_trunk_has_no_files(stupid=True)
|
2008-11-05 01:38:16 +03:00
|
|
|
|
2008-11-15 01:52:30 +03:00
|
|
|
class TestStupidPull(test_util.TestBase):
|
2008-10-08 17:14:31 +04:00
|
|
|
def test_stupid(self):
|
2008-11-10 03:08:35 +03:00
|
|
|
repo = test_util.load_fixture_and_fetch('two_heads.svndump',
|
|
|
|
self.repo_path,
|
|
|
|
self.wc_path,
|
|
|
|
True)
|
2008-10-08 17:14:31 +04:00
|
|
|
# TODO there must be a better way than repo[0] for this check
|
|
|
|
self.assertEqual(node.hex(repo[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'434ed487136c1b47c1e8f952edb4dc5a8e6328df')
|
2008-10-08 17:14:31 +04:00
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
|
2008-10-08 17:14:31 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'4e256962fc5df545e2e0a51d0d1dc61c469127e6')
|
|
|
|
self.assertEqual(repo['the_branch'].extra()['convert_revision'],
|
|
|
|
'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@5')
|
2008-10-08 17:14:31 +04:00
|
|
|
self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
|
2008-10-08 17:14:31 +04:00
|
|
|
self.assertEqual(len(repo['tip'].parents()), 1)
|
2008-12-23 20:10:32 +03:00
|
|
|
self.assertEqual(repo['default'].extra()['convert_revision'],
|
|
|
|
'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@6')
|
2008-10-08 17:14:31 +04:00
|
|
|
self.assertEqual(repo['tip'], repo['default'])
|
|
|
|
self.assertEqual(len(repo.heads()), 2)
|
|
|
|
|
2008-11-05 01:38:16 +03:00
|
|
|
def test_oldest_not_trunk_and_tag_vendor_branch(self):
|
2008-11-10 03:08:35 +03:00
|
|
|
repo = test_util.load_fixture_and_fetch(
|
|
|
|
'tagged_vendor_and_oldest_not_trunk.svndump',
|
|
|
|
self.repo_path,
|
|
|
|
self.wc_path,
|
|
|
|
True)
|
2008-11-05 01:38:16 +03:00
|
|
|
repo = hg.repository(ui.ui(), self.wc_path)
|
|
|
|
self.assertEqual(node.hex(repo['oldest'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'926671740dec045077ab20f110c1595f935334fa')
|
2008-11-05 01:38:16 +03:00
|
|
|
self.assertEqual(repo['tip'].parents()[0].parents()[0],
|
|
|
|
repo['oldest'])
|
|
|
|
self.assertEqual(node.hex(repo['tip'].node()),
|
2008-12-23 20:10:32 +03:00
|
|
|
'1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
|
2008-11-05 01:38:16 +03:00
|
|
|
|
2008-10-08 07:13:14 +04:00
|
|
|
def suite():
|
2008-10-08 17:14:31 +04:00
|
|
|
all = [unittest.TestLoader().loadTestsFromTestCase(TestBasicRepoLayout),
|
|
|
|
unittest.TestLoader().loadTestsFromTestCase(TestStupidPull),
|
|
|
|
]
|
|
|
|
return unittest.TestSuite(all)
|