1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Tests for all_revision_ids on a repository with external references."""
19
from bzrlib import errors
20
from bzrlib.tests.per_repository_reference import (
21
TestCaseWithExternalReferenceRepository,
25
class TestAllRevisionIds(TestCaseWithExternalReferenceRepository):
27
def test_all_revision_ids_empty(self):
28
base = self.make_repository('base')
29
repo = self.make_referring('referring', 'base')
30
self.assertEqual(set([]), set(repo.all_revision_ids()))
32
def test_all_revision_ids_from_base(self):
33
tree = self.make_branch_and_tree('base')
34
revid = tree.commit('one')
35
repo = self.make_referring('referring', 'base')
36
self.assertEqual(set([revid]), set(repo.all_revision_ids()))
38
def test_all_revision_ids_from_repo(self):
39
tree = self.make_branch_and_tree('spare')
40
revid = tree.commit('one')
41
base = self.make_repository('base')
42
repo = self.make_referring('referring', 'base')
43
repo.fetch(tree.branch.repository, revid)
44
self.assertEqual(set([revid]), set(repo.all_revision_ids()))
46
def test_all_revision_ids_from_both(self):
47
tree = self.make_branch_and_tree('spare')
48
revid = tree.commit('one')
49
base_tree = self.make_branch_and_tree('base')
50
revid2 = base_tree.commit('two')
51
repo = self.make_referring('referring', 'base')
52
repo.fetch(tree.branch.repository, revid)
53
self.assertEqual(set([revid, revid2]), set(repo.all_revision_ids()))
55
def test_duplicate_ids_do_not_affect_length(self):
56
tree = self.make_branch_and_tree('spare')
57
revid = tree.commit('one')
58
base = self.make_repository('base')
59
repo = self.make_referring('referring', 'base')
60
repo.fetch(tree.branch.repository, revid)
61
base.fetch(tree.branch.repository, revid)
62
self.assertEqual(set([revid]), set(repo.all_revision_ids()))
63
self.assertEqual(1, len(repo.all_revision_ids()))