~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 11:43:10 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909114310-glw7tv76i5gnx9pt
put rules back in Makefile supporting plain-style docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Black-box tests for bzr pull."""
21
21
import sys
22
22
 
23
23
from bzrlib.branch import Branch
 
24
from bzrlib.directory_service import directories
24
25
from bzrlib.osutils import pathjoin
25
26
from bzrlib.tests.blackbox import ExternalBase
26
27
from bzrlib.uncommit import uncommit
238
239
        out = self.run_bzr('pull ../branch_a', retcode=3)
239
240
        self.assertEqual(out,
240
241
                ('','bzr: ERROR: These branches have diverged.'
241
 
                    ' Use the merge command to reconcile them.\n'))
 
242
                    ' Use the missing command to see how.\n'
 
243
                    'Use the merge command to reconcile them.\n'))
242
244
        self.assertEqual(branch_b.get_parent(), parent)
243
245
        # test implicit --remember after resolving previous failure
244
246
        uncommit(branch=branch_b, tree=tree_b)
305
307
        self.assertContainsRe(out, 'bar')
306
308
        self.assertNotContainsRe(out, 'added:')
307
309
        self.assertNotContainsRe(out, 'foo')
 
310
 
 
311
    def test_pull_quiet(self):
 
312
        """Check that bzr pull --quiet does not print anything"""
 
313
        tree_a = self.make_branch_and_tree('tree_a')
 
314
        self.build_tree(['tree_a/foo'])
 
315
        tree_a.add('foo')
 
316
        revision_id = tree_a.commit('bar')
 
317
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
 
318
        out, err = self.run_bzr('pull --quiet -d tree_b')
 
319
        self.assertEqual(out, '')
 
320
        self.assertEqual(err, '')
 
321
        self.assertEqual(tree_b.last_revision(), revision_id)
 
322
        self.build_tree(['tree_a/moo'])
 
323
        tree_a.add('moo')
 
324
        revision_id = tree_a.commit('quack')
 
325
        out, err = self.run_bzr('pull --quiet -d tree_b')
 
326
        self.assertEqual(out, '')
 
327
        self.assertEqual(err, '')
 
328
        self.assertEqual(tree_b.last_revision(), revision_id)
 
329
 
 
330
    def test_pull_from_directory_service(self):
 
331
        source = self.make_branch_and_tree('source')
 
332
        source.commit('commit 1')
 
333
        target = source.bzrdir.sprout('target').open_workingtree()
 
334
        source_last = source.commit('commit 2')
 
335
        class FooService(object):
 
336
            """A directory service that always returns source"""
 
337
 
 
338
            def look_up(self, name, url):
 
339
                return 'source'
 
340
        directories.register('foo:', FooService, 'Testing directory service')
 
341
        self.addCleanup(lambda: directories.remove('foo:'))
 
342
        self.run_bzr('pull foo:bar -d target')
 
343
        self.assertEqual(source_last, target.last_revision())
 
344
 
 
345
    def test_pull_verbose_defaults_to_long(self):
 
346
        tree = self.example_branch('source')
 
347
        target = self.make_branch_and_tree('target')
 
348
        out = self.run_bzr('pull -v source -d target')[0]
 
349
        self.assertContainsRe(out,
 
350
                              r'revno: 1\ncommitter: .*\nbranch nick: source')
 
351
        self.assertNotContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
 
352
 
 
353
    def test_pull_verbose_uses_default_log(self):
 
354
        tree = self.example_branch('source')
 
355
        target = self.make_branch_and_tree('target')
 
356
        target_config = target.branch.get_config()
 
357
        target_config.set_user_option('log_format', 'short')
 
358
        out = self.run_bzr('pull -v source -d target')[0]
 
359
        self.assertContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
 
360
        self.assertNotContainsRe(
 
361
            out, r'revno: 1\ncommitter: .*\nbranch nick: source')
 
362
 
 
363
    def test_pull_smart_stacked_streaming_acceptance(self):
 
364
        """'bzr pull -r 123' works on stacked, smart branches, even when the
 
365
        revision specified by the revno is only present in the fallback
 
366
        repository.
 
367
 
 
368
        See <https://launchpad.net/bugs/380314>
 
369
        """
 
370
        self.setup_smart_server_with_call_log()
 
371
        # Make a stacked-on branch with two commits so that the
 
372
        # revision-history can't be determined just by looking at the parent
 
373
        # field in the revision in the stacked repo.
 
374
        parent = self.make_branch_and_tree('parent', format='1.9')
 
375
        parent.commit(message='first commit')
 
376
        parent.commit(message='second commit')
 
377
        local = parent.bzrdir.sprout('local').open_workingtree()
 
378
        local.commit(message='local commit')
 
379
        local.branch.create_clone_on_transport(
 
380
            self.get_transport('stacked'), stacked_on=self.get_url('parent'))
 
381
        empty = self.make_branch_and_tree('empty', format='1.9')
 
382
        self.reset_smart_call_log()
 
383
        self.run_bzr(['pull', '-r', '1', self.get_url('stacked')],
 
384
            working_dir='empty')
 
385
        # This figure represent the amount of work to perform this use case. It
 
386
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
387
        # being too low. If rpc_count increases, more network roundtrips have
 
388
        # become necessary for this use case. Please do not adjust this number
 
389
        # upwards without agreement from bzr's network support maintainers.
 
390
        self.assertLength(18, self.hpss_calls)
 
391
        remote = Branch.open('stacked')
 
392
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
 
393