~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: Adeodato Simó
  • Date: 2007-07-17 13:47:45 UTC
  • mto: This revision was merged to the branch mainline in revision 2625.
  • Revision ID: dato@net.com.org.es-20070717134745-lex7ggja6p08kzts
Loose python2.4-specific shebangs; use generic python instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007 Canonical Ltd
 
1
# Copyright (C) 2005 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
22
21
from bzrlib import (
23
22
    bzrdir,
24
23
    errors,
25
 
    merge,
26
24
    repository,
27
25
    )
28
26
from bzrlib.branch import Branch
29
27
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
 
    )
34
31
from bzrlib.tests import TestCaseWithTransport
35
32
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
36
33
from bzrlib.tests.test_revision import make_branches
38
35
from bzrlib.upgrade import Convert
39
36
from bzrlib.workingtree import WorkingTree
40
37
 
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
 
 
45
38
 
46
39
def has_revision(branch, revision_id):
47
40
    return branch.repository.has_revision(revision_id)
101
94
    self.assertEquals(fetched, 3, "fetched %d instead of 3" % fetched)
102
95
    # InstallFailed should be raised if the branch is missing the revision
103
96
    # that was requested.
104
 
    self.assertRaises(errors.InstallFailed, br_a3.fetch, br_a2, 'pizza')
 
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)
105
102
 
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
 
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
111
109
 
112
110
    #TODO: test that fetch correctly does reweaving when needed. RBC 20051008
113
111
    # Note that this means - updating the weave when ghosts are filled in to 
118
116
 
119
117
    def test_fetch(self):
120
118
        #highest indices a: 5, b: 7
121
 
        br_a, br_b = make_branches(self, format='dirstate-tags')
 
119
        br_a, br_b = make_branches(self)
122
120
        fetch_steps(self, br_a, br_b, br_a)
123
121
 
124
122
    def test_fetch_self(self):
181
179
        wt2 = self.make_branch_and_tree('br2')
182
180
        br2 = wt2.branch
183
181
        wt2.commit(message='rev 2-1', rev_id='2-1')
184
 
        wt2.merge_from_branch(br1, from_revision='null:')
 
182
        merge(other_revision=['br1', -1], base_revision=['br1', 0],
 
183
              this_dir='br2')
185
184
        self._check_revs_present(br2)
186
185
 
187
186
    def test_merge_fetches(self):
192
191
        dir_2 = br1.bzrdir.sprout('br2')
193
192
        br2 = dir_2.open_branch()
194
193
        wt1.commit(message='rev 1-2', rev_id='1-2')
195
 
        wt2 = dir_2.open_workingtree()
196
 
        wt2.commit(message='rev 2-1', rev_id='2-1')
197
 
        wt2.merge_from_branch(br1)
 
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')
198
197
        self._check_revs_present(br2)
199
198
 
200
199
    def _check_revs_present(self, br2):
229
228
    def test_merge_fetches_file_history(self):
230
229
        """Merge brings across file histories"""
231
230
        br2 = Branch.open('br2')
232
 
        br1 = Branch.open('br1')
233
 
        wt2 = WorkingTree.open('br2').merge_from_branch(br1)
234
 
        br2.lock_read()
235
 
        self.addCleanup(br2.unlock)
 
231
        merge(other_revision=['br1', -1], base_revision=[None, None], 
 
232
              this_dir='br2')
236
233
        for rev_id, text in [('1-2', 'original from 1\n'),
237
234
                             ('1-3', 'agreement\n'),
238
235
                             ('2-1', 'contents in 2\n'),
266
263
 
267
264
    def test_weaves_are_retrieved_once(self):
268
265
        self.build_tree(("source/", "source/file", "target/"))
269
 
        # This test depends on knit dasta storage.
270
 
        wt = self.make_branch_and_tree('source', format='dirstate-tags')
 
266
        wt = self.make_branch_and_tree('source')
271
267
        branch = wt.branch
272
268
        wt.add(["file"], ["id"])
273
269
        wt.commit("added file")
274
 
        open("source/file", 'w').write("blah\n")
 
270
        print >>open("source/file", 'w'), "blah"
275
271
        wt.commit("changed file")
276
272
        target = BzrDir.create_branch_and_repo("target/")
277
273
        source = Branch.open(self.get_readonly_url("source/"))