1
# Copyright (C) 2017 The Breezy Developers
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Test for 'brz mv'"""
27
from breezy.tests import (
28
TestCaseWithTransport,
30
from breezy.tests.features import (
31
CaseInsensitiveFilesystemFeature,
33
UnicodeFilenameFeature,
37
class TestCopy(TestCaseWithTransport):
39
def test_cp_unversioned(self):
40
self.build_tree(['unversioned.txt'])
42
["^brz: ERROR: Could not copy .*unversioned.txt => .*elsewhere."
43
" .*unversioned.txt is not versioned\\.$"],
44
'cp unversioned.txt elsewhere')
46
def test_cp_nonexisting(self):
48
["^brz: ERROR: Could not copy .*doesnotexist => .*somewhereelse."
49
" .*doesnotexist is not versioned\\.$"],
50
'cp doesnotexist somewhereelse')
52
def test_cp_unqualified(self):
53
self.run_bzr_error(['^brz: ERROR: missing file argument$'], 'cp')
55
def test_cp_invalid(self):
56
tree = self.make_branch_and_tree('.')
57
self.build_tree(['test.txt', 'sub1/'])
58
tree.add(['test.txt'])
61
["^brz: ERROR: Could not copy test.txt => sub1/test.txt: "
62
"sub1 is not versioned\\.$"],
66
["^brz: ERROR: Could not copy test.txt => .*hello.txt: "
67
"sub1 is not versioned\\.$"],
68
'cp test.txt sub1/hello.txt')
70
def test_cp_dir(self):
71
tree = self.make_branch_and_tree('.')
72
self.build_tree(['hello.txt', 'sub1/'])
73
tree.add(['hello.txt', 'sub1'])
76
["^brz: ERROR: Could not copy sub1 => sub2 . "
77
"sub1 is a directory\\.$"],
80
def test_cp_file_into(self):
81
tree = self.make_branch_and_tree('.')
82
self.build_tree(['sub1/', 'sub1/hello.txt', 'sub2/'])
83
tree.add(['sub1', 'sub1/hello.txt', 'sub2'])
85
self.run_bzr('cp sub1/hello.txt sub2')
86
self.assertInWorkingTree('sub1')
87
self.assertInWorkingTree('sub1/hello.txt')
88
self.assertInWorkingTree('sub2')
89
self.assertInWorkingTree('sub2/hello.txt')
91
def test_cp_file(self):
92
tree = self.make_branch_and_tree('.')
93
self.build_tree(['hello.txt'])
94
tree.add(['hello.txt'])
96
self.run_bzr('cp hello.txt hallo.txt')
97
self.assertInWorkingTree('hello.txt')
98
self.assertInWorkingTree('hallo.txt')