~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

resolve conflicts against trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib.tests import (
31
31
    fixtures,
32
32
    HardlinkFeature,
 
33
    script,
33
34
    test_server,
34
35
    )
 
36
from bzrlib.tests.blackbox import test_switch
35
37
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
 
38
from bzrlib.tests.script import run_script
36
39
from bzrlib.urlutils import local_path_to_url, strip_trailing_slash
37
40
from bzrlib.workingtree import WorkingTree
38
41
 
179
182
        source.add('file1')
180
183
        source.commit('added file')
181
184
        out, err = self.run_bzr('branch source target --files-from source')
182
 
        self.failUnlessExists('target/file1')
 
185
        self.assertPathExists('target/file1')
183
186
 
184
187
    def test_branch_files_from_hardlink(self):
185
188
        self.requireFeature(HardlinkFeature)
208
211
    def test_branch_no_tree(self):
209
212
        self.example_branch('source')
210
213
        self.run_bzr('branch --no-tree source target')
211
 
        self.failIfExists('target/hello')
212
 
        self.failIfExists('target/goodbye')
 
214
        self.assertPathDoesNotExist('target/hello')
 
215
        self.assertPathDoesNotExist('target/goodbye')
213
216
 
214
217
    def test_branch_into_existing_dir(self):
215
218
        self.example_branch('a')
225
228
        # force operation
226
229
        self.run_bzr('branch a b --use-existing-dir')
227
230
        # check conflicts
228
 
        self.failUnlessExists('b/hello.moved')
229
 
        self.failIfExists('b/godbye.moved')
 
231
        self.assertPathExists('b/hello.moved')
 
232
        self.assertPathDoesNotExist('b/godbye.moved')
230
233
        # we can't branch into branch
231
234
        out,err = self.run_bzr('branch a b --use-existing-dir', retcode=3)
232
235
        self.assertEqual('', out)
477
480
        # upwards without agreement from bzr's network support maintainers.
478
481
        self.assertLength(9, self.hpss_calls)
479
482
 
 
483
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
 
484
        self.setup_smart_server_with_call_log()
 
485
        t = self.make_branch_and_tree('from')
 
486
        for count in range(9):
 
487
            t.commit(message='commit %d' % count)
 
488
        self.reset_smart_call_log()
 
489
        out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
 
490
            'local-target'])
 
491
        # XXX: the number of hpss calls for this case isn't deterministic yet,
 
492
        # so we can't easily assert about the number of calls.
 
493
        #self.assertLength(XXX, self.hpss_calls)
 
494
        # We can assert that none of the calls were readv requests for rix
 
495
        # files, though (demonstrating that at least get_parent_map calls are
 
496
        # not using VFS RPCs).
 
497
        readvs_of_rix_files = [
 
498
            c for c in self.hpss_calls
 
499
            if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
 
500
        self.assertLength(0, readvs_of_rix_files)
 
501
 
480
502
 
481
503
class TestRemoteBranch(TestCaseWithSFTPServer):
482
504
 
501
523
        # Ensure that no working tree what created remotely
502
524
        self.assertFalse(t.has('remote/file'))
503
525
 
 
526
 
 
527
class TestDeprecatedAliases(TestCaseWithTransport):
 
528
 
 
529
    def test_deprecated_aliases(self):
 
530
        """bzr branch can be called clone or get, but those names are deprecated.
 
531
 
 
532
        See bug 506265.
 
533
        """
 
534
        for command in ['clone', 'get']:
 
535
            run_script(self, """
 
536
            $ bzr %(command)s A B
 
537
            2>The command 'bzr %(command)s' has been deprecated in bzr 2.4. Please use 'bzr branch' instead.
 
538
            2>bzr: ERROR: Not a branch...
 
539
            """ % locals())
 
540
 
 
541
 
 
542
class TestBranchParentLocation(test_switch.TestSwitchParentLocationBase):
 
543
 
 
544
    def _checkout_and_branch(self, option=''):
 
545
        self.script_runner.run_script(self, '''
 
546
                $ bzr checkout %(option)s repo/trunk checkout
 
547
                $ cd checkout
 
548
                $ bzr branch --switch ../repo/trunk ../repo/branched
 
549
                2>Branched 0 revision(s).
 
550
                2>Tree is up to date at revision 0.
 
551
                2>Switched to branch:...branched...
 
552
                $ cd ..
 
553
                ''' % locals())
 
554
        bound_branch = branch.Branch.open_containing('checkout')[0]
 
555
        master_branch = branch.Branch.open_containing('repo/branched')[0]
 
556
        return (bound_branch, master_branch)
 
557
 
 
558
    def test_branch_switch_parent_lightweight(self):
 
559
        """Lightweight checkout using bzr branch --switch."""
 
560
        bb, mb = self._checkout_and_branch(option='--lightweight')
 
561
        self.assertParent('repo/trunk', bb)
 
562
        self.assertParent('repo/trunk', mb)
 
563
 
 
564
    def test_branch_switch_parent_heavyweight(self):
 
565
        """Heavyweight checkout using bzr branch --switch."""
 
566
        bb, mb = self._checkout_and_branch()
 
567
        self.assertParent('repo/trunk', bb)
 
568
        self.assertParent('repo/trunk', mb)