/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.967 by Jelmer Vernooij
Add initial test for push.
1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2
# -*- coding: utf-8 -*-
3
#
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18
"""Tests for pushing revisions from Bazaar into Git."""
19
20
from bzrlib.bzrdir import (
21
    format_registry,
22
    )
23
from bzrlib.repository import (
24
    InterRepository,
25
    )
26
from bzrlib.tests import (
0.200.1156 by Jelmer Vernooij
Disable push.
27
    KnownFailure,
0.200.967 by Jelmer Vernooij
Add initial test for push.
28
    TestCaseWithTransport,
29
    )
30
31
from bzrlib.plugins.git.push import (
32
    InterToGitRepository,
33
    )
34
35
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
36
class InterToGitRepositoryTests(TestCaseWithTransport):
0.200.967 by Jelmer Vernooij
Add initial test for push.
37
38
    def setUp(self):
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
39
        super(InterToGitRepositoryTests, self).setUp()
0.200.967 by Jelmer Vernooij
Add initial test for push.
40
        self.git_repo = self.make_repository("git",
41
                format=format_registry.make_bzrdir("git"))
42
        self.bzr_repo = self.make_repository("bzr")
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
43
        self.bzr_repo.lock_read()
44
        self.addCleanup(self.bzr_repo.unlock)
0.200.967 by Jelmer Vernooij
Add initial test for push.
45
        self.interrepo = InterRepository.get(self.bzr_repo, self.git_repo)
46
47
    def test_instance(self):
48
        self.assertIsInstance(self.interrepo, InterToGitRepository)
49
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
50
    def test_pointless_fetch_refs(self):
0.200.1156 by Jelmer Vernooij
Disable push.
51
        raise KnownFailure("roundtripping not yet supported")
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
52
        old_refs, new_refs = self.interrepo.fetch_refs(lambda x: x)
53
        self.assertEquals(old_refs, new_refs)
54
55
    def test_pointless_dfetch_refs(self):
56
        revidmap, old_refs, new_refs = self.interrepo.dfetch_refs(lambda x: x)
57
        self.assertEquals(old_refs, new_refs)
58
        self.assertEquals(revidmap, {})
59
60
    def test_pointless_missing_revisions(self):
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
61
        self.interrepo.source_store.lock_read()
62
        self.addCleanup(self.interrepo.source_store.unlock)
0.200.968 by Jelmer Vernooij
Add more tests, simplify push code.
63
        self.assertEquals([], list(self.interrepo.missing_revisions([])))
64
65
    def test_missing_revisions_unknown_stop_rev(self):
0.200.1212 by Jelmer Vernooij
Support read locking object stores.
66
        self.interrepo.source_store.lock_read()
67
        self.addCleanup(self.interrepo.source_store.unlock)
0.200.1029 by Jelmer Vernooij
Use dictionary with verifiers rather than requiring testament3-sha1 everywhere.
68
        self.assertEquals([],
0.200.1030 by Jelmer Vernooij
More work on supporting roundtripping push.
69
                list(self.interrepo.missing_revisions([(None, "unknown")])))