~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-02-10 17:52:08 UTC
  • mfrom: (5021 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100210175208-bubuwav4uqigu291
Merge bzr.dev 5021 to resolve NEWS

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
145
147
                         tree_a.branch.revision_history())
146
148
 
147
149
 
148
 
class TestPullHook(TestCaseWithBranch):
 
150
class TestPullHook(per_branch.TestCaseWithBranch):
149
151
 
150
152
    def setUp(self):
151
153
        self.hook_calls = []
152
 
        TestCaseWithBranch.setUp(self)
 
154
        super(TestPullHook, self).setUp()
153
155
 
154
156
    def capture_post_pull_hook(self, result):
155
157
        """Capture post pull hook calls to self.hook_calls.
173
175
    def test_post_pull_empty_history(self):
174
176
        target = self.make_branch('target')
175
177
        source = self.make_branch('source')
176
 
        Branch.hooks.install_named_hook('post_pull',
177
 
            self.capture_post_pull_hook, None)
 
178
        branch.Branch.hooks.install_named_hook(
 
179
            'post_pull', self.capture_post_pull_hook, None)
178
180
        target.pull(source)
179
181
        # with nothing there we should still get a notification, and
180
182
        # have both branches locked at the notification time.
181
183
        self.assertEqual([
182
 
            ('post_pull', source, None, target.base, 0, NULL_REVISION,
183
 
             0, NULL_REVISION, True, None, True)
 
184
            ('post_pull', source, None, target.base, 0, revision.NULL_REVISION,
 
185
             0, revision.NULL_REVISION, True, None, True)
184
186
            ],
185
187
            self.hook_calls)
186
188
 
199
201
            # remotebranches can't be bound.  Let's instead make a new local
200
202
            # branch of the default type, which does allow binding.
201
203
            # See https://bugs.launchpad.net/bzr/+bug/112020
202
 
            local = BzrDir.create_branch_convenience('local2')
 
204
            local = bzrdir.BzrDir.create_branch_convenience('local2')
203
205
            local.bind(target)
204
206
        source = self.make_branch('source')
205
 
        Branch.hooks.install_named_hook('post_pull',
206
 
            self.capture_post_pull_hook, None)
 
207
        branch.Branch.hooks.install_named_hook(
 
208
            'post_pull', self.capture_post_pull_hook, None)
207
209
        local.pull(source)
208
210
        # with nothing there we should still get a notification, and
209
211
        # have both branches locked at the notification time.
210
212
        self.assertEqual([
211
 
            ('post_pull', source, local.base, target.base, 0, NULL_REVISION,
212
 
             0, NULL_REVISION, True, True, True)
 
213
            ('post_pull', source, local.base, target.base, 0,
 
214
             revision.NULL_REVISION, 0, revision.NULL_REVISION,
 
215
             True, True, True)
213
216
            ],
214
217
            self.hook_calls)
215
218
 
220
223
        rev1 = target.commit('rev 1')
221
224
        target.unlock()
222
225
        sourcedir = target.bzrdir.clone(self.get_url('source'))
223
 
        source = MemoryTree.create_on_branch(sourcedir.open_branch())
 
226
        source = memorytree.MemoryTree.create_on_branch(sourcedir.open_branch())
224
227
        rev2 = source.commit('rev 2')
225
 
        Branch.hooks.install_named_hook('post_pull',
226
 
            self.capture_post_pull_hook, None)
 
228
        branch.Branch.hooks.install_named_hook(
 
229
            'post_pull', self.capture_post_pull_hook, None)
227
230
        target.branch.pull(source.branch)
228
231
        # with nothing there we should still get a notification, and
229
232
        # have both branches locked at the notification time.