~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2009-11-25 07:27:43 UTC
  • mto: This revision was merged to the branch mainline in revision 4825.
  • Revision ID: andrew.bennetts@canonical.com-20091125072743-v6sv4m2mkt9iyslp
Terminate SSHSubprocesses when no refs to them are left, in case .close is never called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 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
20
20
import os
21
21
import sys
22
22
 
23
 
from bzrlib import (
24
 
    debug,
25
 
    remote,
26
 
    urlutils,
27
 
    )
28
 
 
29
23
from bzrlib.branch import Branch
30
24
from bzrlib.directory_service import directories
31
25
from bzrlib.osutils import pathjoin
32
 
from bzrlib.tests import (
33
 
    fixtures,
34
 
    TestCaseWithTransport,
35
 
    )
 
26
from bzrlib.tests.blackbox import ExternalBase
36
27
from bzrlib.uncommit import uncommit
37
28
from bzrlib.workingtree import WorkingTree
38
 
 
39
 
 
40
 
class TestPull(TestCaseWithTransport):
 
29
from bzrlib import urlutils
 
30
 
 
31
 
 
32
class TestPull(ExternalBase):
41
33
 
42
34
    def example_branch(self, path='.'):
43
35
        tree = self.make_branch_and_tree(path)
145
137
        self.run_bzr('pull -r 4')
146
138
        self.assertEqual(a.revision_history(), b.revision_history())
147
139
 
148
 
    def test_pull_tags(self):
149
 
        """Tags are updated by pull, and revisions named in those tags are
150
 
        fetched.
151
 
        """
152
 
        # Make a source, sprout a target off it
153
 
        builder = self.make_branch_builder('source')
154
 
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
155
 
        target_bzrdir = source.bzrdir.sprout('target')
156
 
        source.tags.set_tag('tag-a', 'rev-2')
157
 
        # Pull from source
158
 
        self.run_bzr('pull -d target source')
159
 
        target = target_bzrdir.open_branch()
160
 
        # The tag is present, and so is its revision.
161
 
        self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
162
 
        target.repository.get_revision('rev-2')
163
140
 
164
141
    def test_overwrite_uptodate(self):
165
142
        # Make sure pull --overwrite overwrites
361
338
            def look_up(self, name, url):
362
339
                return 'source'
363
340
        directories.register('foo:', FooService, 'Testing directory service')
364
 
        self.addCleanup(directories.remove, 'foo:')
 
341
        self.addCleanup(lambda: directories.remove('foo:'))
365
342
        self.run_bzr('pull foo:bar -d target')
366
343
        self.assertEqual(source_last, target.last_revision())
367
344
 
413
390
        self.assertLength(18, self.hpss_calls)
414
391
        remote = Branch.open('stacked')
415
392
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
416
 
    
417
 
    def test_pull_cross_format_warning(self):
418
 
        """You get a warning for probably slow cross-format pulls.
419
 
        """
420
 
        # this is assumed to be going through InterDifferingSerializer
421
 
        from_tree = self.make_branch_and_tree('from', format='2a')
422
 
        to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
423
 
        from_tree.commit(message='first commit')
424
 
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
425
 
        self.assertContainsRe(err,
426
 
            "(?m)Doing on-the-fly conversion")
427
 
 
428
 
    def test_pull_cross_format_warning_no_IDS(self):
429
 
        """You get a warning for probably slow cross-format pulls.
430
 
        """
431
 
        # this simulates what would happen across the network, where
432
 
        # interdifferingserializer is not active
433
 
 
434
 
        debug.debug_flags.add('IDS_never')
435
 
        # TestCase take care of restoring them
436
 
 
437
 
        from_tree = self.make_branch_and_tree('from', format='2a')
438
 
        to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
439
 
        from_tree.commit(message='first commit')
440
 
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
441
 
        self.assertContainsRe(err,
442
 
            "(?m)Doing on-the-fly conversion")
443
 
 
444
 
    def test_pull_cross_format_from_network(self):
