/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2008-07-09 21:42:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080709214224-r75k87r6a01pfc3h
Restore a real weave merge to 'bzr merge --weave'.

To do so efficiently, we only add the simple LCAs to the final weave
object, unless we run into complexities with the merge graph.
This gives the same effective result as adding all the texts,
with the advantage of not having to extract all of them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Test for 'bzr mv'"""
18
18
 
19
19
import os
20
20
 
21
 
import bzrlib.branch
22
21
from bzrlib import (
23
22
    osutils,
24
23
    workingtree,
78
77
 
79
78
    def test_mv_unqualified(self):
80
79
        self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv')
81
 
 
 
80
        
82
81
    def test_mv_invalid(self):
83
82
        tree = self.make_branch_and_tree('.')
84
83
        self.build_tree(['test.txt', 'sub1/'])
92
91
            ["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
93
92
             "sub1 is not versioned\.$"],
94
93
            'mv test.txt sub1/hello.txt')
95
 
 
 
94
        
96
95
    def test_mv_dirs(self):
97
96
        tree = self.make_branch_and_tree('.')
98
97
        self.build_tree(['hello.txt', 'sub1/'])
431
430
        self.assertNotInWorkingTree('c')
432
431
        self.failUnlessExists('d')
433
432
        self.assertInWorkingTree('d')
434
 
 
435
 
    def make_abcd_tree(self):
436
 
        tree = self.make_branch_and_tree('tree')
437
 
        self.build_tree(['tree/a', 'tree/c'])
438
 
        tree.add(['a', 'c'])
439
 
        tree.commit('record old names')
440
 
        osutils.rename('tree/a', 'tree/b')
441
 
        osutils.rename('tree/c', 'tree/d')
442
 
        return tree
443
 
 
444
 
    def test_mv_auto(self):
445
 
        self.make_abcd_tree()
446
 
        out, err = self.run_bzr('mv --auto', working_dir='tree')
447
 
        self.assertEqual(out, '')
448
 
        self.assertEqual(err, 'a => b\nc => d\n')
449
 
        tree = workingtree.WorkingTree.open('tree')
450
 
        self.assertIsNot(None, tree.path2id('b'))
451
 
        self.assertIsNot(None, tree.path2id('d'))
452
 
 
453
 
    def test_mv_auto_one_path(self):
454
 
        self.make_abcd_tree()
455
 
        out, err = self.run_bzr('mv --auto tree')
456
 
        self.assertEqual(out, '')
457
 
        self.assertEqual(err, 'a => b\nc => d\n')
458
 
        tree = workingtree.WorkingTree.open('tree')
459
 
        self.assertIsNot(None, tree.path2id('b'))
460
 
        self.assertIsNot(None, tree.path2id('d'))
461
 
 
462
 
    def test_mv_auto_two_paths(self):
463
 
        self.make_abcd_tree()
464
 
        out, err = self.run_bzr('mv --auto tree tree2', retcode=3)
465
 
        self.assertEqual('bzr: ERROR: Only one path may be specified to'
466
 
                         ' --auto.\n', err)
467
 
 
468
 
    def test_mv_auto_dry_run(self):
469
 
        self.make_abcd_tree()
470
 
        out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree')
471
 
        self.assertEqual(out, '')
472
 
        self.assertEqual(err, 'a => b\nc => d\n')
473
 
        tree = workingtree.WorkingTree.open('tree')
474
 
        self.assertIsNot(None, tree.path2id('a'))
475
 
        self.assertIsNot(None, tree.path2id('c'))
476
 
 
477
 
    def test_mv_no_auto_dry_run(self):
478
 
        self.make_abcd_tree()
479
 
        out, err = self.run_bzr('mv c d --dry-run',
480
 
                                working_dir='tree', retcode=3)
481
 
        self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err)
482
 
 
483
 
    def test_mv_auto_after(self):
484
 
        self.make_abcd_tree()
485
 
        out, err = self.run_bzr('mv --auto --after', working_dir='tree',
486
 
                                retcode=3)
487
 
        self.assertEqual('bzr: ERROR: --after cannot be specified with'
488
 
                         ' --auto.\n', err)
489
 
 
490
 
    def test_mv_quiet(self):
491
 
        tree = self.make_branch_and_tree('.')
492
 
        self.build_tree(['aaa'])
493
 
        tree.add(['aaa'])
494
 
        out, err = self.run_bzr('mv --quiet aaa bbb')
495
 
        self.assertEqual(out, '')
496
 
        self.assertEqual(err, '')
497
 
 
498
 
    def test_mv_readonly_lightweight_checkout(self):
499
 
        branch = self.make_branch('foo')
500
 
        branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo'))
501
 
        tree = branch.create_checkout('tree', lightweight=True)
502
 
        self.build_tree(['tree/path'])
503
 
        tree.add('path')
504
 
        # If this fails, the tree is trying to acquire a branch lock, which it
505
 
        # shouldn't.
506
 
        self.run_bzr(['mv', 'tree/path', 'tree/path2'])