/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: Jan Hudec
  • Date: 2006-11-25 20:38:39 UTC
  • mto: (2199.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2200.
  • Revision ID: bulb@ucw.cz-20061125203839-9nuhv32z63hb8811
Option --pull for merge command.

Option --pull was added to merge command, that, if the merge would be
trivial, ie. if the common ancestor is equal to the local tip, causes pull of
the remote instead of creating the merger.

Simple test for this option is included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
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
 
16
 
 
17
"""Test for 'bzr mv'"""
 
18
 
 
19
import os
 
20
 
 
21
from bzrlib import (
 
22
    osutils,
 
23
    workingtree,
 
24
)
 
25
from bzrlib.tests import TestCaseWithTransport
 
26
 
 
27
 
 
28
class TestMove(TestCaseWithTransport):
 
29
 
 
30
    def test_mv_modes(self):
 
31
        """Test two modes of operation for mv"""
 
32
        tree = self.make_branch_and_tree('.')
 
33
        files = self.build_tree(['a', 'c', 'subdir/'])
 
34
        tree.add(['a', 'c', 'subdir'])
 
35
 
 
36
        self.run_bzr('mv', 'a', 'b')
 
37
        self.failUnlessExists('b')
 
38
        self.failIfExists('a')
 
39
 
 
40
        self.run_bzr('mv', 'b', 'subdir')
 
41
        self.failUnlessExists('subdir/b')
 
42
        self.failIfExists('b')
 
43
 
 
44
        self.run_bzr('mv', 'subdir/b', 'a')
 
45
        self.failUnlessExists('a')
 
46
        self.failIfExists('subdir/b')
 
47
 
 
48
        self.run_bzr('mv', 'a', 'c', 'subdir')
 
49
        self.failUnlessExists('subdir/a')
 
50
        self.failUnlessExists('subdir/c')
 
51
        self.failIfExists('a')
 
52
        self.failIfExists('c')
 
53
 
 
54
        self.run_bzr('mv', 'subdir/a', 'subdir/newa')
 
55
        self.failUnlessExists('subdir/newa')
 
56
        self.failIfExists('subdir/a')
 
57
 
 
58
    def test_mv_unversioned(self):
 
59
        self.build_tree(['unversioned.txt'])
 
60
        self.run_bzr_error(
 
61
            ["^bzr: ERROR: can't rename: old name .* is not versioned$"],
 
62
            'mv', 'unversioned.txt', 'elsewhere')
 
63
 
 
64
    def test_mv_nonexisting(self):
 
65
        self.run_bzr_error(
 
66
            ["^bzr: ERROR: can't rename: old working file .* does not exist$"],
 
67
            'mv', 'doesnotexist', 'somewhereelse')
 
68
 
 
69
    def test_mv_unqualified(self):
 
70
        self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv')
 
71
        
 
72
    def test_mv_invalid(self):
 
73
        tree = self.make_branch_and_tree('.')
 
74
        self.build_tree(['test.txt', 'sub1/'])
 
75
        tree.add(['test.txt'])
 
76
 
 
77
        self.run_bzr_error(
 
78
            ["^bzr: ERROR: destination u'sub1' is not a versioned directory$"],
 
79
            'mv', 'test.txt', 'sub1')
 
80
        
 
81
        self.run_bzr_error(
 
82
            ["^bzr: ERROR: can't determine destination directory id for u'sub1'$"],
 
83
            'mv', 'test.txt', 'sub1/hello.txt')
 
84
        
 
85
    def test_mv_dirs(self):
 
86
        tree = self.make_branch_and_tree('.')
 
87
        self.build_tree(['hello.txt', 'sub1/'])
 
88
        tree.add(['hello.txt', 'sub1'])
 
89
 
 
90
        self.run_bzr('mv', 'sub1', 'sub2')
 
91
        self.failUnlessExists('sub2')
 
92
        self.failIfExists('sub1')
 
93
        self.run_bzr('mv', 'hello.txt', 'sub2')
 
94
        self.failUnlessExists("sub2/hello.txt")
 
95
        self.failIfExists("hello.txt")
 
96
 
 
97
        tree.read_working_inventory()
 
98
        tree.commit('commit with some things moved to subdirs')
 
99
 
 
100
        self.build_tree(['sub1/'])
 
101
        tree.add(['sub1'])
 
102
        self.run_bzr('mv', 'sub2/hello.txt', 'sub1')
 
103
        self.failIfExists('sub2/hello.txt')
 
104
        self.failUnlessExists('sub1/hello.txt')
 
105
        self.run_bzr('mv', 'sub2', 'sub1')
 
106
        self.failIfExists('sub2')
 
107
        self.failUnlessExists('sub1/sub2')
 
108
 
 
109
    def test_mv_relative(self):
 
110
        self.build_tree(['sub1/', 'sub1/sub2/', 'sub1/hello.txt'])
 
111
        tree = self.make_branch_and_tree('.')
 
112
        tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt'])
 
113
        tree.commit('initial tree')
 
114
 
 
115
        os.chdir('sub1/sub2')
 
116
        self.run_bzr('mv', '../hello.txt', '.')
 
117
        self.failUnlessExists('./hello.txt')
 
118
        tree.read_working_inventory()
 
119
        tree.commit('move to parent directory')
 
120
 
 
121
        os.chdir('..')
 
122
 
 
123
        self.run_bzr('mv', 'sub2/hello.txt', '.')
 
124
        self.failUnlessExists('hello.txt')
 
125
 
 
126
    def test_mv_smoke_aliases(self):
 
127
        # just test that aliases for mv exist, if their behaviour is changed in
 
128
        # the future, then extend the tests.
 
129
        self.build_tree(['a'])
 
130
        tree = self.make_branch_and_tree('.')
 
131
        tree.add(['a'])
 
132
 
 
133
        self.run_bzr('move', 'a', 'b')
 
134
        self.run_bzr('rename', 'b', 'a')
 
135
 
 
136
    def test_mv_through_symlinks(self):
 
137
        if not osutils.has_symlinks():
 
138
            raise TestSkipped('Symlinks are not supported on this platform')
 
139
        tree = self.make_branch_and_tree('.')
 
140
        self.build_tree(['a/', 'a/b'])
 
141
        os.symlink('a', 'c')
 
142
        os.symlink('.', 'd')
 
143
        tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id'])
 
144
        self.run_bzr('mv', 'c/b', 'b')
 
145
        tree = workingtree.WorkingTree.open('.')
 
146
        self.assertEqual('b-id', tree.path2id('b'))