/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

Add finished() notifications to transactions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    # from its own revision history
92
92
    br_a2.append_revision('a-b-c')
93
93
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
94
 
 
95
 
    # TODO: jam 20051218 Branch should no longer allow append_revision for revisions
96
 
    #       which don't exist. So this test needs to be rewritten
97
 
    #       RBC 20060403 the way to do this is to uncommit the revision from the
98
 
    #           repository after the commit
99
 
 
100
94
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
101
95
    # Note that this means - updating the weave when ghosts are filled in to 
102
96
    # add the right parents.
109
103
        br_a, br_b = make_branches(self)
110
104
        fetch_steps(self, br_a, br_b, br_a)
111
105
 
112
 
    def test_fetch_self(self):
113
 
        wt = self.make_branch_and_tree('br')
114
 
        self.assertEqual(wt.branch.fetch(wt.branch), (0, []))
115
 
 
116
106
 
117
107
class TestMergeFetch(TestCaseWithTransport):
118
108
 
196
186
        br_rem_a = Branch.open(self.get_readonly_url('branch1'))
197
187
        fetch_steps(self, br_rem_a, br_b, br_a)
198
188
 
199
 
    def _count_log_matches(self, target, logs):
200
 
        """Count the number of times the target file pattern was fetched in an http log"""
201
 
        log_pattern = '%s HTTP/1.1" 200 - "-" "bzr/%s' % \
202
 
            (target, bzrlib.__version__)
203
 
        c = 0
204
 
        for line in logs:
205
 
            # TODO: perhaps use a regexp instead so we can match more
206
 
            # precisely?
207
 
            if line.find(log_pattern) > -1:
208
 
                c += 1
209
 
        return c
210
 
 
211
189
    def test_weaves_are_retrieved_once(self):
212
190
        self.build_tree(("source/", "source/file", "target/"))
213
191
        wt = self.make_branch_and_tree('source')
219
197
        target = BzrDir.create_branch_and_repo("target/")
220
198
        source = Branch.open(self.get_readonly_url("source/"))
221
199
        self.assertEqual(target.fetch(source), (2, []))
222
 
        log_pattern = '%%s HTTP/1.1" 200 - "-" "bzr/%s' % bzrlib.__version__
 
200
        log_pattern = '%%s HTTP/1.1" 200 - "-" "bzr/%s"' % bzrlib.__version__
223
201
        # this is the path to the literal file. As format changes 
224
202
        # occur it needs to be updated. FIXME: ask the store for the
225
203
        # path.
226
 
        self.log("web server logs are:")
227
 
        http_logs = self.get_readonly_server().logs
228
 
        self.log('\n'.join(http_logs))
229
 
        self.assertEqual(1, self._count_log_matches('weaves/ce/id.weave', http_logs))
230
 
        self.assertEqual(1, self._count_log_matches('inventory.weave', http_logs))
 
204
        weave_suffix = log_pattern % 'weaves/ce/id.weave'
 
205
        self.assertEqual(1,
 
206
            len([log for log in self.get_readonly_server().logs if log.endswith(weave_suffix)]))
 
207
        inventory_weave_suffix = log_pattern % 'inventory.weave'
 
208
        self.assertEqual(1,
 
209
            len([log for log in self.get_readonly_server().logs if log.endswith(
 
210
                inventory_weave_suffix)]))
231
211
        # this r-h check test will prevent regressions, but it currently already 
232
212
        # passes, before the patch to cache-rh is applied :[
233
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
213
        revision_history_suffix = log_pattern % 'revision-history'
 
214
        self.assertEqual(1,
 
215
            len([log for log in self.get_readonly_server().logs if log.endswith(
 
216
                revision_history_suffix)]))
234
217
        # FIXME naughty poking in there.
235
218
        self.get_readonly_server().logs = []
236
219
        # check there is nothing more to fetch
237
220
        source = Branch.open(self.get_readonly_url("source/"))
238
221
        self.assertEqual(target.fetch(source), (0, []))
239
 
        # should make just two requests
240
 
        http_logs = self.get_readonly_server().logs
241
 
        self.log("web server logs are:")
242
 
        self.log('\n'.join(http_logs))
243
 
        self.assertEqual(1, self._count_log_matches('branch-format', http_logs[0:1]))
244
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs[1:2]))
245
 
        self.assertEqual(2, len(http_logs))
 
222
        self.failUnless(self.get_readonly_server().logs[0].endswith(log_pattern % 'branch-format'))
 
223
        self.failUnless(self.get_readonly_server().logs[1].endswith(log_pattern % 'revision-history'))
 
224
        self.assertEqual(2, len(self.get_readonly_server().logs))