/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: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
import re
19
19
import sys
20
20
 
 
21
import bzrlib
21
22
from bzrlib import (
22
23
    bzrdir,
23
24
    errors,
 
25
    merge,
24
26
    repository,
25
27
    )
26
28
from bzrlib.branch import Branch
27
29
from bzrlib.bzrdir import BzrDir
28
 
from bzrlib.builtins import merge
29
 
import bzrlib.errors
30
30
from bzrlib.repofmt import knitrepo
 
31
from bzrlib.symbol_versioning import (
 
32
    zero_ninetyone,
 
33
    )
31
34
from bzrlib.tests import TestCaseWithTransport
32
35
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
33
36
from bzrlib.tests.test_revision import make_branches
35
38
from bzrlib.upgrade import Convert
36
39
from bzrlib.workingtree import WorkingTree
37
40
 
 
41
# These tests are a bit old; please instead add new tests into
 
42
# interrepository_implementations/ so they'll run on all relevant
 
43
# combinations.
 
44
 
38
45
 
39
46
def has_revision(branch, revision_id):
40
47
    return branch.repository.has_revision(revision_id)
94
101
    self.assertEquals(fetched, 3, "fetched %d instead of 3" % fetched)
95
102
    # InstallFailed should be raised if the branch is missing the revision
96
103
    # that was requested.
97
 
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
98
 
    # InstallFailed should be raised if the branch is missing a revision
99
 
    # from its own revision history
100
 
    br_a2.append_revision('a-b-c')
101
 
    self.assertRaises(bzrlib.errors.InstallFailed, br_a3.fetch, br_a2)
 
104
    self.assertRaises(errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
102
105
 
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
 
106
    # TODO: Test trying to fetch from a branch that points to a revision not
 
107
    # actually present in its repository.  Not every branch format allows you
 
108
    # to directly point to such revisions, so it's a bit complicated to
 
109
    # construct.  One way would be to uncommit and gc the revision, but not
 
110
    # every branch supports that.  -- mbp 20070814
109
111
 
110
112
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
111
113
    # Note that this means - updating the weave when ghosts are filled in to 
116
118
 
117
119
    def test_fetch(self):
118
120
        #highest indices a: 5, b: 7
119
 
        br_a, br_b = make_branches(self)
 
121
        br_a, br_b = make_branches(self, format='dirstate-tags')
120
122
        fetch_steps(self, br_a, br_b, br_a)
121
123
 
122
124
    def test_fetch_self(self):
179
181
        wt2 = self.make_branch_and_tree('br2')
180
182
        br2 = wt2.branch
181
183
        wt2.commit(message='rev 2-1', rev_id='2-1')
182
 
        merge(other_revision=['br1', -1], base_revision=['br1', 0],
183
 
              this_dir='br2')
 
184
        wt2.merge_from_branch(br1, from_revision='null:')
184
185
        self._check_revs_present(br2)
185
186
 
186
187
    def test_merge_fetches(self):
191
192
        dir_2 = br1.bzrdir.sprout('br2')
192
193
        br2 = dir_2.open_branch()
193
194
        wt1.commit(message='rev 1-2', rev_id='1-2')
194
 
        dir_2.open_workingtree().commit(message='rev 2-1', rev_id='2-1')
195
 
        merge(other_revision=['br1', -1], base_revision=[None, None], 
196
 
              this_dir='br2')
 
195
        wt2 = dir_2.open_workingtree()
 
196
        wt2.commit(message='rev 2-1', rev_id='2-1')
 
197
        wt2.merge_from_branch(br1)
197
198
        self._check_revs_present(br2)
198
199
 
199
200
    def _check_revs_present(self, br2):
228
229
    def test_merge_fetches_file_history(self):
229
230
        """Merge brings across file histories"""
230
231
        br2 = Branch.open('br2')
231
 
        merge(other_revision=['br1', -1], base_revision=[None, None], 
232
 
              this_dir='br2')
 
232
        br1 = Branch.open('br1')
 
233
        wt2 = WorkingTree.open('br2').merge_from_branch(br1)
233
234
        for rev_id, text in [('1-2', 'original from 1\n'),
234
235
                             ('1-3', 'agreement\n'),
235
236
                             ('2-1', 'contents in 2\n'),