~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-04-13 23:03:17 UTC
  • mfrom: (1661.1.1 bzr.mbp.remember)
  • mto: This revision was merged to the branch mainline in revision 1663.
  • Revision ID: mbp@sourcefrog.net-20060413230317-a1543afe041b1266
[merge] push/pull/merge --remember

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
 
25
25
from bzrlib.branch import Branch
 
26
from bzrlib.osutils import abspath
26
27
from bzrlib.tests.blackbox import ExternalBase
 
28
from bzrlib.uncommit import uncommit
 
29
 
27
30
 
28
31
class TestPull(ExternalBase):
29
32
 
222
225
 
223
226
        self.assertEqual(rev_history_b, rev_history_a)
224
227
 
225
 
 
 
228
    def test_pull_remember(self):
 
229
        """Pull changes from one branch to another and test parent location."""
 
230
        transport = self.get_transport()
 
231
        tree_a = self.make_branch_and_tree('branch_a')
 
232
        branch_a = tree_a.branch
 
233
        self.build_tree(['branch_a/a'])
 
234
        tree_a.add('a')
 
235
        tree_a.commit('commit a')
 
236
        branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
 
237
        tree_b = branch_b.bzrdir.open_workingtree()
 
238
        branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
 
239
        tree_c = branch_c.bzrdir.open_workingtree()
 
240
        self.build_tree(['branch_a/b'])
 
241
        tree_a.add('b')
 
242
        tree_a.commit('commit b')
 
243
        # reset parent
 
244
        parent = branch_b.get_parent()
 
245
        branch_b.set_parent(None)
 
246
        self.assertEqual(None, branch_b.get_parent())
 
247
        # test pull for failure without parent set
 
248
        os.chdir('branch_b')
 
249
        out = self.runbzr('pull', retcode=3)
 
250
        self.assertEquals(out,
 
251
                ('','bzr: ERROR: No pull location known or specified.\n'))
 
252
        # test implicit --remember when no parent set, this pull conflicts
 
253
        self.build_tree(['d'])
 
254
        tree_b.add('d')
 
255
        tree_b.commit('commit d')
 
256
        out = self.runbzr('pull ../branch_a', retcode=3)
 
257
        self.assertEquals(out,
 
258
                ('','bzr: ERROR: These branches have diverged.  Try merge.\n'))
 
259
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
 
260
        # test implicit --remember after resolving previous failure
 
261
        uncommit(branch=branch_b, tree=tree_b)
 
262
        transport.delete('branch_b/d')
 
263
        self.runbzr('pull')
 
264
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
 
265
        # test explicit --remember
 
266
        self.runbzr('pull ../branch_c --remember')
 
267
        self.assertEquals(abspath(branch_b.get_parent()),
 
268
                          abspath(branch_c.bzrdir.root_transport.base))