~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2013-05-19 14:29:37 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: (6437.63.10 2.5)
  • mto: This revision was merged to the branch mainline in revision 6575.
  • Revision ID: john@arbash-meinel.com-20130519142937-21ykz2n2y2f22za9
Merge in the actual 2.5 branch. It seems I failed before

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 
58
58
class TestWorkingTree(TestCaseWithWorkingTree):
59
59
 
 
60
    def requireBranchReference(self):
 
61
        test_branch = self.make_branch('test-branch')
 
62
        try:
 
63
            # if there is a working tree now, this is not supported.
 
64
            test_branch.bzrdir.open_workingtree()
 
65
            raise TestNotApplicable("only on trees that can be separate"
 
66
                " from their branch.")
 
67
        except (errors.NoWorkingTree, errors.NotLocalUrl):
 
68
            pass
 
69
 
60
70
    def test_branch_builder(self):
61
71
        # Just a smoke test that we get a branch at the specified relpath
62
72
        builder = self.make_branch_builder('foobar')
63
 
        br = branch.Branch.open('foobar')
 
73
        br = branch.Branch.open(self.get_url('foobar'))
64
74
 
65
75
    def test_list_files(self):
66
76
        tree = self.make_branch_and_tree('.')
122
132
                         result[0][:4])
123
133
 
124
134
    def test_open_containing(self):
125
 
        branch = self.make_branch_and_tree('.').branch
126
 
        local_base = urlutils.local_path_from_url(branch.base)
 
135
        local_wt = self.make_branch_and_tree('.')
 
136
        local_url = local_wt.bzrdir.root_transport.base
 
137
        local_base = urlutils.local_path_from_url(local_url)
 
138
        del local_wt
127
139
 
128
140
        # Empty opens '.'
129
141
        wt, relpath = WorkingTree.open_containing()
161
173
 
162
174
    def test_lock_locks_branch(self):
163
175
        tree = self.make_branch_and_tree('.')
 
176
        self.assertEqual(None, tree.branch.peek_lock_mode())
164
177
        tree.lock_read()
165
178
        self.assertEqual('r', tree.branch.peek_lock_mode())
166
179
        tree.unlock()
362
375
        # that formats where initialising a branch does not initialise a
363
376
        # tree - and thus have separable entities - support skewing the
364
377
        # two things.
365
 
        branch = self.make_branch('tree')
366
 
        try:
367
 
            # if there is a working tree now, this is not supported.
368
 
            branch.bzrdir.open_workingtree()
369
 
            return
370
 
        except errors.NoWorkingTree:
371
 
            pass
372
 
        wt = branch.bzrdir.create_workingtree()
 
378
        self.requireBranchReference()
 
379
        wt = self.make_branch_and_tree('tree')
373
380
        wt.commit('A', allow_pointless=True, rev_id='A')
374
381
        wt.set_last_revision(None)
375
382
        self.assertEqual([], wt.get_parent_ids())
478
485
        # that formats where initialising a branch does not initialise a
479
486
        # tree - and thus have separable entities - support skewing the
480
487
        # two things.
481
 
        main_branch = self.make_branch('tree')
482
 
        try:
483
 
            # if there is a working tree now, this is not supported.
484
 
            main_branch.bzrdir.open_workingtree()
485
 
            return
486
 
        except errors.NoWorkingTree:
487
 
            pass
488
 
        wt = main_branch.bzrdir.create_workingtree()
 
488
        self.requireBranchReference()
 
489
        wt = self.make_branch_and_tree('tree')
489
490
        # create an out of date working tree by making a checkout in this
490
491
        # current format
491
492
        self.build_tree(['checkout/', 'tree/file'])
492
493
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
493
 
        checkout.set_branch_reference(main_branch)
 
494
        checkout.set_branch_reference(wt.branch)
494
495
        old_tree = self.workingtree_format.initialize(checkout)
495
496
        # now commit to 'tree'
496
497
        wt.add('file')
545
546
        # that formats where initialising a branch does not initialise a
546
547
        # tree - and thus have separable entities - support skewing the
547
548
        # two things.
548
 
        main_branch = self.make_branch('tree')
549
 
        try:
550
 
            # if there is a working tree now, this is not supported.
551
 
            main_branch.bzrdir.open_workingtree()
552
 
            return
553
 
        except errors.NoWorkingTree:
554
 
            pass
555
 
        wt = main_branch.bzrdir.create_workingtree()
 
549
        self.requireBranchReference()
 
550
        wt = self.make_branch_and_tree('tree')
556
551
        # create an out of date working tree by making a checkout in this
557
552
        # current format
558
553
        self.build_tree(['checkout/', 'tree/file'])
559
554
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
560
 
        checkout.set_branch_reference(main_branch)
 
555
        checkout.set_branch_reference(wt.branch)
561
556
        old_tree = self.workingtree_format.initialize(checkout)
562
557
        # now commit to 'tree'
563
558
        wt.add('file')