~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: Robert Collins
  • Date: 2006-02-21 11:42:36 UTC
  • mfrom: (1534.1.36 inter-repo-api)
  • mto: This revision was merged to the branch mainline in revision 1560.
  • Revision ID: robertc@robertcollins.net-20060221114236-0deb1948f0c8c956
Merge in InterRepository API support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.bzrdir import BzrDir
22
22
from bzrlib.builtins import merge
23
23
import bzrlib.errors
24
 
from bzrlib.fetch import greedy_fetch
25
24
from bzrlib.tests import TestCaseWithTransport
26
25
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
27
26
from bzrlib.tests.test_revision import make_branches
40
39
    self.assertFalse(repo_b.has_revision(br_a.revision_history()[3]))
41
40
    self.assertTrue(repo_b.has_revision(br_a.revision_history()[2]))
42
41
    self.assertEquals(len(br_b.revision_history()), 7)
43
 
    self.assertEquals(greedy_fetch(br_b, br_a, br_a.revision_history()[2])[0], 0)
44
 
    # greedy_fetch is not supposed to alter the revision history
 
42
    self.assertEquals(br_b.fetch(br_a, br_a.revision_history()[2])[0], 0)
 
43
    # branch.fetch is not supposed to alter the revision history
45
44
    self.assertEquals(len(br_b.revision_history()), 7)
46
45
    self.assertFalse(repo_b.has_revision(br_a.revision_history()[3]))
47
46
 
48
47
    # fetching the next revision up in sample data copies one revision
49
 
    self.assertEquals(greedy_fetch(br_b, br_a, br_a.revision_history()[3])[0], 1)
 
48
    self.assertEquals(br_b.fetch(br_a, br_a.revision_history()[3])[0], 1)
50
49
    self.assertTrue(repo_b.has_revision(br_a.revision_history()[3]))
51
50
    self.assertFalse(has_revision(br_a, br_b.revision_history()[6]))
52
51
    self.assertTrue(br_a.repository.has_revision(br_b.revision_history()[5]))
54
53
    # When a non-branch ancestor is missing, it should be unlisted...
55
54
    # as its not reference from the inventory weave.
56
55
    br_b4 = self.make_branch('br_4')
57
 
    count, failures = greedy_fetch(br_b4, br_b)
 
56
    count, failures = br_b4.fetch(br_b)
58
57
    self.assertEqual(count, 7)
59
58
    self.assertEqual(failures, [])
60
59
 
61
 
    self.assertEqual(greedy_fetch(writable_a, br_b)[0], 1)
 
60
    self.assertEqual(writable_a.fetch(br_b)[0], 1)
62
61
    self.assertTrue(has_revision(br_a, br_b.revision_history()[3]))
63
62
    self.assertTrue(has_revision(br_a, br_b.revision_history()[4]))
64
63
        
65
64
    br_b2 = self.make_branch('br_b2')
66
 
    self.assertEquals(greedy_fetch(br_b2, br_b)[0], 7)
 
65
    self.assertEquals(br_b2.fetch(br_b)[0], 7)
67
66
    self.assertTrue(has_revision(br_b2, br_b.revision_history()[4]))
68
67
    self.assertTrue(has_revision(br_b2, br_a.revision_history()[2]))
69
68
    self.assertFalse(has_revision(br_b2, br_a.revision_history()[3]))
70
69
 
71
70
    br_a2 = self.make_branch('br_a2')
72
 
    self.assertEquals(greedy_fetch(br_a2, br_a)[0], 9)
 
71
    self.assertEquals(br_a2.fetch(br_a)[0], 9)
73
72
    self.assertTrue(has_revision(br_a2, br_b.revision_history()[4]))
74
73
    self.assertTrue(has_revision(br_a2, br_a.revision_history()[3]))
75
74
    self.assertTrue(has_revision(br_a2, br_a.revision_history()[2]))
77
76
    br_a3 = self.make_branch('br_a3')
78
77
    # pulling a branch with no revisions grabs nothing, regardless of 
79
78
    # whats in the inventory.
80
 
    self.assertEquals(greedy_fetch(br_a3, br_a2)[0], 0)
 
79
    self.assertEquals(br_a3.fetch(br_a2)[0], 0)
81
80
    for revno in range(4):
82
81
        self.assertFalse(
83
82
            br_a3.repository.has_revision(br_a.revision_history()[revno]))
84
 
    self.assertEqual(greedy_fetch(br_a3, br_a2, br_a.revision_history()[2])[0], 3)
 
83
    self.assertEqual(br_a3.fetch(br_a2, br_a.revision_history()[2])[0], 3)
85
84
    # pull the 3 revisions introduced by a@u-0-3
86
 
    fetched = greedy_fetch(br_a3, br_a2, br_a.revision_history()[3])[0]
 
85
    fetched = br_a3.fetch(br_a2, br_a.revision_history()[3])[0]
87
86
    self.assertEquals(fetched, 3, "fetched %d instead of 3" % fetched)
88
87
    # InstallFailed should be raised if the branch is missing the revision
89
88
    # that was requested.
90
 
    self.assertRaises(bzrlib.errors.InstallFailed, greedy_fetch, br_a3,
91
 
                      br_a2, 'pizza')
 
89
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
92
90
    # InstallFailed should be raised if the branch is missing a revision
93
91
    # from its own revision history
94
92
    br_a2.append_revision('a-b-c')
95
 
    self.assertRaises(bzrlib.errors.InstallFailed, greedy_fetch, br_a3,
96
 
                      br_a2)
 
93
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
97
94
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
98
95
    # Note that this means - updating the weave when ghosts are filled in to 
99
96
    # add the right parents.
199
196
        wt.commit("changed file")
200
197
        target = BzrDir.create_branch_and_repo("target/")
201
198
        source = Branch.open(self.get_readonly_url("source/"))
202
 
        self.assertEqual(greedy_fetch(target, source), (2, []))
 
199
        self.assertEqual(target.fetch(source), (2, []))
203
200
        # this is the path to the literal file. As format changes 
204
201
        # occur it needs to be updated. FIXME: ask the store for the
205
202
        # path.
220
217
        self.get_readonly_server().logs = []
221
218
        # check there is nothing more to fetch
222
219
        source = Branch.open(self.get_readonly_url("source/"))
223
 
        self.assertEqual(greedy_fetch(target, source), (0, []))
 
220
        self.assertEqual(target.fetch(source), (0, []))
224
221
        self.failUnless(self.get_readonly_server().logs[0].endswith('branch-format HTTP/1.1" 200 -'))
225
222
        self.failUnless(self.get_readonly_server().logs[1].endswith('revision-history HTTP/1.1" 200 -'))
226
223
        self.assertEqual(2, len(self.get_readonly_server().logs))