-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path20add.t
200 lines (171 loc) · 6.06 KB
/
20add.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/usr/bin/perl -w
use Test::More tests => 35;
use strict;
use SVK::Test;
our $output;
my ($xd, $svk) = build_test();
my ($copath, $corpath) = get_copath ('add');
my ($repospath, undef, $repos) = $xd->find_repos ('//', 1);
$svk->checkout ('//', $copath);
is_output_like ($svk, 'add', [], qr'SYNOPSIS', 'add - help');
is_output_like ($svk, 'add', ['nonexist'],
qr'not a checkout path');
chdir ($copath);
mkdir ('A');
mkdir ('A/deep');
overwrite_file ("A/foo", "foobar");
overwrite_file ("A/bar", "foobar");
overwrite_file ("A/deep/baz", "foobar");
overwrite_file ("A/deep/baz~", "foobar");
overwrite_file ("test.txt", "test..\n");
is_output ($svk, 'add', ['test.txt'],
['A test.txt']);
is_output_like ($svk, 'add', ['Z/bzz'],
qr'not a checkout path');
is_output ($svk, 'add', ['asdf'],
["Unknown target: asdf."]);
is_output ($svk, 'add', ['A/foo'],
[map __($_), 'A A', 'A A/foo'], 'add - descendent target only');
$svk->revert ('-R', '.');
mkdir ('Z');
is_output ($svk, 'add', ["Z/noexist"], [
__"A Z",
__"Unknown target: $corpath/Z/noexist."], "target doesn't exist");
unlink ('Z');
is_output ($svk, 'add', ['-q', 'A/foo'],
[], 'add - quiet');
$svk->revert ('-R', '.');
is_output ($svk, 'add', ["$corpath/A/foo"],
[map __($_), "A $corpath/A", "A $corpath/A/foo"], 'add - descendent target only - abspath');
$svk->revert ('-R', '.');
is_output ($svk, 'add', ['../add/A/foo'],
[map __($_), "A ../add/A", "A ../add/A/foo"], 'add - descendent target only - relpath');
$svk->revert ('-R', '.');
is_output ($svk, 'add', ['A/deep/baz'],
[map __($_), 'A A', 'A A/deep', 'A A/deep/baz'],
'add - deep descendent target only');
$svk->revert ('-R', '.');
chdir('A');
is_output ($svk, 'add', ['deep'],
[map __($_), 'A ../A', 'A ../A/deep', 'A ../A/deep/baz'],
'add - deep descendent target only');
is_output ($svk, 'st', [],
[map __($_),
'A ../A',
'? ../A/bar',
'A ../A/deep', 'A ../A/deep/baz',
'? ../A/foo'],
'add - deep descendent target only');
$svk->revert ('-R', '.');
chdir('..');
is_output ($svk, 'add', ['A'],
[map __($_), 'A A', 'A A/bar', 'A A/foo', 'A A/deep', 'A A/deep/baz'],
'add - anchor');
$svk->revert ('-R', '.');
is_output ($svk, 'add', ['A/'],
[map __($_), 'A A', 'A A/bar', 'A A/foo', 'A A/deep', 'A A/deep/baz'],
'add - anchor with trailing slash');
$svk->revert ('-R', '.');
is_output ($svk, 'add', [qw/-N A/],
[map __($_), 'A A'],
'add - nonrecursive anchor');
is_output ($svk, 'add', [qw/-N A/],
['A already added.'],
'add - nonrecursive anchor already added');
is_output ($svk, 'add', ['-N', 'A/deep'],
[map __($_), 'A A/deep'],
'add - nonrecursive, parent added ');
is_output ($svk, 'add', ['A/foo'],
[map __($_), 'A A/foo'],
'add - nonrecursive target');
is_output ($svk, 'add', ['A'],
[map __($_), 'A A/bar', 'A A/deep/baz'],
'add - readd');
$svk->revert ('-R', '.');
is_output ($svk, 'add', ['-N', 'A/foo'],
["Please add the parent directory 'A' first."],
'add - nonrecursive target only');
overwrite_file ("A/exe", "foobar");
chmod (0755, "A/exe");
is_output($svk, 'add', ['A/exe'],
[__('A A'),
__('A A/exe')]);
SKIP: {
skip 'No execute bit on win32', 1 if $^O eq 'MSWin32';
is_output($svk, 'pl', ['-v', 'A/exe'],
[__('Properties on A/exe:'),
' svn:executable: *']);
}
$svk->commit ('-m', 'test exe bit');
is_output ($svk, 'add', [qw/-N A/],
['A already under version control.'],
'add - nonrecursive, already committed');
is_output ($svk, 'add', ['A'],
[map __($_), 'A A/bar', 'A A/deep', 'A A/deep/baz', 'A A/foo'],
'add - readd with committed anchor');
is_output ($svk, 'add', ['-N', 'A/exe'], [],
'add - readd with committed file unmodified');
is_output ($svk, 'add', ['A/exe'], [],
'add - readd with committed file unmodified');
overwrite_file ("A/exe", "foobarbaz");
is_output ($svk, 'add', ['-N', 'A/exe'],
[],
'add - readd with committed file modified');
unlink ('A/exe');
$svk->revert ('A/exe');
ok (_x('A/exe'));
mkdir ('Ai');
overwrite_file ("Ai/foo", "foobar");
overwrite_file ("Ai/bar", "foobar");
overwrite_file ("Ai/tilde~", "foobar");
$svk->add ('-N', 'Ai');
$svk->propset ('svn:ignore', 'f*', 'Ai');
is_output ($svk, 'add', ['Ai'],
[map __($_), 'A Ai/bar']);
$svk->revert ('-R', 'Ai');
$svk->add ('-N', 'Ai');
$svk->propset ('svn:ignore', 'f*', 'Ai');
is_output ($svk, 'add', ['Ai/foo', 'Ai/tilde~', 'Ai/bar'],
[map __($_), 'A Ai/bar', 'A Ai/foo', 'A Ai/tilde~']);
$svk->commit ('-m', 'commit');
is_output ($svk, 'ls', ['//Ai'], ['bar', 'foo', 'tilde~']);
# auto-prop
use File::Temp qw/tempdir/;
my $dir = tempdir ( CLEANUP => 1 );
overwrite_file (File::Spec->catfile ($dir, 'servers'), '');
overwrite_file (File::Spec->catfile ($dir, 'config'), << "EOF");
[miscellany]
enable-auto-props = yes
[auto-props]
*.txt = svn:eol-style = native ; svn:keywords = Revision Id
*.pl = svn:eol-style=native;svn:mime-type=text/perl
EOF
SVK::Config->_svnconfig( SVN::Core::config_get_config($dir) );
mkdir ('A/autoprop');
overwrite_file ("A/autoprop/foo.pl", "#!/usr/bin/perl\n");
overwrite_file ("A/autoprop/foo.txt", "Text file\n");
overwrite_file ("A/autoprop/foo.bar", "this is just a test\n");
# test enumerator
eval { SVK::Config->svnconfig->{config}->enumerate('auto-props', sub {}) };
SKIP: {
skip 'svn too old, does not support config enumerator', 2 if $@;
is_output ($svk, 'add', ['A/autoprop'],
[__('A A/autoprop'),
__('A A/autoprop/foo.bar'),
__('A A/autoprop/foo.pl'),
__('A A/autoprop/foo.txt')]);
is_output ($svk, 'pl', ['-v', glob("A/autoprop/*")],
[__('Properties on A/autoprop/foo.pl:'),
' svn:eol-style: native',
' svn:mime-type: text/perl',
__('Properties on A/autoprop/foo.txt:'),
' svn:eol-style: native',
' svn:keywords: Revision Id'
]);
}
eval { overwrite_file("A/\x{05}file", "fnord\n") };
SKIP: {
skip "can't create file with control character.", 1 unless -e "A/\x{05}file";
is_output ($svk, 'add', ["A/\x{05}file"],
[__("Invalid control character '0x05' in path 'A/\x{05}file'")]);
}