~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Matthew Fuller
  • Date: 2009-08-18 08:10:44 UTC
  • mto: (4772.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4773.
  • Revision ID: fullermd@over-yonder.net-20090818081044-2due6ius01c4pwjl
Fix up some doctests to handle things ending up as RevisionSpec_dwim's
instead of RS_revno, and ending up as _dwim's (which may error
eventually, but won't until we try to evaluate them) instead of
insta-errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007, 2008 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
31
31
    workingtree
32
32
    )
33
33
from bzrlib.repofmt import knitrepo
34
 
from bzrlib.tests import (
35
 
    blackbox,
36
 
    http_server,
37
 
    test_foreign,
38
 
    test_server,
39
 
    )
 
34
from bzrlib.tests import http_server
40
35
from bzrlib.transport import memory
41
36
 
42
37
 
139
134
 
140
135
    def test_push_without_tree(self):
141
136
        # bzr push from a branch that does not have a checkout should work.
 
137
        self.thisFailsStrictLockCheck()
142
138
        b = self.make_branch('.')
143
139
        out, err = self.run_bzr('push pushed-location')
144
140
        self.assertEqual('', out)
150
146
        # bzr push of a branch with revisions to a new location
151
147
        # should print the number of revisions equal to the length of the
152
148
        # local branch.
 
149
        self.thisFailsStrictLockCheck()
153
150
        t = self.make_branch_and_tree('tree')
154
151
        self.build_tree(['tree/file'])
155
152
        t.add('file')
160
157
 
161
158
    def test_push_only_pushes_history(self):
162
159
        # Knit branches should only push the history for the current revision.
 
160
        self.thisFailsStrictLockCheck()
163
161
        format = bzrdir.BzrDirMetaFormat1()
164
162
        format.repository_format = knitrepo.RepositoryFormatKnit1()
165
163
        shared_repo = self.make_repository('repo', format=format, shared=True)
197
195
        self.assertTrue(pushed_repo.has_revision('b-1'))
198
196
 
199
197
    def test_push_funky_id(self):
 
198
        self.thisFailsStrictLockCheck()
200
199
        t = self.make_branch_and_tree('tree')
201
200
        self.build_tree(['tree/filename'])
202
201
        t.add('filename', 'funky-chars<>%&;"\'')
204
203
        self.run_bzr('push -d tree new-tree')
205
204
 
206
205
    def test_push_dash_d(self):
 
206
        self.thisFailsStrictLockCheck()
207
207
        t = self.make_branch_and_tree('from')
208
208
        t.commit(allow_pointless=True,
209
209
                message='first commit')
258
258
        # upwards without agreement from bzr's network support maintainers.
259
259
        self.assertLength(11, self.hpss_calls)
260
260
 
261
 
    def test_push_smart_incremental_acceptance(self):
262
 
        self.setup_smart_server_with_call_log()
263
 
        t = self.make_branch_and_tree('from')
264
 
        rev_id1 = t.commit(allow_pointless=True, message='first commit')
265
 
        rev_id2 = t.commit(allow_pointless=True, message='second commit')
266
 
        self.run_bzr(
267
 
            ['push', self.get_url('to-one'), '-r1'], working_dir='from')
268
 
        self.reset_smart_call_log()
269
 
        self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
270
 
        # This figure represent the amount of work to perform this use case. It
271
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
272
 
        # being too low. If rpc_count increases, more network roundtrips have
273
 
        # become necessary for this use case. Please do not adjust this number
274
 
        # upwards without agreement from bzr's network support maintainers.
275
 
        self.assertLength(11, self.hpss_calls)
276
 
 
277
261
    def test_push_smart_with_default_stacking_url_path_segment(self):
278
262
        # If the default stacked-on location is a path element then branches
279
263
        # we push there over the smart server are stacked and their
308
292
 
309
293
    def test_push_create_prefix(self):
310
294
        """'bzr push --create-prefix' will create leading directories."""
 
295
        self.thisFailsStrictLockCheck()
