annotate tests/test_tags.py @ 69:63ece4ea25c9

hg_delta_editor: register copies only if files are unchanged between source and dest Handle copies of items from revision X into revision Y where X is not the parent of Y. This cannot happen in Mercurial because copies always happen between parents and children. A file copy is recorded if: 1- Source and destination revs are in the same branch. 2- The file is unchanged (content, type, removal) through all revisions between destination and source, not including source and destination. Directory copies are registered only if the previous rules apply on all copied items. [1] is there because file copies across branches are meaningless in Mercurial world. We could have tried to remap the source rev to a similar one in the correct branch, but anyway the intent is wrong. [2] is more questionable but I think it's better this way for we live in a non-perfect svn world. In theory, 99% of copies out there should come from the direct parent. But the direct parent is a fuzzy notion when you can have a working directory composed of different directory at different revisions. So we assume that stuff copied from past revisions exactly matching the content of the direct parent revision is really copied from the parent revision. The alternative would be to discard the copy, which would always happen unless people kept updating the working directory after every commit (see tests).
author Patrick Mezard <pmezard@gmail.com>
date Wed, 05 Nov 2008 13:37:08 +0100
parents 2d319e162598
children 072010a271c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
42 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
43 self.assertEqual(repo['tip'].node(), repo['tag/copied_tag'].node())
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
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)
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
54 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
55 self.assert_('tag/copied_tag' not in repo.tags())
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
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)
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
66 self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
67 self.assertEqual(repo['tip'].node(), repo['tag/other_tag_r3'].node())
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
68 self.assert_('tag/copied_tag' not in repo.tags())
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
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())
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
79 self.assertEqual(repo[1].node(), repo['tag/tag_r3'].node())
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
80 self.assertEqual(repo['branch_from_tag'].parents()[0].node(),
28
9c481cae0428 Change the format of generated tags so they are tag/$tag instead of tag:$tag so that you can use them as revision args in diff.
Augie Fackler <durin42@gmail.com>
parents: 23
diff changeset
81 repo['tag/copied_tag'].node())
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
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)
37
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
85
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
86 def test_tag_by_renaming_branch(self, stupid=False):
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
87 repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump',
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
88 stupid=stupid)
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
89 svncommand.generate_hg_tags(ui.ui(), self.wc_path)
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
90 repo = hg.repository(ui.ui(), self.wc_path)
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
91 self.assertEqual(node.hex(repo['tip'].node()),
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
92 '1b941f92acc343939274bd8bbf25984fa9706bb9')
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
93 self.assertEqual(node.hex(repo['tag/dummy'].node()),
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
94 '68f5f7d82b00a2efe3aca28b615ebab98235d55f')
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
95
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
96 def test_tag_by_renaming_branch_stupid(self):
2d319e162598 Add a test that proves renaming a branch to make a tag works properly.
Augie Fackler <durin42@gmail.com>
parents: 28
diff changeset
97 self.test_tag_by_renaming_branch(stupid=True)
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
98
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
99 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
100 return unittest.TestLoader().loadTestsFromTestCase(TestTags)