~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interrepository/test_interrepository.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    TestNotApplicable,
28
28
    TestSkipped,
29
29
    )
 
30
from bzrlib.tests.matchers import MatchesAncestry
30
31
from bzrlib.tests.per_interrepository import (
31
32
    TestCaseWithInterRepository,
32
33
    )
33
34
 
34
35
 
35
 
def check_old_format_lock_error(repository_format):
36
 
    """Potentially ignore LockError on old formats.
37
 
 
38
 
    On win32, with the old OS locks, we get a failure of double-lock when
39
 
    we open a object in 2 objects and try to lock both.
40
 
 
41
 
    On new formats, LockError would be invalid, but for old formats
42
 
    this was not supported on Win32.
43
 
    """
44
 
    if sys.platform != 'win32':
45
 
        raise
46
 
 
47
 
    description = repository_format.get_format_description()
48
 
    if description in ("Repository format 4",
49
 
                       "Weave repository format 5",
50
 
                       "Weave repository format 6"):
51
 
        # jam 20060701
52
 
        # win32 OS locks are not re-entrant. So one process cannot
53
 
        # open the same repository twice and lock them both.
54
 
        raise TestSkipped('%s on win32 cannot open the same'
55
 
                          ' repository twice in different objects'
56
 
                          % description)
57
 
    raise
58
 
 
59
 
 
60
36
def check_repo_format_for_funky_id_on_win32(repo):
61
37
    if not repo._format.supports_funky_characters and sys.platform == 'win32':
62
38
        raise TestSkipped("funky chars not allowed on this platform in repository"
131
107
        self.assertFalse(repo_b.has_revision('pizza'))
132
108
        # Asking specifically for an absent revision errors.
133
109
        self.assertRaises(errors.NoSuchRevision,
134
 
            repo_b.search_missing_revision_ids, repo_a, revision_id='pizza',
 
110
            repo_b.search_missing_revision_ids, repo_a, revision_ids=['pizza'],
135
111
            find_ghosts=True)
136
112
        self.assertRaises(errors.NoSuchRevision,
 
113
            repo_b.search_missing_revision_ids, repo_a, revision_ids=['pizza'],
 
114
            find_ghosts=False)
 
115
        self.callDeprecated(
 
116
            ['search_missing_revision_ids(revision_id=...) was deprecated in '
 
117
             '2.4.  Use revision_ids=[...] instead.'],
 
118
            self.assertRaises, errors.NoSuchRevision,
137
119
            repo_b.search_missing_revision_ids, repo_a, revision_id='pizza',
138
120
            find_ghosts=False)
139
121
 
143
125
        # make a repository to compare against that is empty
144
126
        repo_b = self.make_to_repository('empty')
145
127
        repo_a = self.bzrdir.open_repository()
146
 
        result = repo_b.search_missing_revision_ids(repo_a, revision_id='rev1')
 
128
        result = repo_b.search_missing_revision_ids(
 
129
            repo_a, revision_ids=['rev1'])
147
130
        self.assertEqual(set(['rev1']), result.get_keys())
148
131
        self.assertEqual(('search', set(['rev1']), set([NULL_REVISION]), 1),
149
132
            result.get_recipe())
150
133
 
 
134
    def test_search_missing_revision_ids_limit(self):
 
135
        # The limit= argument makes fetch() limit
 
136
        # the results to the first X topo-sorted revisions.
 
137
        repo_b = self.make_to_repository('rev1_only')
 
138
        repo_a = self.bzrdir.open_repository()
 
139
        # check the test will be valid
 
140
        self.assertFalse(repo_b.has_revision('rev2'))
 
141
        result = repo_b.search_missing_revision_ids(repo_a, limit=1)
 
142
        self.assertEqual(('search', set(['rev1']), set(['null:']), 1),
 
143
            result.get_recipe())
 
144
 
151
145
    def test_fetch_fetches_signatures_too(self):
152
146
        from_repo = self.bzrdir.open_repository()
153
147
        from_signature = from_repo.get_signature_text('rev2')
207
201
        rev = missing_ghost.get_revision('ghost')
208
202
        inv = missing_ghost.get_inventory('ghost')
209
203
        # rev must not be corrupt now
210
 
        self.assertEqual([None, 'ghost', 'references', 'tip'],
211
 
            missing_ghost.get_ancestry('tip'))
 
204
        self.assertThat(['ghost', 'references', 'tip'],
 
205
            MatchesAncestry(missing_ghost, 'tip'))