311
296
        tree = self.create_simple_tree()
312
297
 
313
298
        self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
324
309
 
325
310
        By default, 'bzr push' will not use an existing, non-versioned dir.
326
311
        """
 
312
        self.thisFailsStrictLockCheck()
327
313
        tree = self.create_simple_tree()
328
314
        self.build_tree(['target/'])
329
315
 
340
326
        # The push should have created target/a
341
327
        self.failUnlessExists('target/a')
342
328
 
343
 
    def test_push_use_existing_into_empty_bzrdir(self):
344
 
        """'bzr push --use-existing-dir' into a dir with an empty .bzr dir
345
 
        fails.
346
 
        """
347
 
        tree = self.create_simple_tree()
348
 
        self.build_tree(['target/', 'target/.bzr/'])
349
 
        self.run_bzr_error(
350
 
            ['Target directory ../target already contains a .bzr directory, '
351
 
             'but it is not valid.'],
352
 
            'push ../target --use-existing-dir', working_dir='tree')
353
 
 
354
329
    def test_push_onto_repo(self):
355
330
        """We should be able to 'bzr push' into an existing bzrdir."""
356
331
        tree = self.create_simple_tree()
383
358
 
384
359
    def test_push_with_revisionspec(self):
385
360
        """We should be able to push a revision older than the tip."""
 
361
        self.thisFailsStrictLockCheck()
386
362
        tree_from = self.make_branch_and_tree('from')
387
363
        tree_from.commit("One.", rev_id="from-1")
388
364
        tree_from.commit("Two.", rev_id="from-2")
424
400
 
425
401
    def test_push_new_branch_stacked_on(self):
426
402
        """Pushing a new branch with --stacked-on creates a stacked branch."""
 
403
        self.thisFailsStrictLockCheck()
427
404
        trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
428
405
        # we publish branch_tree with a reference to the mainline.
429
406
        out, err = self.run_bzr(['push', '--stacked-on', trunk_tree.branch.base,
436
413
 
437
414
    def test_push_new_branch_stacked_uses_parent_when_no_public_url(self):
438
415
        """When the parent has no public url the parent is used as-is."""
 
416
        self.thisFailsStrictLockCheck()
439
417
        trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
440
418
        # now we do a stacked push, which should determine the public location
441
419
        # for us.
449
427
 
450
428
    def test_push_new_branch_stacked_uses_parent_public(self):
451
429
        """Pushing a new branch with --stacked creates a stacked branch."""
 
430
        self.thisFailsStrictLockCheck()
452
431
        trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
453
432
        # the trunk is published on a web server
454
433
        self.transport_readonly_server = http_server.HttpServer
533
512
        out, err = self.run_bzr('push -d repo/local remote -r 3')
534
513
 
535
514
    def test_push_verbose_shows_log(self):
 
515
        self.thisFailsStrictLockCheck()
536
516
        tree = self.make_branch_and_tree('source')
537
517
        tree.commit('rev1')
538
518
        out, err = self.run_bzr('push -v -d source target')
546
526
        self.assertNotContainsRe(out, 'rev1')
547
527
 
548
528
    def test_push_from_subdir(self):
 
529
        self.thisFailsStrictLockCheck()
549
530
        t = self.make_branch_and_tree('tree')
550
531
        self.build_tree(['tree/dir/', 'tree/dir/file'])
551
532
        t.add('dir', 'dir/file')
585
566
 
586
567
class RedirectingMemoryServer(memory.MemoryServer):
587
568
 
588
 
    def start_server(self):
 
569
    def setUp(self):
589
570
        self._dirs = {'/': None}
590
571
        self._files = {}
591
572
        self._locks = {}
599
580
        result._locks = self._locks
600
581
        return result
601
582
 
602
 
    def stop_server(self):
 
583
    def tearDown(self):
603
584
        transport.unregister_transport(self._scheme, self._memory_factory)
604
585
 
605
586
 
608
589
    def setUp(self):
609
590
        tests.TestCaseWithTransport.setUp(self)
610
591
        self.memory_server = RedirectingMemoryServer()
611
 
        self.start_server(self.memory_server)
 
592
        self.memory_server.setUp()
 
593
        self.addCleanup(self.memory_server.tearDown)
 
594
 
612
595
        # Make the branch and tree that we'll be pushing.
613
596
        t = self.make_branch_and_tree('tree')
614
597
        self.build_tree(['tree/file'])
687
670
        self.make_local_branch_and_tree()
688
671
 
689
672
    def test_push_default(self):
 
673
        self.thisFailsStrictLockCheck()
690
674
        self.assertPushSucceeds([])
691
675
 
692
676
    def test_push_strict(self):
 
677
        self.thisFailsStrictLockCheck()
693
678
        self.assertPushSucceeds(['--strict'])
694
679
 
695
680
    def test_push_no_strict(self):
 
681
        self.thisFailsStrictLockCheck()
696
682
        self.assertPushSucceeds(['--no-strict'])
697
683
 
698
684
    def test_push_config_var_strict(self):
 
685
        self.thisFailsStrictLockCheck()
699
686
        self.set_config_push_strict('true')
700
687
        self.assertPushSucceeds([])
701
688
 
702
689
    def test_push_config_var_no_strict(self):
 
690
        self.thisFailsStrictLockCheck()
703
691
        self.set_config_push_strict('false')
704
692
        self.assertPushSucceeds([])
705
693
 
711
699
 
712
700
    def setUp(self):
713
701
        super(TestPushStrictWithChanges, self).setUp()
714
 
        # Apply the changes defined in load_tests: one of _uncommitted_changes,
715
 
        # _pending_merges or _out_of_sync_trees
716
702
        getattr(self, self._changes_type)()
717
703
 
718
704
    def _uncommitted_changes(self):
748
734
        self.assertPushFails([])
749
735
 
750
736
    def test_push_with_revision(self):
 
737
        self.thisFailsStrictLockCheck()
751
738
        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
752
739
 
753
740
    def test_push_no_strict(self):
 
741
        self.thisFailsStrictLockCheck()
754
742
        self.assertPushSucceeds(['--no-strict'])
755
743
 
756
744
    def test_push_strict_with_changes(self):
765
753
        self.assertPushFails([])
766
754
 
767
755
    def test_push_no_strict_command_line_override_config(self):
 
756
        self.thisFailsStrictLockCheck()
768
757
        self.set_config_push_strict('yES')
769
758
        self.assertPushFails([])
770
759
        self.assertPushSucceeds(['--no-strict'])
771
760
 
772
761
    def test_push_strict_command_line_override_config(self):
 
762
        self.thisFailsStrictLockCheck()
773
763
        self.set_config_push_strict('oFF')
774
764
        self.assertPushFails(['--strict'])
775
765
        self.assertPushSucceeds([])
776
 
 
777
 
 
778
 
class TestPushForeign(blackbox.ExternalBase):
779
 
 
780
 
    def setUp(self):
781
 
        super(TestPushForeign, self).setUp()
782
 
        test_foreign.register_dummy_foreign_for_test(self)
783
 
 
784
 
    def make_dummy_builder(self, relpath):
785
 
        builder = self.make_branch_builder(
786
 
            relpath, format=test_foreign.DummyForeignVcsDirFormat())
787
 
        builder.build_snapshot('revid', None,
788
 
            [('add', ('', 'TREE_ROOT', 'directory', None)),
789
 
             ('add', ('foo', 'fooid', 'file', 'bar'))])
790
 
        return builder
791
 
 
792
 
    def test_no_roundtripping(self):
793
 
        target_branch = self.make_dummy_builder('dp').get_branch()
794
 
        source_tree = self.make_branch_and_tree("dc")
795
 
        output, error = self.run_bzr("push -d dc dp", retcode=3)
796
 
        self.assertEquals("", output)
797
 
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
798
 
            " push to dummy. You may want to use dpush instead.\n")