Mercurial > hgsubversion
annotate tests/test_tags.py @ 24:5954a514ae26
Pushing fails in 1.4's SWIG bindings, so double check for that in the test.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Thu, 09 Oct 2008 23:36:20 -0500 |
parents | 1f8854804795 |
children | 9c481cae0428 |
rev | line source |
---|---|
23
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 import os |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import shutil |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import tempfile |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import unittest |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 from mercurial import hg |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from mercurial import node |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 from mercurial import ui |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import test_util |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 import svncommand |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 class TestTags(unittest.TestCase): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 def setUp(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 self.oldwd = os.getcwd() |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 self.tmpdir = tempfile.mkdtemp('svnwrap_test') |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 self.repo_path = '%s/testrepo' % self.tmpdir |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 self.wc_path = '%s/testrepo_wc' % self.tmpdir |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 def tearDown(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 shutil.rmtree(self.tmpdir) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 os.chdir(self.oldwd) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 def _load_fixture_and_fetch(self, fixture_name, stupid=False): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 return test_util.load_fixture_and_fetch(fixture_name, self.repo_path, |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 self.wc_path, stupid=stupid) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 def _test_tag_revision_info(self, repo): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 self.assertEqual(node.hex(repo[0].node()), |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 'a47d0ce778660a91c31bf2c21c448e9ee296ac90') |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 self.assertEqual(node.hex(repo['tip'].node()), |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 'bf3767835b3b32ecc775a298c2fa27134dd91c11') |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 self.assertEqual(repo['tip'], repo[1]) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 def test_tags(self, stupid=False): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 repo = self._load_fixture_and_fetch('basic_tag_tests.svndump', |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 stupid=stupid) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 self._test_tag_revision_info(repo) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 svncommand.generate_hg_tags(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 repo = hg.repository(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 self.assertEqual(repo['tip'].node(), repo['tag:tag_r3'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 self.assertEqual(repo['tip'].node(), repo['tag:copied_tag'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 def test_tags_stupid(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 self.test_tags(stupid=True) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 def test_remove_tag(self, stupid=False): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 repo = self._load_fixture_and_fetch('remove_tag_test.svndump', |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 stupid=stupid) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 self._test_tag_revision_info(repo) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 svncommand.generate_hg_tags(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 repo = hg.repository(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 self.assertEqual(repo['tip'].node(), repo['tag:tag_r3'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 self.assert_('tag:copied_tag' not in repo.tags()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 def test_remove_tag_stupid(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 self.test_remove_tag(stupid=True) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 def test_rename_tag(self, stupid=False): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 repo = self._load_fixture_and_fetch('rename_tag_test.svndump', |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 stupid=stupid) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 self._test_tag_revision_info(repo) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 svncommand.generate_hg_tags(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 repo = hg.repository(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 self.assertEqual(repo['tip'].node(), repo['tag:tag_r3'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 self.assertEqual(repo['tip'].node(), repo['tag:other_tag_r3'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 self.assert_('tag:copied_tag' not in repo.tags()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 def test_rename_tag_stupid(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 self.test_rename_tag(stupid=True) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 def test_branch_from_tag(self, stupid=False): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 stupid=stupid) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 svncommand.generate_hg_tags(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 repo = hg.repository(ui.ui(), self.wc_path) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 self.assertEqual(repo['tip'].node(), repo['branch_from_tag'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 self.assertEqual(repo[1].node(), repo['tag:tag_r3'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 self.assertEqual(repo['branch_from_tag'].parents()[0].node(), |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 repo['tag:copied_tag'].node()) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 def test_branch_from_tag_stupid(self): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 self.test_branch_from_tag(stupid=True) |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 def suite(): |
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
87 return unittest.TestLoader().loadTestsFromTestCase(TestTags) |