445
 
        self.setup_smart_server_with_call_log()
446
 
        from_tree = self.make_branch_and_tree('from', format='2a')
447
 
        to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
448
 
        self.assertIsInstance(from_tree.branch, remote.RemoteBranch)
449
 
        from_tree.commit(message='first commit')
450
 
        out, err = self.run_bzr(['pull', '-d', 'to',
451
 
            from_tree.branch.bzrdir.root_transport.base])
452
 
        self.assertContainsRe(err,
453
 
            "(?m)Doing on-the-fly conversion")
454
 
 
455
 
    def test_pull_to_experimental_format_warning(self):
456
 
        """You get a warning for pulling into experimental formats.
457
 
        """
458
 
        from_tree = self.make_branch_and_tree('from', format='development-subtree')
459
 
        to_tree = self.make_branch_and_tree('to', format='development-subtree')
460
 
        from_tree.commit(message='first commit')
461
 
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
462
 
        self.assertContainsRe(err,
463
 
            "(?m)Fetching into experimental format")
464
 
 
465
 
    def test_pull_cross_to_experimental_format_warning(self):
466
 
        """You get a warning for pulling into experimental formats.
467
 
        """
468
 
        from_tree = self.make_branch_and_tree('from', format='2a')
469
 
        to_tree = self.make_branch_and_tree('to', format='development-subtree')
470
 
        from_tree.commit(message='first commit')
471
 
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
472
 
        self.assertContainsRe(err,
473
 
            "(?m)Fetching into experimental format")
474
 
 
475
 
    def test_pull_show_base(self):
476
 
        """bzr pull supports --show-base
477
 
 
478
 
        see https://bugs.launchpad.net/bzr/+bug/202374"""
479
 
        # create two trees with conflicts, setup conflict, check that
480
 
        # conflicted file looks correct
481
 
        a_tree = self.example_branch('a')
482
 
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
483
 
 
484
 
        f = open(pathjoin('a', 'hello'),'wt')
485
 
        f.write('fee')
486
 
        f.close()
487
 
        a_tree.commit('fee')
488
 
 
489
 
        f = open(pathjoin('b', 'hello'),'wt')
490
 
        f.write('fie')
491
 
        f.close()
492
 
 
493
 
        out,err=self.run_bzr(['pull','-d','b','a','--show-base'])
494
 
 
495
 
        # check for message here
496
 
        self.assertEqual(err,
497
 
                         ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
498
 
 
499
 
        self.assertEqualDiff('<<<<<<< TREE\n'
500
 
                             'fie||||||| BASE-REVISION\n'
501
 
                             'foo=======\n'
502
 
                             'fee>>>>>>> MERGE-SOURCE\n',
503
 
                             open(pathjoin('b', 'hello')).read())
504
 
 
505
 
    def test_pull_show_base_working_tree_only(self):
506
 
        """--show-base only allowed if there's a working tree
507
 
 
508
 
        see https://bugs.launchpad.net/bzr/+bug/202374"""
509
 
        # create a branch, see that --show-base fails
510
 
        self.make_branch('from')
511
 
        self.make_branch('to')
512
 
        out=self.run_bzr(['pull','-d','to','from','--show-base'],retcode=3)
513
 
        self.assertEqual(out,
514
 
                         ('','bzr: ERROR: Need working tree for --show-base.\n'))
515
 
 
516
 
    def test_pull_tag_conflicts(self):
517
 
        """pulling tags with conflicts will change the exit code"""
518
 
        # create a branch, see that --show-base fails
519
 
        from_tree = self.make_branch_and_tree('from')
520
 
        from_tree.branch.tags.set_tag("mytag", "somerevid")
521
 
        to_tree = self.make_branch_and_tree('to')
522
 
        to_tree.branch.tags.set_tag("mytag", "anotherrevid")
523
 
        out = self.run_bzr(['pull','-d','to','from'],retcode=1)
524
 
        self.assertEqual(out,
525
 
            ('No revisions to pull.\nConflicting tags:\n    mytag\n', ''))
 
393