~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Olaf Conradi
  • Date: 2006-03-28 23:30:02 UTC
  • mto: (1661.1.1 bzr.mbp.remember)
  • mto: This revision was merged to the branch mainline in revision 1663.
  • Revision ID: olaf@conradi.org-20060328233002-f6262df0e19c1963
Added testcases for using pull with --remember. Moved remember code to
beginning of cmd_pull. This remembers the location in case of a failure
during pull.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib.branch import Branch
26
26
from bzrlib.tests.blackbox import ExternalBase
 
27
from bzrlib.osutils import abspath
 
28
 
27
29
 
28
30
class TestPull(ExternalBase):
29
31
 
222
224
 
223
225
        self.assertEqual(rev_history_b, rev_history_a)
224
226
 
 
227
    def test_pull_remember(self):
 
228
        """Pull changes from one branch to another and test parent location."""
 
229
        os.mkdir('a')
 
230
        os.chdir('a')
225
231
 
 
232
        self.example_branch()
 
233
        self.runbzr('branch . ../b')
 
234
        self.runbzr('branch . ../c')
 
235
        file('bottles', 'wt').write('99 bottles of beer on the wall')
 
236
        self.runbzr('add bottles')
 
237
        self.runbzr('commit -m 99_bottles')
 
238
        os.chdir('../b')
 
239
        b = Branch.open('')
 
240
        parent = b.get_parent()
 
241
        # reset parent
 
242
        b.set_parent(None)
 
243
        self.assertEqual(None, b.get_parent())
 
244
        # test pull for failure without parent set
 
245
        out = self.runbzr('pull', retcode=3)
 
246
        self.assertEquals(out,
 
247
                ('','bzr: ERROR: No pull location known or specified.\n'))
 
248
        # test implicit --remember when no parent set, this pull conflicts
 
249
        file('bottles', 'wt').write('98 bottles of beer on the wall')
 
250
        self.runbzr('add bottles')
 
251
        self.runbzr('commit -m 98_bottles')
 
252
        out = self.runbzr('pull ../a', retcode=3)
 
253
        self.assertEquals(out,
 
254
                ('','bzr: ERROR: These branches have diverged.  Try merge.\n'))
 
255
        self.assertEquals(abspath(b.get_parent()), abspath(parent))
 
256
        # test implicit --remember after resolving previous failure
 
257
        self.runbzr('uncommit --force')
 
258
        self.runbzr('pull')
 
259
        self.assertEquals(abspath(b.get_parent()), abspath(parent))
 
260
        # test explicit --remember
 
261
        self.runbzr('pull ../c --remember')
 
262
        self.assertEquals(abspath(b.get_parent()), abspath('../c'))