-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path36push-pull.t
304 lines (250 loc) · 10.4 KB
/
36push-pull.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/usr/bin/perl -w
use strict;
use Test::More;
use Cwd;
use File::Path;
use SVK::Test;
plan tests => 18;
my $initial_cwd = getcwd;
# build another tree to be mirrored ourself
my ($xd, $svk) = build_test('test');
my $tree = create_basic_tree ($xd, '/test/');
my ($copath_test, $corpath_test) = get_copath ('push-pull-test');
my ($copath_default, $corpath_default) = get_copath ('push-pull-default');
my ($copath_second, $corpath_second) = get_copath ('push-pull-second');
my ($test_repospath, $test_a_path, $test_repos) =$xd->find_repos ('/test/A', 1);
my $test_uuid = $test_repos->fs->get_uuid;
my ($default_repospath, $default_path, $default_repos) =$xd->find_repos ('//A', 1);
my $default_uuid = $default_repos->fs->get_uuid;
my $uri = uri($test_repospath);
$svk->mirror ('//m', $uri.($test_a_path eq '/' ? '' : $test_a_path));
$svk->sync ('//m');
$svk->copy ('-m', 'branch', '//m', '//l');
$svk->checkout ('//l', $corpath_default);
ok (-e "$corpath_default/be");
append_file ("$corpath_default/be", "from local branch\n");
mkdir "$corpath_default/T/";
append_file ("$corpath_default/T/xd", "local new file\n");
$svk->add ("$corpath_default/T");
$svk->delete ("$corpath_default/Q/qu");
$svk->commit ('-m', 'local modification from branch', "$corpath_default");
append_file ("$corpath_default/T/xd", "more content\n");
$svk->commit ('-m', 'second local modification from branch', "$corpath_default");
chdir ($corpath_default);
is_output ($svk, "push", [], [
"Auto-merging (0, 6) /l to /m (base /m:3).",
"===> Auto-merging (0, 4) /l to /m (base /m:3).",
"Merging back to mirror source $uri/A.",
"Empty merge.",
"===> Auto-merging (4, 5) /l to /m (base /m:3).",
"Merging back to mirror source $uri/A.",
"D Q/qu",
"A T",
"A T/xd",
"U be",
"New merge ticket: $default_uuid:/l:5",
"Merge back committed as revision 3.",
"Syncing $uri/A",
"Retrieving log information from 3 to 3",
"Committed revision 7 from revision 3.",
"===> Auto-merging (5, 6) /l to /m (base /l:5).",
"Merging back to mirror source $uri/A.",
"U T/xd",
"New merge ticket: $default_uuid:/l:6",
"Merge back committed as revision 4.",
"Syncing $uri/A",
"Retrieving log information from 4 to 4",
"Committed revision 8 from revision 4."]);
append_file ("$corpath_default/T/xd", "even more content\n");
$svk->commit ('-m', 'third local modification from branch', "$corpath_default");
append_file ("$corpath_default/be", "more content\n");
$svk->commit ('-m', 'fourth local modification from branch', "$corpath_default");
is_output ($svk, 'push', ['-l'], [
"Auto-merging (6, 10) /l to /m (base /l:6).",
"Merging back to mirror source $uri/A.",
"U T/xd",
"U be",
"New merge ticket: $default_uuid:/l:10",
"Merge back committed as revision 5.",
"Syncing $uri/A",
"Retrieving log information from 5 to 5",
"Committed revision 11 from revision 5."]);
$svk->checkout ('/test/A', $corpath_test);
# add a file to remote
append_file ("$corpath_test/new-file", "some text\n");
$svk->add ("$corpath_test/new-file");
$svk->commit ('-m', 'making changes in remote depot', "$corpath_test");
chdir ($corpath_default);
is_output ($svk, "pull", [], [
"Syncing $uri/A",
"Retrieving log information from 6 to 6",
"Committed revision 12 from revision 6.",
"Auto-merging (3, 12) /m to /l (base /l:10).",
"A new-file",
"New merge ticket: $test_uuid:/A:6",
"Committed revision 13.",
"Syncing //l(/l) in $corpath_default to 13.",
"A new-file"]);
# add a file to remote
append_file ("$corpath_test/new-file", "some text\n");
$svk->add ("$corpath_test/new-file");
$svk->commit ('-m', 'making changes in remote depot', "$corpath_test");
chdir ($initial_cwd);
$svk->sync ("//m");
is_output ($svk, "push", ['-C', "--from", "//m", "//l"], [
"Auto-merging (12, 14) /m to /l (base /m:12).",
'===> Auto-merging (12, 14) /m to /l (base /m:12).',
"U new-file",
"New merge ticket: $test_uuid:/A:7"]);
is_output ($svk, "push", ["--from", "//m", "//l"], [
"Auto-merging (12, 14) /m to /l (base /m:12).",
"===> Auto-merging (12, 14) /m to /l (base /m:12).",
"U new-file",
"New merge ticket: $test_uuid:/A:7",
"Committed revision 15."]);
$svk->switch ("//m", $corpath_default);
append_file ("$corpath_default/new-file", "some text\n");
$svk->commit ('-m', 'modification to mirror', "$corpath_default");
is_output ($svk, "pull", ["//l"], [
"Auto-merging (14, 16) /m to /l (base /m:14).",
"U new-file",
"New merge ticket: $test_uuid:/A:8",
"Committed revision 17."]);
$svk->copy ('-m', '2nd branch', '//m', '//l2');
$svk->checkout ('//l2', $corpath_second);
is_output ($svk, "pull", [$corpath_default, $corpath_second], [
"Syncing $uri/A",
"Syncing //m(/m) in $corpath_default to 18.",
"Syncing //l2(/l2) in $corpath_second to 18."]);
is_output ($svk, "pull", ['-a'], [
"Syncing $uri/A",
"Syncing //m(/m) in $corpath_default to 18.",
"Syncing //l2(/l2) in $corpath_second to 18.",
"Syncing /test/A(/A) in $corpath_test to 8.",
__"U $corpath_test/new-file"]);
append_file ("$corpath_default/new-file", "some text\n");
$svk->commit ('-m', 'modification to mirror', "$corpath_default");
is_output ($svk, "pull", ['--lump', "//l"], [
"Auto-merging (16, 19) /m to /l (base /m:16).",
"U new-file",
"New merge ticket: $test_uuid:/A:9",
"Committed revision 20."]);
my ($copath_subir, $corpath_subdir) = get_copath ('pull-subdir-test');
$svk->sync ('//m');
$svk->mkdir('-m', 'just dir', '//l-sub');
$svk->copy ('-m', 'branch', '//m/T', '//l-sub/sub');
$svk->checkout ('//l-sub', $corpath_subdir);
append_file ("$corpath_default/T/xd", "local changed file\n");
$svk->commit ('-m', 'local modification from branch', "$corpath_default");
chdir ($corpath_subdir);
is_output ($svk, "pull", ["sub"], [
"Syncing $uri".($test_a_path eq '/' ? '' : $test_a_path),
"Auto-merging (11, 23) /m/T to /l-sub/sub (base /m/T:11).",
__("U xd"),
"New merge ticket: $test_uuid:/A/T:10",
"Committed revision 24.",
"Syncing //l-sub/sub(/l-sub/sub) in ".__("$corpath_subdir/sub to 24."),
__("U sub/xd")]);
overwrite_file ("$corpath_second/Q/qz", "asfd orz\n");
$svk->commit (-m => 'randome changes', $corpath_second);
overwrite_file ("$corpath_test/Q/qz", "asfd orz\n");
$svk->commit (-m => 'randome changes', $corpath_test);
chdir ($corpath_second);
our $output;
# Server should be less strict, before that we need sync first
# so we first expect it is bzz here
# These added tests should be removed after server side less strict
is_output ($svk, 'push', [],
['Auto-merging (0, 25) /l2 to /m (base /m:16).',
'===> Auto-merging (0, 18) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
qr"Transaction is out of date: .+ '/A' .+",
'Please sync mirrored path /m first.']);
# syncing
is_output ($svk, "sync", ['//m'], [
"Syncing $uri/A",
"Retrieving log information from 11 to 11",
"Committed revision 26 from revision 11."]);
# expect it is
is_output ($svk, 'push', [],
['Auto-merging (0, 25) /l2 to /m (base /m:16).',
'===> Auto-merging (0, 18) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
'Empty merge.',
'===> Auto-merging (18, 25) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
"g Q/qz",
'Empty merge.']);
overwrite_file ("$corpath_test/push-newfile", "sync and not merged immediately\n");
$svk->add("$corpath_test/push-newfile");
$svk->commit (-m => 'add a file', $corpath_test);
$svk->sync('//m');
append_file ("$corpath_second/be", "asfd orz\n");
$svk->commit (-m => 'randome changes between sync and merge', $corpath_second);
is_output($svk, 'pull', [],
["Syncing $uri/A",
'Auto-merging (16, 27) /m to /l2 (base /m:16).',
'g Q/qz',
'U T/xd',
'U new-file',
'A push-newfile',
qr'New merge ticket: .*:/A:12',
'Committed revision 29.',
"Syncing //l2(/l2) in $corpath_second to 29.",
__('U T/xd'),
__('U new-file'),
__('A push-newfile')]);
$svk->up($corpath_test);
append_file("$corpath_test/new-file", "more modification that will get overwritten if using wrong merge base\n");
$svk->commit (-m => 'change something', $corpath_test);
# Server should be less strict, before that we need sync first
# so we first expect it is bzz here
is_output($svk, 'push', [],
['Auto-merging (0, 29) /l2 to /m (base /m:27).',
'===> Auto-merging (0, 18) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
qr"Transaction is out of date: .+ '/A' .+",
'Please sync mirrored path /m first.']);
# syncing
$svk->sync('//m');
is_output($svk, 'push', [],
['Auto-merging (0, 29) /l2 to /m (base /m:27).',
'===> Auto-merging (0, 18) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
'Empty merge.',
'===> Auto-merging (18, 25) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
'g Q/qz',
'Empty merge.',
'===> Auto-merging (25, 28) /l2 to /m (base /m:16).',
"Merging back to mirror source $uri/A.",
'g Q/qz',
'U be',
qr'New merge ticket: .*:/l2:28',
'Merge back committed as revision 14.',
"Syncing $uri/A",
'Retrieving log information from 14 to 14',
'Committed revision 31 from revision 14.',
'===> Auto-merging (28, 29) /l2 to /m (base */m:30).',
"Merging back to mirror source $uri/A.",
'U new-file',
qr'New merge ticket: .*:/l2:29',
'Merge back committed as revision 15.',
"Syncing $uri/A",
'Retrieving log information from 15 to 15',
'Committed revision 32 from revision 15.']);
chdir ($initial_cwd);
$svk->cp (-m => 'copy', '/test/A' => '/test/A-cp');
$svk->mkdir (-m => 'dir in A', '/test/A/notforcp');
$svk->mkdir (-m => 'dir in A-ap', '/test/A-cp/cp-only');
$svk->mi ('--detach' => '//m');
$svk->mi ('//all', $uri);
$svk->sync ('-a');
rmtree [$corpath_default];
$svk->checkout ('//all/A-cp', $corpath_default);
TODO: {
local $TODO = 'pull on mirrored path should not smerge from the same source';
is_output ($svk, 'pull', [$copath_default],
["Syncing //all/A-cp(/all/A-cp) in $corpath_default to 32.",
__"A $copath_default/cp-only"]);
}