~ubuntu-branches/ubuntu/natty/bzr/natty-proposed

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_pull.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-08-07 00:54:52 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100807005452-g4zb99ezl3xn44r4
Tags: 2.2.0-1
* New upstream release.
 + Adds support for setting timestamps to originating revisions.
   Closes: #473450
 + Removes remaining string exception. Closes: #585193, LP: #586926
 + Add C extension to work around Python issue 1628205. LP: #583941,
   Closes: #577110
 + Avoids showing progress bars when --quiet is used. Closes: #542105,
   LP: #320035
 + No longer creates ~/.bazaar as root when run under sudo. LP: #376388
 + 'bzr commit' now supports -p as alternative for --show-diff. LP: #571467
 + 'bzr add' no longer adds .THIS/.BASE/.THEIRS files unless
   explicitly requested. LP: #322767
 + When parsing patch files, Bazaar now supports diff lines before each
   patch. LP: #502076
 + WorkingTrees now no longer requires using signal.signal, so can
   be used in a threaded environment. LP: #521989
 + An assertion error is no longer triggered when pushing to a pre-1.6
   Bazaar server. LP: #528041
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
 
19
19
import os
20
20
 
21
 
from bzrlib.branch import Branch, BzrBranchFormat5
22
 
from bzrlib.bzrdir import BzrDir
23
 
from bzrlib import errors
24
 
from bzrlib.memorytree import MemoryTree
25
 
from bzrlib.revision import NULL_REVISION
26
 
from bzrlib.tests.per_branch.test_branch import TestCaseWithBranch
27
 
 
28
 
 
29
 
class TestPull(TestCaseWithBranch):
 
21
from bzrlib import (
 
22
    branch,
 
23
    bzrdir,
 
24
    errors,
 
25
    memorytree,
 
26
    revision,
 
27
    )
 
28
from bzrlib.tests import per_branch
 
29
 
 
30
 
 
31
class TestPull(per_branch.TestCaseWithBranch):
30
32
 
31
33
    def test_pull_convergence_simple(self):
32
34
        # when revisions are pulled, the left-most accessible parents must
96
98
                          master_tree.branch.pull, other.branch, local = True)
97
99
        self.assertEqual([rev1], master_tree.branch.revision_history())
98
100
 
99
 
    def test_pull_raises_specific_error_on_master_connection_error(self):
100
 
        master_tree = self.make_branch_and_tree('master')
101
 
        checkout = master_tree.branch.create_checkout('checkout')
102
 
        other = master_tree.branch.bzrdir.sprout('other').open_workingtree()
103
 
        # move the branch out of the way on disk to cause a connection
104
 
        # error.
105
 
        os.rename('master', 'master_gone')
106
 
        # try to pull, which should raise a BoundBranchConnectionFailure.
107
 
        self.assertRaises(errors.BoundBranchConnectionFailure,
108
 
                checkout.branch.pull, other.branch)
109
 
 
110
101
    def test_pull_returns_result(self):
111
102
        parent = self.make_branch_and_tree('parent')
112
103
        parent.commit('1st post', rev_id='P1')
145
136
                         tree_a.branch.revision_history())
146
137
 
147
138
 
148
 
class TestPullHook(TestCaseWithBranch):
 
139
class TestPullHook(per_branch.TestCaseWithBranch):
149
140
 
150
141
    def setUp(self):
151
142
        self.hook_calls = []
152
 
        TestCaseWithBranch.setUp(self)
 
143
        super(TestPullHook, self).setUp()
153
144
 
154
145
    def capture_post_pull_hook(self, result):
155
146
        """Capture post pull hook calls to self.hook_calls.
173
164
    def test_post_pull_empty_history(self):
174
165
        target = self.make_branch('target')
175
166
        source = self.make_branch('source')
176
 
        Branch.hooks.install_named_hook('post_pull',
177
 
            self.capture_post_pull_hook, None)
 
167
        branch.Branch.hooks.install_named_hook(
 
168
            'post_pull', self.capture_post_pull_hook, None)
178
169
        target.pull(source)
179
170
        # with nothing there we should still get a notification, and
180
171
        # have both branches locked at the notification time.
181
172
        self.assertEqual([
182
 
            ('post_pull', source, None, target.base, 0, NULL_REVISION,
183
 
             0, NULL_REVISION, True, None, True)
 
173
            ('post_pull', source, None, target.base, 0, revision.NULL_REVISION,
 
174
             0, revision.NULL_REVISION, True, None, True)
184
175
            ],
185
176
            self.hook_calls)
186
177
 
199
190
            # remotebranches can't be bound.  Let's instead make a new local
200
191
            # branch of the default type, which does allow binding.
201
192
            # See https://bugs.launchpad.net/bzr/+bug/112020
202
 
            local = BzrDir.create_branch_convenience('local2')
 
193
            local = bzrdir.BzrDir.create_branch_convenience('local2')
203
194
            local.bind(target)
204
195
        source = self.make_branch('source')
205
 
        Branch.hooks.install_named_hook('post_pull',
206
 
            self.capture_post_pull_hook, None)
 
196
        branch.Branch.hooks.install_named_hook(
 
197
            'post_pull', self.capture_post_pull_hook, None)
207
198
        local.pull(source)
208
199
        # with nothing there we should still get a notification, and
209
200
        # have both branches locked at the notification time.
210
201
        self.assertEqual([
211
 
            ('post_pull', source, local.base, target.base, 0, NULL_REVISION,
212
 
             0, NULL_REVISION, True, True, True)
 
202
            ('post_pull', source, local.base, target.base, 0,
 
203
             revision.NULL_REVISION, 0, revision.NULL_REVISION,
 
204
             True, True, True)
213
205
            ],
214
206
            self.hook_calls)
215
207
 
220
212
        rev1 = target.commit('rev 1')
221
213
        target.unlock()
222
214
        sourcedir = target.bzrdir.clone(self.get_url('source'))
223
 
        source = MemoryTree.create_on_branch(sourcedir.open_branch())
 
215
        source = memorytree.MemoryTree.create_on_branch(sourcedir.open_branch())
224
216
        rev2 = source.commit('rev 2')
225
 
        Branch.hooks.install_named_hook('post_pull',
226
 
            self.capture_post_pull_hook, None)
 
217
        branch.Branch.hooks.install_named_hook(
 
218
            'post_pull', self.capture_post_pull_hook, None)
227
219
        target.branch.pull(source.branch)
228
220
        # with nothing there we should still get a notification, and
229
221
        # have both branches locked at the notification time.