/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

  • Committer: Aaron Bentley
  • Date: 2007-03-03 17:17:53 UTC
  • mfrom: (2309 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2316.
  • Revision ID: aaron.bentley@utoronto.ca-20070303171753-o0s1yrxx5sn12p2k
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import re
18
19
import sys
19
20
 
20
21
from bzrlib import bzrdir, repository
22
23
from bzrlib.bzrdir import BzrDir
23
24
from bzrlib.builtins import merge
24
25
import bzrlib.errors
 
26
from bzrlib.repofmt import knitrepo
25
27
from bzrlib.tests import TestCaseWithTransport
26
28
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
27
29
from bzrlib.tests.test_revision import make_branches
94
96
    br_a2.append_revision('a-b-c')
95
97
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
96
98
 
97
 
    # TODO: jam 20051218 Branch should no longer allow append_revision for revisions
98
 
    #       which don't exist. So this test needs to be rewritten
99
 
    #       RBC 20060403 the way to do this is to uncommit the revision from the
100
 
    #           repository after the commit
 
99
    # TODO: ADHB 20070116 Perhaps set_last_revision shouldn't accept
 
100
    #       revisions which are not present?  In that case, this test
 
101
    #       must be rewritten.
 
102
    #
 
103
    #       RBC 20060403 the way to do this is to uncommit the revision from
 
104
    #       the repository after the commit
101
105
 
102
106
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
103
107
    # Note that this means - updating the weave when ghosts are filled in to 
122
126
        corresponding filename, parent, contents or other changes.
123
127
        """
124
128
        knit1_format = bzrdir.BzrDirMetaFormat1()
125
 
        knit1_format.repository_format = repository.RepositoryFormatKnit1()
 
129
        knit1_format.repository_format = knitrepo.RepositoryFormatKnit1()
126
130
        knit2_format = bzrdir.BzrDirMetaFormat1()
127
 
        knit2_format.repository_format = repository.RepositoryFormatKnit2()
 
131
        knit2_format.repository_format = knitrepo.RepositoryFormatKnit2()
128
132
        # we start with a knit1 repository because that causes the
129
133
        # root revision to change for each commit, even though the content,
130
134
        # parent, name, and other attributes are unchanged.
236
240
 
237
241
    def _count_log_matches(self, target, logs):
238
242
        """Count the number of times the target file pattern was fetched in an http log"""
239
 
        log_pattern = '%s HTTP/1.1" 200 - "-" "bzr/%s' % \
240
 
            (target, bzrlib.__version__)
 
243
        get_succeeds_re = re.compile(
 
244
            '.*"GET .*%s HTTP/1.1" 20[06] - "-" "bzr/%s' %
 
245
            (     target,                    bzrlib.__version__))
241
246
        c = 0
242
247
        for line in logs:
243
 
            # TODO: perhaps use a regexp instead so we can match more
244
 
            # precisely?
245
 
            if line.find(log_pattern) > -1:
 
248
            if get_succeeds_re.match(line):
246
249
                c += 1
247
250
        return c
248
251
 
257
260
        target = BzrDir.create_branch_and_repo("target/")
258
261
        source = Branch.open(self.get_readonly_url("source/"))
259
262
        self.assertEqual(target.fetch(source), (2, []))
260
 
        log_pattern = '%%s HTTP/1.1" 200 - "-" "bzr/%s' % bzrlib.__version__
261
263
        # this is the path to the literal file. As format changes 
262
264
        # occur it needs to be updated. FIXME: ask the store for the
263
265
        # path.
272
274
        self.assertEqual(1, self._count_log_matches('inventory.kndx', http_logs))
273
275
        # this r-h check test will prevent regressions, but it currently already 
274
276
        # passes, before the patch to cache-rh is applied :[
275
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
277
        self.assertTrue(1 >= self._count_log_matches('revision-history',
 
278
                                                     http_logs))
 
279
        self.assertTrue(1 >= self._count_log_matches('last-revision',
 
280
                                                     http_logs))
276
281
        # FIXME naughty poking in there.
277
282
        self.get_readonly_server().logs = []
278
283
        # check there is nothing more to fetch
285
290
        self.assertEqual(1, self._count_log_matches('branch-format', http_logs))
286
291
        self.assertEqual(1, self._count_log_matches('branch/format', http_logs))
287
292
        self.assertEqual(1, self._count_log_matches('repository/format', http_logs))
288
 
        self.assertEqual(1, self._count_log_matches('revision-history', http_logs))
 
293
        self.assertTrue(1 >= self._count_log_matches('revision-history',
 
294
                                                     http_logs))
 
295
        self.assertTrue(1 >= self._count_log_matches('last-revision',
 
296
                                                     http_logs))
289
297
        self.assertEqual(4, len(http_logs))