~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import re
19
19
import sys
20
20
 
21
 
from bzrlib import bzrdir, repository
 
21
from bzrlib import (
 
22
    bzrdir,
 
23
    errors,
 
24
    repository,
 
25
    )
22
26
from bzrlib.branch import Branch
23
27
from bzrlib.bzrdir import BzrDir
24
28
from bzrlib.builtins import merge
25
29
import bzrlib.errors
 
30
from bzrlib.repofmt import knitrepo
26
31
from bzrlib.tests import TestCaseWithTransport
27
32
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
28
33
from bzrlib.tests.test_revision import make_branches
95
100
    br_a2.append_revision('a-b-c')
96
101
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
97
102
 
98
 
    # TODO: jam 20051218 Branch should no longer allow append_revision for revisions
99
 
    #       which don't exist. So this test needs to be rewritten
100
 
    #       RBC 20060403 the way to do this is to uncommit the revision from the
101
 
    #           repository after the commit
 
103
    # TODO: ADHB 20070116 Perhaps set_last_revision shouldn't accept
 
104
    #       revisions which are not present?  In that case, this test
 
105
    #       must be rewritten.
 
106
    #
 
107
    #       RBC 20060403 the way to do this is to uncommit the revision from
 
108
    #       the repository after the commit
102
109
 
103
110
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
104
111
    # Note that this means - updating the weave when ghosts are filled in to 
123
130
        corresponding filename, parent, contents or other changes.
124
131
        """
125
132
        knit1_format = bzrdir.BzrDirMetaFormat1()
126
 
        knit1_format.repository_format = repository.RepositoryFormatKnit1()
 
133
        knit1_format.repository_format = knitrepo.RepositoryFormatKnit1()
127
134
        knit2_format = bzrdir.BzrDirMetaFormat1()
128
 
        knit2_format.repository_format = repository.RepositoryFormatKnit2()
 
135
        knit2_format.repository_format = knitrepo.RepositoryFormatKnit3()
129
136
        # we start with a knit1 repository because that causes the
130
137
        # root revision to change for each commit, even though the content,
131
138
        # parent, name, and other attributes are unchanged.
152
159
        # even though the text, name, parent_id, etc., were unchanged.
153
160
        self.assertTrue('rev2' in root_knit)
154
161
 
 
162
    def test_fetch_incompatible(self):
 
163
        knit_tree = self.make_branch_and_tree('knit', format='knit')
 
164
        knit3_tree = self.make_branch_and_tree('knit3',
 
165
            format='dirstate-with-subtree')
 
166
        knit3_tree.commit('blah')
 
167
        self.assertRaises(errors.IncompatibleRepositories,
 
168
                          knit_tree.branch.fetch, knit3_tree.branch)
 
169
 
155
170
 
156
171
class TestMergeFetch(TestCaseWithTransport):
157
172
 
271
286
        self.assertEqual(1, self._count_log_matches('inventory.kndx', http_logs))
272
287
        # this r-h check test will prevent regressions, but it currently already 
273
288
        # passes, before the patch to cache-rh is applied :[
274
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
289
        self.assertTrue(1 >= self._count_log_matches('revision-history',
 
290
                                                     http_logs))
 
291
        self.assertTrue(1 >= self._count_log_matches('last-revision',
 
292
                                                     http_logs))
275
293
        # FIXME naughty poking in there.
276
294
        self.get_readonly_server().logs = []
277
295
        # check there is nothing more to fetch
284
302
        self.assertEqual(1, self._count_log_matches('branch-format', http_logs))
285
303
        self.assertEqual(1, self._count_log_matches('branch/format', http_logs))
286
304
        self.assertEqual(1, self._count_log_matches('repository/format', http_logs))
287
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
305
        self.assertTrue(1 >= self._count_log_matches('revision-history',
 
306
                                                     http_logs))
 
307
        self.assertTrue(1 >= self._count_log_matches('last-revision',
 
308
                                                     http_logs))
288
309
        self.assertEqual(4, len(http_logs))