Mercurial > hgsubversion
comparison tests/test_fetch_command.py @ 21:8626f3d2e50b
Add a small stack of tests that exercise some of the interesting special cases.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Wed, 08 Oct 2008 18:17:29 -0500 |
| parents | f4c751037a4a |
| children | 95d0109e495e |
comparison
equal
deleted
inserted
replaced
| 20:2953c867ca99 | 21:8626f3d2e50b |
|---|---|
| 22 shutil.rmtree(self.tmpdir) | 22 shutil.rmtree(self.tmpdir) |
| 23 os.chdir(self.oldwd) | 23 os.chdir(self.oldwd) |
| 24 | 24 |
| 25 def test_fresh_fetch_single_rev(self): | 25 def test_fresh_fetch_single_rev(self): |
| 26 test_util.load_svndump_fixture(self.repo_path, 'single_rev.svndump') | 26 test_util.load_svndump_fixture(self.repo_path, 'single_rev.svndump') |
| 27 fetch_command.fetch_revisions(ui.ui(), | 27 fetch_command.fetch_revisions(ui.ui(), |
| 28 svn_url='file://%s' % self.repo_path, | 28 svn_url='file://%s' % self.repo_path, |
| 29 hg_repo_path=self.wc_path) | 29 hg_repo_path=self.wc_path) |
| 30 repo = hg.repository(ui.ui(), self.wc_path) | 30 repo = hg.repository(ui.ui(), self.wc_path) |
| 31 self.assertEqual(node.hex(repo['tip'].node()), | 31 self.assertEqual(node.hex(repo['tip'].node()), |
| 32 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') | 32 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
| 33 self.assertEqual(repo['tip'], repo[0]) | 33 self.assertEqual(repo['tip'], repo[0]) |
| 34 | 34 |
| 35 def test_fresh_fetch_two_revs(self): | 35 def test_fresh_fetch_two_revs(self): |
| 36 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') | 36 test_util.load_svndump_fixture(self.repo_path, 'two_revs.svndump') |
| 37 fetch_command.fetch_revisions(ui.ui(), | 37 fetch_command.fetch_revisions(ui.ui(), |
| 38 svn_url='file://%s' % self.repo_path, | 38 svn_url='file://%s' % self.repo_path, |
| 39 hg_repo_path=self.wc_path) | 39 hg_repo_path=self.wc_path) |
| 40 repo = hg.repository(ui.ui(), self.wc_path) | 40 repo = hg.repository(ui.ui(), self.wc_path) |
| 41 # TODO there must be a better way than repo[0] for this check | 41 # TODO there must be a better way than repo[0] for this check |
| 42 self.assertEqual(node.hex(repo[0].node()), | 42 self.assertEqual(node.hex(repo[0].node()), |
| 43 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') | 43 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
| 45 'bf3767835b3b32ecc775a298c2fa27134dd91c11') | 45 'bf3767835b3b32ecc775a298c2fa27134dd91c11') |
| 46 self.assertEqual(repo['tip'], repo[1]) | 46 self.assertEqual(repo['tip'], repo[1]) |
| 47 | 47 |
| 48 def test_branches(self): | 48 def test_branches(self): |
| 49 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') | 49 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') |
| 50 fetch_command.fetch_revisions(ui.ui(), | 50 fetch_command.fetch_revisions(ui.ui(), |
| 51 svn_url='file://%s' % self.repo_path, | 51 svn_url='file://%s' % self.repo_path, |
| 52 hg_repo_path=self.wc_path) | 52 hg_repo_path=self.wc_path) |
| 53 repo = hg.repository(ui.ui(), self.wc_path) | 53 repo = hg.repository(ui.ui(), self.wc_path) |
| 54 # TODO there must be a better way than repo[0] for this check | 54 # TODO there must be a better way than repo[0] for this check |
| 55 self.assertEqual(node.hex(repo[0].node()), | 55 self.assertEqual(node.hex(repo[0].node()), |
| 56 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') | 56 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
| 60 self.assertEqual(repo['tip'].parents()[0], repo['default']) | 60 self.assertEqual(repo['tip'].parents()[0], repo['default']) |
| 61 self.assertEqual(len(repo.heads()), 1) | 61 self.assertEqual(len(repo.heads()), 1) |
| 62 | 62 |
| 63 def test_two_branches_with_heads(self): | 63 def test_two_branches_with_heads(self): |
| 64 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') | 64 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') |
| 65 fetch_command.fetch_revisions(ui.ui(), | 65 fetch_command.fetch_revisions(ui.ui(), |
| 66 svn_url='file://%s' % self.repo_path, | 66 svn_url='file://%s' % self.repo_path, |
| 67 hg_repo_path=self.wc_path) | 67 hg_repo_path=self.wc_path) |
| 68 repo = hg.repository(ui.ui(), self.wc_path) | 68 repo = hg.repository(ui.ui(), self.wc_path) |
| 69 # TODO there must be a better way than repo[0] for this check | 69 # TODO there must be a better way than repo[0] for this check |
| 70 self.assertEqual(node.hex(repo[0].node()), | 70 self.assertEqual(node.hex(repo[0].node()), |
| 71 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') | 71 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
| 77 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') | 77 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') |
| 78 self.assertEqual(len(repo['tip'].parents()), 1) | 78 self.assertEqual(len(repo['tip'].parents()), 1) |
| 79 self.assertEqual(repo['tip'], repo['default']) | 79 self.assertEqual(repo['tip'], repo['default']) |
| 80 self.assertEqual(len(repo.heads()), 2) | 80 self.assertEqual(len(repo.heads()), 2) |
| 81 | 81 |
| 82 def test_many_special_cases_replay(self): | |
| 83 test_util.load_svndump_fixture(self.repo_path, | |
| 84 'many_special_cases.svndump') | |
| 85 fetch_command.fetch_revisions(ui.ui(), | |
| 86 svn_url='file://%s' % self.repo_path, | |
| 87 hg_repo_path=self.wc_path) | |
| 88 repo = hg.repository(ui.ui(), self.wc_path) | |
| 89 # TODO there must be a better way than repo[0] for this check | |
| 90 self._many_special_cases_checks(repo) | |
| 91 | |
| 92 | |
| 93 def test_many_special_cases_diff(self): | |
| 94 test_util.load_svndump_fixture(self.repo_path, | |
| 95 'many_special_cases.svndump') | |
| 96 fetch_command.fetch_revisions(ui.ui(), | |
| 97 svn_url='file://%s' % self.repo_path, | |
| 98 hg_repo_path=self.wc_path, | |
| 99 stupid = True) | |
| 100 repo = hg.repository(ui.ui(), self.wc_path) | |
| 101 # TODO there must be a better way than repo[0] for this check | |
| 102 self._many_special_cases_checks(repo) | |
| 103 | |
| 104 def _many_special_cases_checks(self, repo): | |
| 105 self.assertEqual(node.hex(repo[0].node()), | |
| 106 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') | |
| 107 self.assertEqual(node.hex(repo['tip'].node()), | |
| 108 'a7742757189db8aea5f4c6721cbbfb1a09f00ddf') | |
| 109 self.assertEqual(node.hex(repo['the_branch'].node()), | |
| 110 '8ccaba5f0eae124487e413abd904a013f7f6fdeb') | |
| 111 self.assertEqual(node.hex(repo['the_branch'].parents()[0].node()), | |
| 112 '9dfb0a19494f45c36e22f3c6d1b21d80638a7f6e') | |
| 113 self.assertEqual(len(repo['tip'].parents()), 1) | |
| 114 self.assertEqual(repo['tip'], repo['default']) | |
| 115 self.assertEqual(len(repo.heads()), 2) | |
| 116 | |
| 117 | |
| 118 | |
| 82 | 119 |
| 83 class TestStupidPull(unittest.TestCase): | 120 class TestStupidPull(unittest.TestCase): |
| 84 def setUp(self): | 121 def setUp(self): |
| 85 self.oldwd = os.getcwd() | 122 self.oldwd = os.getcwd() |
| 86 self.tmpdir = tempfile.mkdtemp('svnwrap_test') | 123 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
| 91 shutil.rmtree(self.tmpdir) | 128 shutil.rmtree(self.tmpdir) |
| 92 os.chdir(self.oldwd) | 129 os.chdir(self.oldwd) |
| 93 | 130 |
| 94 def test_stupid(self): | 131 def test_stupid(self): |
| 95 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') | 132 test_util.load_svndump_fixture(self.repo_path, 'two_heads.svndump') |
| 96 fetch_command.fetch_revisions(ui.ui(), | 133 fetch_command.fetch_revisions(ui.ui(), |
| 97 svn_url='file://%s' % self.repo_path, | 134 svn_url='file://%s' % self.repo_path, |
| 98 hg_repo_path=self.wc_path, | 135 hg_repo_path=self.wc_path, |
| 99 stupid=True) | 136 stupid=True) |
| 100 repo = hg.repository(ui.ui(), self.wc_path) | 137 repo = hg.repository(ui.ui(), self.wc_path) |
| 101 # TODO there must be a better way than repo[0] for this check | 138 # TODO there must be a better way than repo[0] for this check |
| 102 self.assertEqual(node.hex(repo[0].node()), | 139 self.assertEqual(node.hex(repo[0].node()), |
