1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2
# -*- coding: utf-8 -*-
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.
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.
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
18
"""Tests for pushing revisions from Bazaar into Git."""
20
from bzrlib.bzrdir import (
23
from bzrlib.repository import (
26
from bzrlib.tests import (
27
TestCaseWithTransport,
30
from bzrlib.plugins.git.push import (
35
class InterToGitRepositoryTests(TestCaseWithTransport):
38
super(InterToGitRepositoryTests, self).setUp()
39
self.git_repo = self.make_repository("git",
40
format=format_registry.make_bzrdir("git"))
41
self.bzr_repo = self.make_repository("bzr")
42
self.bzr_repo.lock_read()
43
self.addCleanup(self.bzr_repo.unlock)
44
self.interrepo = InterRepository.get(self.bzr_repo, self.git_repo)
46
def test_instance(self):
47
self.assertIsInstance(self.interrepo, InterToGitRepository)
49
def test_pointless_fetch_refs(self):
50
revidmap, old_refs, new_refs = self.interrepo.fetch_refs(lambda x: {}, lossy=False)
51
self.assertEquals(old_refs, {'HEAD': ('ref: refs/heads/master', None)})
52
self.assertEquals(new_refs, {})
54
def test_pointless_lossy_fetch_refs(self):
55
revidmap, old_refs, new_refs = self.interrepo.fetch_refs(lambda x: {}, lossy=True)
56
self.assertEquals(old_refs, {'HEAD': ('ref: refs/heads/master', None)})
57
self.assertEquals(new_refs, {})
58
self.assertEquals(revidmap, {})
60
def test_pointless_missing_revisions(self):
61
self.interrepo.source_store.lock_read()
62
self.addCleanup(self.interrepo.source_store.unlock)
63
self.assertEquals([], list(self.interrepo.missing_revisions([])))
65
def test_missing_revisions_unknown_stop_rev(self):
66
self.interrepo.source_store.lock_read()
67
self.addCleanup(self.interrepo.source_store.unlock)
69
list(self.interrepo.missing_revisions([(None, "unknown")])))