view tests/test_tags.py @ 131:4d42dbbb5127

hg_delta_editor: fix parent revision detection on branch copy Project items copyfrom revisions are irrelevant to parent revision detection, only the project one or those of its ancestors matter. Items copyfrom is useful when retrieving items content. Former code resulted in incorrect converted graph for pyglet repository, especially on the following revision: ------------------------------------------------------------------------ r274 | r1chardj0n3s | 2006-12-21 02:02:14 +0100 (Jeu, 21 Dec 2006) | 2 lines Changed paths: A /branches/richard-glx-version (from /trunk:269) M /branches/richard-glx-version/pyglet/window/xlib/__init__.py R /branches/richard-glx-version/tests/test.py (from /trunk/tests/test.py:270) R /branches/richard-glx-version/tools/info.py (from /trunk/tools/info.py:272) R /branches/richard-glx-version/website/get_involved.php (from /trunk/website/get_involved.php:273) Branching to horribly mangle GLX
author Patrick Mezard <pmezard@gmail.com>
date Wed, 10 Dec 2008 11:03:22 -0600
parents 291925677a9f
children 2242dd1163c6
line wrap: on
line source

import unittest

from mercurial import hg
from mercurial import node
from mercurial import ui

import test_util

import svncommand
import tag_repo

class TestTags(test_util.TestBase):
    def _load_fixture_and_fetch(self, fixture_name, stupid=False):
        return test_util.load_fixture_and_fetch(fixture_name, self.repo_path,
                                                self.wc_path, stupid=stupid)

    def getrepo(self):
        ui_ = ui.ui()
        repo = hg.repository(ui_, self.wc_path)
        repo.__class__ = tag_repo.generate_repo_class(ui_, repo)
        return repo

    def _test_tag_revision_info(self, repo):
        self.assertEqual(node.hex(repo[0].node()),
                         'a47d0ce778660a91c31bf2c21c448e9ee296ac90')
        self.assertEqual(node.hex(repo['tip'].node()),
                         'bf3767835b3b32ecc775a298c2fa27134dd91c11')
        self.assertEqual(repo['tip'], repo[1])

    def test_tags(self, stupid=False):
        repo = self._load_fixture_and_fetch('basic_tag_tests.svndump',
                                            stupid=stupid)
        self._test_tag_revision_info(repo)
        repo = self.getrepo()
        self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
        self.assertEqual(repo['tip'].node(), repo['tag/copied_tag'].node())

    def test_tags_stupid(self):
        self.test_tags(stupid=True)

    def test_remove_tag(self, stupid=False):
        repo = self._load_fixture_and_fetch('remove_tag_test.svndump',
                                            stupid=stupid)
        self._test_tag_revision_info(repo)
        repo = self.getrepo()
        self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
        self.assert_('tag/copied_tag' not in repo.tags())

    def test_remove_tag_stupid(self):
        self.test_remove_tag(stupid=True)

    def test_rename_tag(self, stupid=False):
        repo = self._load_fixture_and_fetch('rename_tag_test.svndump',
                                            stupid=stupid)
        self._test_tag_revision_info(repo)
        repo = self.getrepo()
        self.assertEqual(repo['tip'].node(), repo['tag/tag_r3'].node())
        self.assertEqual(repo['tip'].node(), repo['tag/other_tag_r3'].node())
        self.assert_('tag/copied_tag' not in repo.tags())

    def test_rename_tag_stupid(self):
        self.test_rename_tag(stupid=True)

    def test_branch_from_tag(self, stupid=False):
        repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                            stupid=stupid)
        repo = self.getrepo()
        self.assertEqual(repo['tip'].node(), repo['branch_from_tag'].node())
        self.assertEqual(repo[1].node(), repo['tag/tag_r3'].node())
        self.assertEqual(repo['branch_from_tag'].parents()[0].node(),
                         repo['tag/copied_tag'].node())

    def test_branch_from_tag_stupid(self):
        self.test_branch_from_tag(stupid=True)

    def test_tag_by_renaming_branch(self, stupid=False):
        repo = self._load_fixture_and_fetch('tag_by_rename_branch.svndump',
                                            stupid=stupid)
        repo = self.getrepo()
        self.assertEqual(node.hex(repo['tip'].node()),
                         '1b941f92acc343939274bd8bbf25984fa9706bb9')
        self.assertEqual(node.hex(repo['tag/dummy'].node()),
                         '68f5f7d82b00a2efe3aca28b615ebab98235d55f')

    def test_tag_by_renaming_branch_stupid(self):
        self.test_tag_by_renaming_branch(stupid=True)

def suite():
    return unittest.TestLoader().loadTestsFromTestCase(TestTags)