/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-05-20 17:51:13 UTC
  • mfrom: (1718 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1727.
  • Revision ID: aaron.bentley@utoronto.ca-20060520175113-4549e0023f9210bf
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
 
19
 
"""Black-box tests for bzr pull.
20
 
"""
 
19
"""Black-box tests for bzr pull."""
21
20
 
22
21
import os
23
22
import sys
24
23
 
25
24
from bzrlib.branch import Branch
 
25
from bzrlib.osutils import abspath
26
26
from bzrlib.tests.blackbox import ExternalBase
 
27
from bzrlib.uncommit import uncommit
 
28
 
27
29
 
28
30
class TestPull(ExternalBase):
29
31
 
46
48
        self.runbzr('missing', retcode=3)
47
49
        self.runbzr('missing .')
48
50
        self.runbzr('missing')
49
 
        if sys.platform not in ('win32', 'cygwin'):
50
 
            # This is equivalent to doing "bzr pull ."
51
 
            # Which means that bzr creates 2 branches grabbing
52
 
            # the same location, and tries to pull.
53
 
            # However, 2 branches mean 2 locks on the same file
54
 
            # which ultimately implies a deadlock.
55
 
            # (non windows platforms allow multiple locks on the
56
 
            # same file by the same calling process)
57
 
            self.runbzr('pull')
 
51
        # this will work on windows because we check for the same branch
 
52
        # in pull - if it fails, it is a regression
 
53
        self.runbzr('pull')
58
54
        self.runbzr('pull /', retcode=3)
59
55
        if sys.platform not in ('win32', 'cygwin'):
60
56
            self.runbzr('pull')
222
218
 
223
219
        self.assertEqual(rev_history_b, rev_history_a)
224
220
 
225
 
 
 
221
    def test_pull_remember(self):
 
222
        """Pull changes from one branch to another and test parent location."""
 
223
        transport = self.get_transport()
 
224
        tree_a = self.make_branch_and_tree('branch_a')
 
225
        branch_a = tree_a.branch
 
226
        self.build_tree(['branch_a/a'])
 
227
        tree_a.add('a')
 
228
        tree_a.commit('commit a')
 
229
        tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
 
230
        branch_b = tree_b.branch
 
231
        tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
 
232
        branch_c = tree_c.branch
 
233
        self.build_tree(['branch_a/b'])
 
234
        tree_a.add('b')
 
235
        tree_a.commit('commit b')
 
236
        # reset parent
 
237
        parent = branch_b.get_parent()
 
238
        branch_b.set_parent(None)
 
239
        self.assertEqual(None, branch_b.get_parent())
 
240
        # test pull for failure without parent set
 
241
        os.chdir('branch_b')
 
242
        out = self.runbzr('pull', retcode=3)
 
243
        self.assertEquals(out,
 
244
                ('','bzr: ERROR: No pull location known or specified.\n'))
 
245
        # test implicit --remember when no parent set, this pull conflicts
 
246
        self.build_tree(['d'])
 
247
        tree_b.add('d')
 
248
        tree_b.commit('commit d')
 
249
        out = self.runbzr('pull ../branch_a', retcode=3)
 
250
        self.assertEquals(out,
 
251
                ('','bzr: ERROR: These branches have diverged.  Try merge.\n'))
 
252
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
 
253
        # test implicit --remember after resolving previous failure
 
254
        uncommit(branch=branch_b, tree=tree_b)
 
255
        transport.delete('branch_b/d')
 
256
        self.runbzr('pull')
 
257
        self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
 
258
        # test explicit --remember
 
259
        self.runbzr('pull ../branch_c --remember')
 
260
        self.assertEquals(abspath(branch_b.get_parent()),
 
261
                          abspath(branch_c.bzrdir.root_transport.base))