~greatmay12/+junk/test1

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_reference/test_all_revision_ids.py

  • Committer: thitipong at ndrsolution
  • Date: 2011-11-14 06:31:02 UTC
  • Revision ID: thitipong@ndrsolution.com-20111114063102-9obte3yfi2azku7d
ndr redirect version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
"""Tests for all_revision_ids on a repository with external references."""
 
18
 
 
19
from bzrlib import errors
 
20
from bzrlib.tests.per_repository_reference import (
 
21
    TestCaseWithExternalReferenceRepository,
 
22
    )
 
23
 
 
24
 
 
25
class TestAllRevisionIds(TestCaseWithExternalReferenceRepository):
 
26
 
 
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()))
 
31
 
 
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()))
 
37
 
 
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()))
 
45
 
 
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()))
 
54
 
 
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()))
 
64