77
77
# If there's no pristine repos, create one.
78
78
if not os.path.exists(main.pristine_greek_repos_dir):
79
main.create_repos(main.pristine_greek_repos_dir)
81
# if this is dav, gives us access rights to import the greek tree.
82
if main.is_ra_type_dav():
83
authz_file = os.path.join(main.work_dir, "authz")
84
main.file_write(authz_file, "[/]\n* = rw\n")
86
# dump the greek tree to disk.
87
main.greek_state.write_to_disk(main.greek_dump_dir)
89
# import the greek tree, using l:foo/p:bar
90
### todo: svn should not be prompting for auth info when using
91
### repositories with no auth/auth requirements
92
_, output, _ = main.run_svn(None, 'import', '-m',
93
'Log message for revision 1.',
95
main.pristine_greek_repos_url)
97
# verify the printed output of 'svn import'.
98
lastline = output.pop().strip()
99
match = re.search("(Committed|Imported) revision [0-9]+.", lastline)
101
logger.error("import did not succeed, while creating greek repos.")
102
logger.error("The final line from 'svn import' was:")
103
logger.error(lastline)
105
output_tree = wc.State.from_commit(output)
107
expected_output_tree = main.greek_state.copy(main.greek_dump_dir)
108
expected_output_tree.tweak(verb='Adding',
112
expected_output_tree.compare_and_display('output', output_tree)
113
except tree.SVNTreeUnequal:
114
verify.display_trees("ERROR: output of import command is unexpected.",
116
expected_output_tree.old_tree(),
117
output_tree.old_tree())
79
if main.options.fsfs_version is not None:
80
main.unpack_greek_repos(main.pristine_greek_repos_dir)
82
main.create_repos(main.pristine_greek_repos_dir)
84
# if this is dav, gives us access rights to import the greek tree.
85
if main.is_ra_type_dav():
86
authz_file = os.path.join(main.work_dir, "authz")
87
main.file_write(authz_file, "[/]\n* = rw\n")
89
# dump the greek tree to disk.
90
main.greek_state.write_to_disk(main.greek_dump_dir)
92
# import the greek tree, using l:foo/p:bar
93
### todo: svn should not be prompting for auth info when using
94
### repositories with no auth/auth requirements
95
_, output, _ = main.run_svn(None, 'import', '-m',
96
'Log message for revision 1.',
98
main.pristine_greek_repos_url)
100
# verify the printed output of 'svn import'.
101
lastline = output.pop().strip()
102
match = re.search("(Committed|Imported) revision [0-9]+.", lastline)
104
logger.error("import did not succeed, while creating greek repos.")
105
logger.error("The final line from 'svn import' was:")
106
logger.error(lastline)
108
output_tree = wc.State.from_commit(output)
110
expected_output_tree = main.greek_state.copy(main.greek_dump_dir)
111
expected_output_tree.tweak(verb='Adding',
115
expected_output_tree.compare_and_display('output', output_tree)
116
except tree.SVNTreeUnequal:
117
verify.display_trees("ERROR: output of import command is unexpected.",
119
expected_output_tree.old_tree(),
120
output_tree.old_tree())
120
123
# Finally, disallow any changes to the "pristine" repos.
121
124
error_msg = "Don't modify the pristine repository"
154
157
# copy the pristine repository to PATH.
155
158
main.safe_rmtree(path)
156
if main.copy_repos(main.pristine_greek_repos_dir, path, 1, 1, minor_version):
159
if (main.options.fsfs_version is not None):
160
failed = main.unpack_greek_repos(path)
162
failed = main.copy_repos(main.pristine_greek_repos_dir,
163
path, 1, 1, minor_version)
157
165
logger.error("copying repository failed.")
160
168
# make the repos world-writeable, for mod_dav_svn's sake.
161
169
main.chmod_tree(path, 0666, 0666)
171
# give the repository a unique UUID
172
run_and_verify_svnadmin([], [], 'setuuid', path)
164
def run_and_verify_atomic_ra_revprop_change(message,
174
def run_and_verify_atomic_ra_revprop_change(expected_stdout,
168
177
url, revision, propname,
193
202
verify.verify_outputs("Unexpected output", out, err,
194
203
expected_stdout, expected_stderr)
195
verify.verify_exit_code(message, exit_code, expected_exit)
204
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
196
205
return exit_code, out, err
199
def run_and_verify_svnlook(message, expected_stdout,
208
def run_and_verify_svnlook(expected_stdout,
200
209
expected_stderr, *varargs):
201
210
"""Like run_and_verify_svnlook2, but the expected exit code is
202
211
assumed to be 0 if no output is expected on stderr, and 1 otherwise."""
204
213
expected_exit = 0
205
214
if expected_stderr is not None and expected_stderr != []:
206
215
expected_exit = 1
207
return run_and_verify_svnlook2(message, expected_stdout, expected_stderr,
216
return run_and_verify_svnlook2(expected_stdout, expected_stderr,
208
217
expected_exit, *varargs)
210
def run_and_verify_svnlook2(message, expected_stdout, expected_stderr,
219
def run_and_verify_svnlook2(expected_stdout, expected_stderr,
211
220
expected_exit, *varargs):
212
221
"""Run svnlook command and check its output and exit code."""
214
223
exit_code, out, err = main.run_svnlook(*varargs)
215
224
verify.verify_outputs("Unexpected output", out, err,
216
225
expected_stdout, expected_stderr)
217
verify.verify_exit_code(message, exit_code, expected_exit)
226
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
218
227
return exit_code, out, err
221
def run_and_verify_svnadmin(message, expected_stdout,
230
def run_and_verify_svnadmin(expected_stdout,
222
231
expected_stderr, *varargs):
223
232
"""Like run_and_verify_svnadmin2, but the expected exit code is
224
233
assumed to be 0 if no output is expected on stderr, and 1 otherwise."""
226
235
expected_exit = 0
227
236
if expected_stderr is not None and expected_stderr != []:
228
237
expected_exit = 1
229
return run_and_verify_svnadmin2(message, expected_stdout, expected_stderr,
238
return run_and_verify_svnadmin2(expected_stdout, expected_stderr,
230
239
expected_exit, *varargs)
232
def run_and_verify_svnadmin2(message, expected_stdout, expected_stderr,
241
def run_and_verify_svnadmin2(expected_stdout, expected_stderr,
233
242
expected_exit, *varargs):
234
243
"""Run svnadmin command and check its output and exit code."""
236
245
exit_code, out, err = main.run_svnadmin(*varargs)
237
246
verify.verify_outputs("Unexpected output", out, err,
238
247
expected_stdout, expected_stderr)
239
verify.verify_exit_code(message, exit_code, expected_exit)
248
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
240
249
return exit_code, out, err
243
def run_and_verify_svnversion(message, wc_dir, trail_url,
252
def run_and_verify_svnversion(wc_dir, trail_url,
244
253
expected_stdout, expected_stderr, *varargs):
245
254
"""like run_and_verify_svnversion2, but the expected exit code is
246
255
assumed to be 0 if no output is expected on stderr, and 1 otherwise."""
248
257
expected_exit = 0
249
258
if expected_stderr is not None and expected_stderr != []:
250
259
expected_exit = 1
251
return run_and_verify_svnversion2(message, wc_dir, trail_url,
260
return run_and_verify_svnversion2(wc_dir, trail_url,
252
261
expected_stdout, expected_stderr,
253
262
expected_exit, *varargs)
255
def run_and_verify_svnversion2(message, wc_dir, trail_url,
264
def run_and_verify_svnversion2(wc_dir, trail_url,
256
265
expected_stdout, expected_stderr,
257
266
expected_exit, *varargs):
258
267
"""Run svnversion command and check its output and exit code."""
265
274
verify.verify_outputs("Unexpected output", out, err,
266
275
expected_stdout, expected_stderr)
267
verify.verify_exit_code(message, exit_code, expected_exit)
276
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
268
277
return exit_code, out, err
270
def run_and_verify_svn(message, expected_stdout, expected_stderr, *varargs):
279
def run_and_verify_svn(expected_stdout, expected_stderr, *varargs):
271
280
"""like run_and_verify_svn2, but the expected exit code is assumed to
272
281
be 0 if no output is expected on stderr, and 1 otherwise."""
278
287
expected_exit = 1
279
288
elif expected_stderr != []:
280
289
expected_exit = 1
281
return run_and_verify_svn2(message, expected_stdout, expected_stderr,
290
return run_and_verify_svn2(expected_stdout, expected_stderr,
282
291
expected_exit, *varargs)
284
def run_and_verify_svn2(message, expected_stdout, expected_stderr,
293
def run_and_verify_svn2(expected_stdout, expected_stderr,
285
294
expected_exit, *varargs):
286
295
"""Invoke main.run_svn() with *VARARGS. Return exit code as int; stdout,
287
296
stderr as lists of lines (including line terminators). For both
320
329
exit_code, out, err = main.run_svn(want_err, *varargs)
321
verify.verify_outputs(message, out, err, expected_stdout, expected_stderr)
322
verify.verify_exit_code(message, exit_code, expected_exit)
330
verify.verify_outputs("Unexpected output", out, err,
331
expected_stdout, expected_stderr)
332
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
323
333
return exit_code, out, err
325
335
def run_and_verify_load(repo_dir, dump_file_content,
328
338
if not isinstance(dump_file_content, list):
329
339
raise TypeError("dump_file_content argument should have list type")
330
340
expected_stderr = []
331
342
if bypass_prop_validation:
332
exit_code, output, errput = main.run_command_stdin(
333
main.svnadmin_binary, expected_stderr, 0, True, dump_file_content,
334
'load', '--force-uuid', '--quiet', '--bypass-prop-validation', repo_dir)
336
exit_code, output, errput = main.run_command_stdin(
337
main.svnadmin_binary, expected_stderr, 0, True, dump_file_content,
338
'load', '--force-uuid', '--quiet', repo_dir)
340
verify.verify_outputs("Unexpected stderr output", None, errput,
341
None, expected_stderr)
343
args += ('--bypass-prop-validation',)
344
main.run_command_stdin(
345
main.svnadmin_binary, expected_stderr, 0, True, dump_file_content,
346
'load', '--force-uuid', '--quiet', repo_dir, *args)
344
349
def run_and_verify_dump(repo_dir, deltas=False):
345
350
"Runs 'svnadmin dump' and reports any errors, returning the dump content."
347
exit_code, output, errput = main.run_svnadmin('dump', '--deltas',
350
exit_code, output, errput = main.run_svnadmin('dump', repo_dir)
351
verify.verify_outputs("Missing expected output(s)", output, errput,
352
verify.AnyOutput, verify.AnyOutput)
353
args += ('--deltas',)
354
exit_code, output, errput = run_and_verify_svnadmin(
355
verify.AnyOutput, [],
356
'dump', '--quiet', repo_dir, *args)
377
def run_and_verify_svnmucc(message, expected_stdout, expected_stderr,
383
def run_and_verify_svnmucc(expected_stdout, expected_stderr,
379
385
"""Run svnmucc command and check its output"""
381
387
expected_exit = 0
382
388
if expected_stderr is not None and expected_stderr != []:
383
389
expected_exit = 1
384
return run_and_verify_svnmucc2(message, expected_stdout, expected_stderr,
390
return run_and_verify_svnmucc2(expected_stdout, expected_stderr,
385
391
expected_exit, *varargs)
387
def run_and_verify_svnmucc2(message, expected_stdout, expected_stderr,
393
def run_and_verify_svnmucc2(expected_stdout, expected_stderr,
388
394
expected_exit, *varargs):
389
395
"""Run svnmucc command and check its output and exit code."""
391
397
exit_code, out, err = main.run_svnmucc(*varargs)
392
398
verify.verify_outputs("Unexpected output", out, err,
393
399
expected_stdout, expected_stderr)
394
verify.verify_exit_code(message, exit_code, expected_exit)
400
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
401
return exit_code, out, err
404
def run_and_verify_svnsync(expected_stdout, expected_stderr,
406
"""Run svnsync command and check its output"""
409
if expected_stderr is not None and expected_stderr != []:
411
return run_and_verify_svnsync2(expected_stdout, expected_stderr,
412
expected_exit, *varargs)
414
def run_and_verify_svnsync2(expected_stdout, expected_stderr,
415
expected_exit, *varargs):
416
"""Run svnmucc command and check its output and exit code."""
418
exit_code, out, err = main.run_svnsync(*varargs)
420
# Ignore "consider upgrade" warnings to allow regression tests to pass
421
# when run against a 1.6 mod_dav_svn.
422
for index, line in enumerate(err[:]):
423
if re.search("warning: W200007", line):
426
verify.verify_outputs("Unexpected output", out, err,
427
expected_stdout, expected_stderr)
428
verify.verify_exit_code("Unexpected return code", exit_code, expected_exit)
395
429
return exit_code, out, err
398
432
def load_repo(sbox, dumpfile_path = None, dump_str = None,
399
bypass_prop_validation = False):
433
bypass_prop_validation = False,create_wc=True):
400
434
"Loads the dumpfile into sbox"
402
436
dump_str = open(dumpfile_path, "rb").read()
449
def run_and_verify_checkout2(do_remove,
450
URL, wc_dir_name, output_tree, disk_tree,
451
singleton_handler_a = None,
453
singleton_handler_b = None,
484
def run_and_verify_checkout(URL, wc_dir_name, output_tree, disk_tree,
456
487
"""Checkout the URL into a new directory WC_DIR_NAME. *ARGS are any
457
488
extra optional args to the checkout subcommand.
469
500
if isinstance(output_tree, wc.State):
470
501
output_tree = output_tree.old_tree()
472
# Remove dir if it's already there, unless this is a forced checkout.
473
# In that case assume we want to test a forced checkout's toleration
474
# of obstructing paths.
476
main.safe_rmtree(wc_dir_name)
478
503
# Checkout and make a tree of the output, using l:foo/p:bar
479
504
### todo: svn should not be prompting for auth info when using
480
505
### repositories with no auth/auth requirements
481
exit_code, output, errput = main.run_svn(None, 'co',
482
URL, wc_dir_name, *args)
506
exit_code, output, errput = run_and_verify_svn(None, expected_stderr,
507
'co', URL, wc_dir_name,
483
509
actual = tree.build_tree_from_checkout(output)
485
511
# Verify actual output against expected output.
493
verify_disk(wc_dir_name, disk_tree, False,
494
singleton_handler_a, a_baton,
495
singleton_handler_b, b_baton)
497
def run_and_verify_checkout(URL, wc_dir_name, output_tree, disk_tree,
498
singleton_handler_a = None,
500
singleton_handler_b = None,
503
"""Same as run_and_verify_checkout2(), but without the DO_REMOVE arg.
504
WC_DIR_NAME is deleted if present unless the '--force' option is passed
508
# Remove dir if it's already there, unless this is a forced checkout.
509
# In that case assume we want to test a forced checkout's toleration
510
# of obstructing paths.
511
return run_and_verify_checkout2(('--force' not in args),
512
URL, wc_dir_name, output_tree, disk_tree,
519
verify_disk(wc_dir_name, disk_tree, False, **kw)
520
521
def run_and_verify_export(URL, export_dir_name, output_tree, disk_tree,
573
579
self.revprops = revprops
581
def assert_log_attrs(self, attributes):
582
"""Assert that attributes is the same as this entry's attributes
583
Raises svntest.Failure if not.
585
if self.attributes != attributes:
586
raise Failure('\n' + '\n'.join(difflib.ndiff(
587
pprint.pformat(attributes).splitlines(),
588
pprint.pformat(self.attributes).splitlines())))
575
590
def assert_changed_paths(self, changed_paths):
576
591
"""Assert that changed_paths is the same as this entry's changed_paths
577
592
Raises svntest.Failure if not.
669
684
self.entries[-1].changed_paths[self.use_cdata()] = [{'kind': self.kind,
670
685
'action': self.action}]
672
def run_and_verify_log_xml(message=None, expected_paths=None,
673
expected_revprops=None, expected_stdout=None,
674
expected_stderr=None, args=[]):
687
def run_and_verify_log_xml(expected_log_attrs=None,
688
expected_paths=None, expected_revprops=None,
689
expected_stdout=None, expected_stderr=None,
675
691
"""Call run_and_verify_svn with log --xml and args (optional) as command
676
arguments, and pass along message, expected_stdout, and expected_stderr.
678
If message is None, pass the svn log command as message.
692
arguments, and pass along expected_stdout, and expected_stderr.
680
694
expected_paths checking is not yet implemented.
696
expected_log_attrs is an optional list of dicts, compared to each revisions's
697
logentry attributes. The list must be in the same order the log entries
682
700
expected_revprops is an optional list of dicts, compared to each
683
701
revision's revprops. The list must be in the same order the log entries
684
702
come in. Any svn:date revprops in the dicts must be '' in order to
806
821
def verify_disk(wc_dir_name, disk_tree, check_props=False,
807
singleton_handler_a = None, a_baton = None,
808
singleton_handler_b = None, b_baton = None):
809
823
"""Verify WC_DIR_NAME against DISK_TREE. If CHECK_PROPS is set,
810
824
the comparison will examin props. Returns if successful, raises on
827
singleton_handler_a = None
829
singleton_handler_b = None
834
singleton_handler_a = svntest.tree.detect_conflict_files
835
done_a = svntest.tree.detect_conflict_files_done
836
a_baton = extra_files
813
838
if isinstance(disk_tree, wc.State):
814
839
disk_tree = disk_tree.old_tree()
852
874
None, the 'svn status' output will be verified against STATUS_TREE.
853
875
(This is a good way to check that revision numbers were bumped.)
855
For the DISK_TREE verification, SINGLETON_HANDLER_A and
856
SINGLETON_HANDLER_B will be passed to tree.compare_trees -- see that
857
function's doc string for more details.
859
877
If CHECK_PROPS is set, then disk comparison will examine props.
861
879
Return if successful, raise on failure."""
863
881
# Update and make a tree of the output.
865
exit_code, output, errput = main.run_svn(error_re_string, 'up', *args)
867
exit_code, output, errput = main.run_svn(error_re_string,
883
args = (wc_dir_name,)
872
rm = re.compile(error_re_string)
875
match = rm.search(line)
879
raise main.SVNUnmatchedError
885
exit_code, output, errput = run_and_verify_svn(None, expected_stderr, 'up', *args)
881
887
actual = wc.State.from_checkout(output)
882
888
verify_update(actual, None, None, wc_dir_name,
883
889
output_tree, None, None, disk_tree, status_tree,
884
singleton_handler_a, a_baton,
885
singleton_handler_b, b_baton,
889
893
def run_and_parse_info(*args):
968
972
for actual, expected in zip(actual_infos, expected_infos):
974
path = actual['Path']
970
975
for key, value in expected.items():
971
976
assert ':' not in key # caller passed impossible expectations?
972
977
if value is None and key in actual:
973
raise main.SVNLineUnequal("Found unexpected key '%s' with value '%s'"
974
% (key, actual[key]))
978
raise main.SVNLineUnequal("On '%s': Found unexpected key '%s'\n Value '%s'"
979
% (path, key, actual[key]))
975
980
if value is not None and key not in actual:
976
raise main.SVNLineUnequal("Expected key '%s' (with value '%s') "
977
"not found" % (key, value))
981
raise main.SVNLineUnequal("On '%s': Expected key '%s' not found\n Expected value '%s'"
982
% (path, key, value))
978
983
if value is not None and not re.match(value, actual[key]):
979
raise verify.SVNUnexpectedStdout("Values of key '%s' don't match:\n"
984
raise verify.SVNUnexpectedStdout("On '%s': Values of key '%s' don't match:\n"
980
985
" Expected: '%s' (regex)\n"
981
986
" Found: '%s' (string)\n"
982
% (key, value, actual[key]))
987
% (path, key, value, actual[key]))
985
990
sys.stderr.write("Bad 'svn info' output:\n"
993
998
mergeinfo_output_tree,
994
999
elision_output_tree,
995
1000
disk_tree, status_tree, skip_tree,
996
error_re_string = None,
997
singleton_handler_a = None,
999
singleton_handler_b = None,
1001
expected_stderr = [],
1001
1002
check_props = False,
1002
1003
dry_run = True,
1004
1005
"""Run 'svn merge URL1@REV1 URL2@REV2 DIR' if URL2 is not None
1005
1006
(for a three-way merge between URLs and WC).
1007
1008
If URL2 is None, run 'svn merge -rREV1:REV2 URL1 DIR'. If both REV1
1008
1009
and REV2 are None, leave off the '-r' argument.
1010
If ERROR_RE_STRING, the merge must exit with error, and the error
1011
message must match regular expression ERROR_RE_STRING.
1013
Else if ERROR_RE_STRING is None, then:
1015
1011
The subcommand output will be verified against OUTPUT_TREE. Output
1016
1012
related to mergeinfo notifications will be verified against
1017
1013
MERGEINFO_OUTPUT_TREE if that is not None. Output related to mergeinfo
1051
1047
pre_disk = tree.build_tree_from_wc(dir)
1052
1048
dry_run_command = merge_command + ('--dry-run',)
1053
1049
dry_run_command = dry_run_command + args
1054
exit_code, out_dry, err_dry = main.run_svn(error_re_string,
1050
exit_code, out_dry, err_dry = run_and_verify_svn(None, expected_stderr,
1056
1052
post_disk = tree.build_tree_from_wc(dir)
1058
1054
tree.compare_trees("disk", post_disk, pre_disk)
1066
1062
# Update and make a tree of the output.
1067
1063
merge_command = merge_command + args
1068
exit_code, out, err = main.run_svn(error_re_string, *merge_command)
1071
if not error_re_string.startswith(".*"):
1072
error_re_string = ".*(" + error_re_string + ")"
1073
expected_err = verify.RegexOutput(error_re_string, match_all=False)
1074
verify.verify_outputs(None, None, err, None, expected_err)
1077
raise verify.SVNUnexpectedStderr(err)
1064
exit_code, out, err = run_and_verify_svn(None, expected_stderr, *merge_command)
1079
1066
# Split the output into that related to application of the actual diff
1080
1067
# and that related to the recording of mergeinfo describing the merge.
1310
1295
output_tree, disk_tree, status_tree,
1311
error_re_string = None,
1312
singleton_handler_a = None,
1314
singleton_handler_b = None,
1296
expected_stderr = [],
1316
1297
check_props = False,
1319
1300
"""Switch WC_TARGET (in working copy dir WC_DIR_NAME) to SWITCH_URL.
1321
If ERROR_RE_STRING, the switch must exit with error, and the error
1322
message must match regular expression ERROR_RE_STRING.
1324
Else if ERROR_RE_STRING is None, then:
1326
1302
The subcommand output will be verified against OUTPUT_TREE, and the
1327
1303
working copy itself will be verified against DISK_TREE. If optional
1328
1304
STATUS_TREE is given, then 'svn status' output will be
1329
1305
compared. (This is a good way to check that revision numbers were
1332
For the DISK_TREE verification, SINGLETON_HANDLER_A and
1333
SINGLETON_HANDLER_B will be passed to tree.compare_trees -- see that
1334
function's doc string for more details.
1336
1308
If CHECK_PROPS is set, then disk comparison will examine props.
1338
1310
Return if successful, raise on failure."""
1340
1312
# Update and make a tree of the output.
1341
exit_code, output, errput = main.run_svn(error_re_string, 'switch',
1342
switch_url, wc_target, *args)
1345
if not error_re_string.startswith(".*"):
1346
error_re_string = ".*(" + error_re_string + ")"
1347
expected_err = verify.RegexOutput(error_re_string, match_all=False)
1348
verify.verify_outputs(None, None, errput, None, expected_err)
1350
raise verify.SVNUnexpectedStderr(err)
1313
exit_code, output, errput = run_and_verify_svn(None, expected_stderr,
1314
'switch', switch_url,
1352
1316
actual = wc.State.from_checkout(output)
1354
1318
verify_update(actual, None, None, wc_dir_name,
1355
1319
output_tree, None, None, disk_tree, status_tree,
1356
singleton_handler_a, a_baton,
1357
singleton_handler_b, b_baton,
1360
1322
def process_output_for_commit(output, error_re_string):
1361
1323
"""Helper for run_and_verify_commit(), also used in the factory."""
1423
1383
output_tree = output_tree.old_tree()
1387
args = (wc_dir_name,)
1426
1388
if '-m' not in args and '-F' not in args:
1427
1389
args = list(args) + ['-m', 'log msg']
1428
exit_code, output, errput = main.run_svn(error_re_string, 'ci',
1432
if not error_re_string.startswith(".*"):
1433
error_re_string = ".*(" + error_re_string + ")"
1434
expected_err = verify.RegexOutput(error_re_string, match_all=False)
1435
verify.verify_outputs(None, None, errput, None, expected_err)
1437
# Else not expecting error:
1390
exit_code, output, errput = run_and_verify_svn(None, expected_stderr,
1439
1393
# Convert the output into a tree.
1440
output = process_output_for_commit(output, error_re_string)
1394
output = process_output_for_commit(output, expected_stderr)
1441
1395
actual = tree.build_tree_from_commit(output)
1443
1397
# Verify actual output against expected output.
1458
1412
# This function always passes '-q' to the status command, which
1459
1413
# suppresses the printing of any unversioned or nonexistent items.
1460
def run_and_verify_status(wc_dir_name, status_tree,
1461
singleton_handler_a = None,
1463
singleton_handler_b = None,
1414
def run_and_verify_status(wc_dir_name, status_tree, no_entries=False):
1465
1415
"""Run 'status' on WC_DIR_NAME and compare it with the
1466
expected STATUS_TREE. SINGLETON_HANDLER_A and SINGLETON_HANDLER_B will
1467
be passed to tree.compare_trees - see that function's doc string for
1416
expected STATUS_TREE.
1469
1417
Returns on success, raises on failure."""
1419
if not isinstance(status_tree, wc.State):
1420
raise TypeError('wc.State tree expected')
1471
1422
exit_code, output, errput = main.run_svn(None, 'status', '-v', '-u', '-q',
1474
actual_status = svntest.wc.State.from_status(output)
1425
actual_status = svntest.wc.State.from_status(output, wc_dir=wc_dir_name)
1476
1427
# Verify actual output against expected output.
1477
if isinstance(status_tree, wc.State):
1479
status_tree.compare_and_display('status', actual_status)
1480
except tree.SVNTreeError:
1481
_log_tree_state("ACTUAL STATUS TREE:", actual_status.old_tree(),
1485
actual_status = actual_status.old_tree()
1487
tree.compare_trees("status", actual_status, status_tree,
1488
singleton_handler_a, a_baton,
1489
singleton_handler_b, b_baton)
1490
except tree.SVNTreeError:
1491
verify.display_trees(None, 'STATUS OUTPUT TREE', status_tree, actual_status)
1492
_log_tree_state("ACTUAL STATUS TREE:", actual_status, wc_dir_name)
1429
status_tree.compare_and_display('status', actual_status)
1430
except tree.SVNTreeError:
1431
_log_tree_state("ACTUAL STATUS TREE:", actual_status.old_tree(),
1495
1438
# if we have an output State, and we can/are-allowed to create an
1496
1439
# entries-based State, then compare the two.
1497
if isinstance(status_tree, wc.State):
1498
actual_entries = wc.State.from_entries(wc_dir_name)
1500
tweaked = status_tree.copy()
1501
tweaked.tweak_for_entries_compare()
1503
tweaked.compare_and_display('entries', actual_entries)
1504
except tree.SVNTreeUnequal:
1505
### do something more
1440
actual_entries = wc.State.from_entries(wc_dir_name)
1442
tweaked = status_tree.copy()
1443
tweaked.tweak_for_entries_compare()
1445
tweaked.compare_and_display('entries', actual_entries)
1446
except tree.SVNTreeUnequal:
1447
### do something more
1448
_log_tree_state("ACTUAL ENTRY TREE:", actual_entries.old_tree(),
1509
1453
# A variant of previous func, but doesn't pass '-q'. This allows us
1513
1457
expected STATUS_TREE.
1514
1458
Returns on success, raises on failure."""
1460
if not isinstance(status_tree, wc.State):
1461
raise TypeError('wc.State tree expected')
1516
1463
exit_code, output, errput = main.run_svn(None, 'status', '-v',
1517
1464
'-u', wc_dir_name)
1519
actual_status = svntest.wc.State.from_status(output)
1466
actual_status = svntest.wc.State.from_status(output, wc_dir=wc_dir_name)
1521
1468
# Verify actual output against expected output.
1522
if isinstance(status_tree, wc.State):
1524
status_tree.compare_and_display('unquiet status', actual_status)
1525
except tree.SVNTreeError:
1526
_log_tree_state("ACTUAL STATUS TREE:",
1527
actual_status.normalize().old_tree(), wc_dir_name)
1530
actual_status = actual_status.old_tree()
1532
tree.compare_trees("UNQUIET STATUS", actual_status, status_tree)
1533
except tree.SVNTreeError:
1534
_log_tree_state("ACTUAL UNQUIET STATUS TREE:", actual_status,
1470
status_tree.compare_and_display('unquiet status', actual_status)
1471
except tree.SVNTreeError:
1472
_log_tree_state("ACTUAL STATUS TREE:",
1473
actual_status.normalize().old_tree(), wc_dir_name)
1538
1476
def run_and_verify_status_xml(expected_entries = [],
1616
1554
exit_code, output, errput = svntest.actions.run_and_verify_svn(
1617
None, None, [], 'propget', propname, '--xml',
1555
None, [], 'propget', propname, '--xml',
1618
1556
'--show-inherited-props', path_or_url, *args)
1620
1558
exit_code, output, errput = svntest.actions.run_and_verify_svn(
1621
None, None, [], 'proplist', '-v', '--xml', '--show-inherited-props',
1559
None, [], 'proplist', '-v', '--xml', '--show-inherited-props',
1622
1560
path_or_url, *args)
1624
1562
if len(errput) > 0:
1775
1713
comment = "Locking path:%s." % path
1777
1715
# lock the path
1778
run_and_verify_svn(None, ".*locked by user", [], 'lock',
1716
run_and_verify_svn(".*locked by user", [], 'lock',
1779
1717
'--username', username,
1780
1718
'-m', comment, path)
1782
1720
# Run info and check that we get the lock fields.
1783
exit_code, output, err = run_and_verify_svn(None, None, [],
1721
exit_code, output, err = run_and_verify_svn(None, [],
1853
1791
# This allows a test to *quickly* bootstrap itself.
1854
def make_repo_and_wc(sbox, create_wc = True, read_only = False,
1855
minor_version = None):
1856
"""Create a fresh 'Greek Tree' repository and check out a WC from it.
1792
def make_repo_and_wc(sbox, create_wc=True, read_only=False, empty=False,
1793
minor_version=None):
1794
"""Create a fresh repository and check out a WC from it. If EMPTY is
1795
True, the repository and WC will be empty and at revision 0,
1796
otherwise they will contain the 'Greek Tree' at revision 1.
1858
1798
If READ_ONLY is False, a dedicated repository will be created, at the path
1859
SBOX.repo_dir. If READ_ONLY is True, the pristine repository will be used.
1799
SBOX.repo_dir. If READ_ONLY is True, a shared pristine repository may be
1800
used or a dedicated repository may be created. (Currently we use a shared
1801
pristine 'Greek tree' repo but we create a dedicated empty repo.)
1860
1802
In either case, SBOX.repo_url is assumed to point to the repository that
1863
If create_wc is True, a dedicated working copy will be checked out from
1805
If CREATE_WC is True, a dedicated working copy will be checked out from
1864
1806
the repository, at the path SBOX.wc_dir.
1866
1808
Returns on success, raises on failure."""
1868
# Create (or copy afresh) a new repos with a greek tree in it.
1870
guarantee_greek_repository(sbox.repo_dir, minor_version)
1810
# Create or copy or reference the appropriate kind of repository:
1811
# if we want a non-empty, Greek repo, refer to the shared one; else
1812
# if we want an empty repo or a writable Greek repo, create one.
1813
# (We could have a shared empty repo for read-only use, but we don't.)
1815
guarantee_empty_repository(sbox.repo_dir, minor_version)
1816
expected_state = svntest.wc.State('', {})
1819
guarantee_greek_repository(sbox.repo_dir, minor_version)
1820
expected_state = main.greek_state
1873
1823
# Generate the expected output tree.
1874
expected_output = main.greek_state.copy()
1824
expected_output = expected_state.copy()
1875
1825
expected_output.wc_dir = sbox.wc_dir
1876
1826
expected_output.tweak(status='A ', contents=None)
1878
1828
# Generate an expected wc tree.
1879
expected_wc = main.greek_state
1829
expected_wc = expected_state
1881
1831
# Do a checkout, and verify the resulting output and disk contents.
1882
1832
run_and_verify_checkout(sbox.repo_url,
1918
1868
# Cheap administrative directory locking
1919
def lock_admin_dir(wc_dir, recursive=False):
1869
def lock_admin_dir(wc_dir, recursive=False, work_queue=False):
1920
1870
"Lock a SVN administrative directory"
1921
1871
db, root_path, relpath = wc.open_wc_db(wc_dir)
1923
svntest.main.run_wc_lock_tester(recursive, wc_dir)
1873
svntest.main.run_wc_lock_tester(recursive, wc_dir, work_queue)
1925
1875
def set_incomplete(wc_dir, revision):
1926
1876
"Make wc_dir incomplete at revision"
2131
2081
def inject_conflict_into_expected_state(state_path,
2132
2082
expected_disk, expected_status,
2133
wc_text, merged_text, merged_rev):
2083
wc_text, merged_text, prev_rev,
2134
2085
"""Update the EXPECTED_DISK and EXPECTED_STATUS trees for the
2135
2086
conflict at STATE_PATH (ignored if None). WC_TEXT, MERGED_TEXT, and
2136
2087
MERGED_REV are used to determine the contents of the conflict (the
2137
2088
text parameters should be newline-terminated)."""
2138
2089
if expected_disk:
2139
2090
conflict_marker = make_conflict_marker_text(wc_text, merged_text,
2091
prev_rev, merged_rev)
2141
2092
existing_text = expected_disk.desc[state_path].contents or ""
2142
2093
expected_disk.tweak(state_path, contents=existing_text + conflict_marker)
2144
2095
if expected_status:
2145
2096
expected_status.tweak(state_path, status='C ')
2147
def make_conflict_marker_text(wc_text, merged_text, merged_rev):
2098
def make_conflict_marker_text(wc_text, merged_text, prev_rev, merged_rev,
2148
2100
"""Return the conflict marker text described by WC_TEXT (the current
2149
2101
text in the working copy, MERGED_TEXT (the conflicting text merged
2150
2102
in), and MERGED_REV (the revision from whence the conflicting text
2152
return "<<<<<<< .working\n" + wc_text + "=======\n" + \
2104
return "<<<<<<< .working\n" + wc_text + \
2105
"||||||| .merge-left.r" + str(prev_rev) + '\n' + \
2106
old_text + "=======\n" + \
2153
2107
merged_text + ">>>>>>> .merge-right.r" + str(merged_rev) + "\n"
2201
2155
expected_status = get_virginal_state(wc_dir, 1)
2202
2156
expected_status.tweak('A/D/G/pi', wc_rev='2')
2203
2157
expected_status.remove('A/D/G/rho', 'A/D/G/tau')
2204
run_and_verify_commit(wc_dir, expected_output, expected_status, None,
2158
run_and_verify_commit(wc_dir, expected_output, expected_status, [],
2205
2159
'-m', 'Incoming changes.', wc_dir )
2207
2161
# Update back to the pristine state ("time-warp").