~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
20
20
 
21
21
import os
22
22
 
23
 
from bzrlib.controldir import ControlDir
 
23
from bzrlib.bzrdir import BzrDir
24
24
from bzrlib import (
25
 
    osutils,
26
 
    urlutils,
27
 
    branch,
28
 
    )
 
25
        osutils,
 
26
        urlutils,
 
27
        branch,
 
28
        )
29
29
from bzrlib.workingtree import WorkingTree
30
30
from bzrlib.tests import (
31
 
    TestCaseWithTransport,
32
 
    script,
33
 
    )
 
31
        TestCaseWithTransport,
 
32
        script,
 
33
        )
34
34
from bzrlib.tests.features import UnicodeFilenameFeature
35
35
from bzrlib.directory_service import directories
36
36
 
153
153
        branchb_id = tree2.commit('bar')
154
154
        checkout = tree1.branch.create_checkout('heavyco/a', lightweight=False)
155
155
        self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a')
156
 
        # Refresh checkout as 'switch' modified it
157
 
        checkout = checkout.bzrdir.open_workingtree()
158
 
        self.assertEqual(branchb_id, checkout.last_revision())
159
 
        self.assertEqual(tree2.branch.base,
160
 
                         checkout.branch.get_bound_location())
161
 
 
162
 
    def test_switch_finds_relative_unicode_branch(self):
163
 
        """Switch will find 'foo' relative to the branch the checkout is of."""
164
 
        self.requireFeature(UnicodeFilenameFeature)
165
 
        self.build_tree(['repo/'])
166
 
        tree1 = self.make_branch_and_tree('repo/brancha')
167
 
        tree1.commit('foo')
168
 
        tree2 = self.make_branch_and_tree(u'repo/branch\xe9')
169
 
        tree2.pull(tree1.branch)
170
 
        branchb_id = tree2.commit('bar')
171
 
        checkout =  tree1.branch.create_checkout('checkout', lightweight=True)
172
 
        self.run_bzr(['switch', u'branch\xe9'], working_dir='checkout')
173
 
        self.assertEqual(branchb_id, checkout.last_revision())
174
 
        checkout = checkout.bzrdir.open_workingtree()
175
 
        self.assertEqual(tree2.branch.base, checkout.branch.base)
 
156
        self.assertEqual(branchb_id, checkout.last_revision())
 
157
        self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location())
176
158
 
177
159
    def test_switch_finds_relative_unicode_branch(self):
178
160
        """Switch will find 'foo' relative to the branch the checkout is of."""
205
187
        tree.add('file-2')
206
188
        revid2 = tree.commit('rev2')
207
189
        self.run_bzr(['switch', '-b', 'anotherbranch'])
208
 
        self.assertEqual(
 
190
        self.assertEquals(
209
191
            set(['', 'anotherbranch']),
210
192
            set(tree.branch.bzrdir.get_branches().keys()))
211
193
 
238
220
        otherbranch.generate_revision_history(revid1)
239
221
        self.run_bzr(['switch', 'anotherbranch'], working_dir='branch-1')
240
222
        tree = WorkingTree.open("branch-1")
241
 
        self.assertEqual(tree.last_revision(), revid1)
242
 
        self.assertEqual(tree.branch.control_url, otherbranch.control_url)
 
223
        self.assertEquals(tree.last_revision(), revid1)
 
224
        self.assertEquals(tree.branch.control_url, otherbranch.control_url)
243
225
 
244
226
    def test_switch_new_colocated(self):
245
227
        # Create a branch branch-1 that initially is a checkout of 'foo'
252
234
        tree.add('file-1')
253
235
        revid1 = tree.commit('rev1')
254
236
        self.run_bzr(['switch', '-b', 'anotherbranch'], working_dir='branch-1')
255
 
        bzrdir = ControlDir.open("branch-1")
256
 
        self.assertEqual(
 
237
        bzrdir = BzrDir.open("branch-1")
 
238
        self.assertEquals(
257
239
            set([b.name for b in bzrdir.list_branches()]),
258
240
            set(["foo", "anotherbranch"]))
259
 
        self.assertEqual(bzrdir.open_branch().name, "anotherbranch")
260
 
        self.assertEqual(bzrdir.open_branch().last_revision(), revid1)
 
241
        self.assertEquals(bzrdir.open_branch().name, "anotherbranch")
 
242
        self.assertEquals(bzrdir.open_branch().last_revision(), revid1)
261
243
 
262
244
    def test_switch_new_colocated_unicode(self):
263
245
        # Create a branch branch-1 that initially is a checkout of 'foo'
271
253
        tree.add('file-1')
272
254
        revid1 = tree.commit('rev1')
273
255
        self.run_bzr(['switch', '-b', u'branch\xe9'], working_dir='branch-1')
274
 
        bzrdir = ControlDir.open("branch-1")
275
 
        self.assertEqual(
 
256
        bzrdir = BzrDir.open("branch-1")
 
257
        self.assertEquals(
276
258
            set([b.name for b in bzrdir.list_branches()]),
277
259
            set(["foo", u"branch\xe9"]))
278
 
        self.assertEqual(bzrdir.open_branch().name, u"branch\xe9")
279
 
        self.assertEqual(bzrdir.open_branch().last_revision(), revid1)
 
260
        self.assertEquals(bzrdir.open_branch().name, u"branch\xe9")
 
261
        self.assertEquals(bzrdir.open_branch().last_revision(), revid1)
280
262
 
281
263
    def test_switch_only_revision(self):
282
264
        tree = self._create_sample_tree()
304
286
 
305
287
    def test_switch_lightweight_after_branch_moved_relative(self):
306
288
        self.prepare_lightweight_switch()
307
 
        self.run_bzr('switch --force branch1',
308
 
                     working_dir='tree')
 
289
        self.run_bzr('switch --force branch1', working_dir='tree')
309
290
        branch_location = WorkingTree.open('tree').branch.base
310
291
        self.assertEndsWith(branch_location, 'branch1/')
311
292
 
493
474
        self.assertLength(24, self.hpss_calls)
494
475
        self.assertLength(4, self.hpss_connections)
495
476
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
496
 
 
497
 
 
498
 
class TestSwitchUncommitted(TestCaseWithTransport):
499
 
 
500
 
    def prepare(self):
501
 
        tree = self.make_branch_and_tree('orig')
502
 
        tree.commit('')
503
 
        tree.branch.bzrdir.sprout('new')
504
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
505
 
        self.build_tree(['checkout/a'])
506
 
        self.assertPathExists('checkout/a')
507
 
        checkout.add('a')
508
 
        return checkout
509
 
 
510
 
    def test_store_and_restore_uncommitted(self):
511
 
        checkout = self.prepare()
512
 
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'new'])
513
 
        self.build_tree(['checkout/b'])
514
 
        checkout.add('b')
515
 
        self.assertPathDoesNotExist('checkout/a')
516
 
        self.assertPathExists('checkout/b')
517
 
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'orig'])
518
 
        self.assertPathExists('checkout/a')
519
 
        self.assertPathDoesNotExist('checkout/b')
520
 
 
521
 
    def test_does_not_store(self):
522
 
        self.prepare()
523
 
        self.run_bzr(['switch', '-d', 'checkout', 'new'])
524
 
        self.assertPathExists('checkout/a')
525
 
 
526
 
    def test_does_not_restore_changes(self):
527
 
        self.prepare()
528
 
        self.run_bzr(['switch', '--store', '-d', 'checkout', 'new'])
529
 
        self.assertPathDoesNotExist('checkout/a')
530
 
        self.run_bzr(['switch', '-d', 'checkout', 'orig'])
531
 
        self.assertPathDoesNotExist('checkout/a')