In the command-line client, forbid
[svn.git] / subversion / tests / cmdline / trans_tests.py
blobc18d771aac8bb7462d1f6d5570f4a9d135ce2913
1 #!/usr/bin/env python
3 # trans_tests.py: testing eol conversion and keyword substitution
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 2000-2006 CollabNet. All rights reserved.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://subversion.tigris.org/license-1.html.
14 # If newer versions of this license are posted there, you may use a
15 # newer version instead, at your option.
17 ######################################################################
19 # General modules
20 import os, re
22 # Our testing module
23 import svntest
24 from svntest import wc
26 # (abbreviation)
27 Skip = svntest.testcase.Skip
28 XFail = svntest.testcase.XFail
29 Item = svntest.wc.StateItem
32 ######################################################################
33 # THINGS TO TEST
35 # *** Perhaps something like commit_tests.py:make_standard_slew_of_changes
36 # is in order here in this file as well. ***
38 # status level 1:
39 # enable translation, status
40 # (now throw local text mods into the picture)
42 # commit level 1:
43 # enable translation, commit
44 # (now throw local text mods into the picture)
46 # checkout:
47 # checkout stuff with translation enabled
49 # status level 2:
50 # disable translation, status
51 # change newline conversion to different style, status
52 # (now throw local text mods into the picture)
54 # commit level 2:
55 # disable translation, commit
56 # change newline conversion to different style, commit
57 # (now throw local text mods into the picture)
58 # (now throw local text mods with tortured line endings into the picture)
60 # update:
61 # update files from disabled translation to enabled translation
62 # update files from enabled translation to disabled translation
63 # update files with newline conversion style changes
64 # (now throw local text mods into the picture)
65 # (now throw conflicting local property mods into the picture)
67 ####
71 # Paths that the tests test.
72 author_rev_unexp_path = ''
73 author_rev_exp_path = ''
74 bogus_keywords_path = ''
75 embd_author_rev_unexp_path = ''
76 embd_author_rev_exp_path = ''
77 embd_bogus_keywords_path = ''
79 def check_keywords(actual_kw, expected_kw, name):
80 """A Helper function to compare two keyword lists"""
82 if len(actual_kw) != len(expected_kw):
83 print "Keyword lists are different by size"
84 raise svntest.Failure
86 for i in range(0,len(actual_kw)):
87 if actual_kw[i] != expected_kw[i]:
88 print '%s item %s, Expected: %s' % (name, i, expected_kw[i][:-1])
89 print '%s item %s, Got: %s' % (name, i, actual_kw[i][:-1])
90 raise svntest.Failure
92 def setup_working_copy(wc_dir, value_len):
93 """Setup a standard test working copy, then create (but do not add)
94 various files for testing translation."""
96 global author_rev_unexp_path
97 global author_rev_exp_path
98 global url_unexp_path
99 global url_exp_path
100 global id_unexp_path
101 global id_exp_path
102 global bogus_keywords_path
103 global embd_author_rev_unexp_path
104 global embd_author_rev_exp_path
105 global embd_bogus_keywords_path
106 global fixed_length_keywords_path
107 global id_with_space_path
108 global id_exp_with_dollar_path
110 # NOTE: Only using author and revision keywords in tests for now,
111 # since they return predictable substitutions.
113 # Unexpanded, expanded, and bogus keywords; sometimes as the only
114 # content of the files, sometimes embedded in non-keyword content.
115 author_rev_unexp_path = os.path.join(wc_dir, 'author_rev_unexp')
116 author_rev_exp_path = os.path.join(wc_dir, 'author_rev_exp')
117 url_unexp_path = os.path.join(wc_dir, 'url_unexp')
118 url_exp_path = os.path.join(wc_dir, 'url_exp')
119 id_unexp_path = os.path.join(wc_dir, 'id_unexp')
120 id_exp_path = os.path.join(wc_dir, 'id_exp')
121 bogus_keywords_path = os.path.join(wc_dir, 'bogus_keywords')
122 embd_author_rev_unexp_path = os.path.join(wc_dir, 'embd_author_rev_unexp')
123 embd_author_rev_exp_path = os.path.join(wc_dir, 'embd_author_rev_exp')
124 embd_bogus_keywords_path = os.path.join(wc_dir, 'embd_bogus_keywords')
125 fixed_length_keywords_path = os.path.join(wc_dir, 'fixed_length_keywords')
126 id_with_space_path = os.path.join(wc_dir, 'id with space')
127 id_exp_with_dollar_path = os.path.join(wc_dir, 'id_exp with_$_sign')
129 svntest.main.file_append(author_rev_unexp_path, "$Author$\n$Rev$")
130 svntest.main.file_append(author_rev_exp_path, "$Author: blah $\n$Rev: 0 $")
131 svntest.main.file_append(url_unexp_path, "$URL$")
132 svntest.main.file_append(url_exp_path, "$URL: blah $")
133 svntest.main.file_append(id_unexp_path, "$Id$")
134 svntest.main.file_append(id_exp_path, "$Id: blah $")
135 svntest.main.file_append(bogus_keywords_path, "$Arthur$\n$Rev0$")
136 svntest.main.file_append(embd_author_rev_unexp_path,
137 "one\nfish\n$Author$ two fish\n red $Rev$\n fish")
138 svntest.main.file_append(embd_author_rev_exp_path,
139 "blue $Author: blah $ fish$Rev: 0 $\nI fish")
140 svntest.main.file_append(embd_bogus_keywords_path,
141 "you fish $Arthur$then\n we$Rev0$ \n\nchew fish")
143 keyword_test_targets = [
144 # User tries to shoot him or herself on the foot
145 "$URL::$\n",
146 "$URL:: $\n",
147 "$URL:: $\n",
148 # Following are valid entries
149 "$URL:: $\n",
150 "$URL:: %s $\n" % (' ' * (value_len-1)),
151 "$URL:: %s $\n" % (' ' * value_len),
152 # Check we will clean the truncate marker when the value fits exactly
153 "$URL:: %s#$\n" % ('a' * value_len),
154 "$URL:: %s $\n" % (' ' * (value_len+1)),
155 # These are syntactically wrong
156 "$URL::x%s $\n" % (' ' * value_len),
157 "$URL:: %sx$\n" % (' ' * value_len),
158 "$URL::x%sx$\n" % (' ' * value_len)
161 for i in keyword_test_targets:
162 svntest.main.file_append(fixed_length_keywords_path, i)
164 svntest.main.file_append(id_with_space_path, "$Id$")
165 svntest.main.file_append(id_exp_with_dollar_path,
166 "$Id: id_exp with_$_sign 1 2006-06-10 11:10:00Z jrandom $")
169 ### Helper functions for setting/removing properties
171 # Set the property keyword for PATH. Turn on all possible keywords.
172 # ### todo: Later, take list of keywords to set.
173 def keywords_on(path):
174 svntest.actions.run_and_verify_svn(None, None, [], 'propset',
175 "svn:keywords", "Author Rev Date URL Id",
176 path)
178 # Delete property NAME from versioned PATH in the working copy.
179 # ### todo: Later, take list of keywords to remove from the propval?
180 def keywords_off(path):
181 svntest.actions.run_and_verify_svn(None, None, [], 'propdel',
182 "svn:keywords", path)
185 ######################################################################
186 # Tests
188 # Each test must return on success or raise on failure.
190 #----------------------------------------------------------------------
192 ### This test is know to fail when Subversion is built in very deep
193 ### directory structures, caused by SVN_KEYWORD_MAX_LEN being defined
194 ### as 255.
195 def keywords_from_birth(sbox):
196 "commit new files with keywords active from birth"
198 sbox.build()
199 wc_dir = sbox.wc_dir
201 canonical_repo_url = svntest.main.canonicalize_url(sbox.repo_url)
202 if canonical_repo_url[-1:] != '/':
203 url_expand_test_data = canonical_repo_url + '/fixed_length_keywords'
204 else:
205 url_expand_test_data = canonical_repo_url + 'fixed_length_keywords'
207 setup_working_copy(wc_dir, len(url_expand_test_data))
209 # Add all the files
210 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
211 expected_status.add({
212 'author_rev_unexp' : Item(status='A ', wc_rev=0),
213 'author_rev_exp' : Item(status='A ', wc_rev=0),
214 'url_unexp' : Item(status='A ', wc_rev=0),
215 'url_exp' : Item(status='A ', wc_rev=0),
216 'id_unexp' : Item(status='A ', wc_rev=0),
217 'id_exp' : Item(status='A ', wc_rev=0),
218 'bogus_keywords' : Item(status='A ', wc_rev=0),
219 'embd_author_rev_unexp' : Item(status='A ', wc_rev=0),
220 'embd_author_rev_exp' : Item(status='A ', wc_rev=0),
221 'embd_bogus_keywords' : Item(status='A ', wc_rev=0),
222 'fixed_length_keywords' : Item(status='A ', wc_rev=0),
223 'id with space' : Item(status='A ', wc_rev=0),
224 'id_exp with_$_sign' : Item(status='A ', wc_rev=0),
227 svntest.main.run_svn(None, 'add', author_rev_unexp_path)
228 svntest.main.run_svn(None, 'add', author_rev_exp_path)
229 svntest.main.run_svn(None, 'add', url_unexp_path)
230 svntest.main.run_svn(None, 'add', url_exp_path)
231 svntest.main.run_svn(None, 'add', id_unexp_path)
232 svntest.main.run_svn(None, 'add', id_exp_path)
233 svntest.main.run_svn(None, 'add', bogus_keywords_path)
234 svntest.main.run_svn(None, 'add', embd_author_rev_unexp_path)
235 svntest.main.run_svn(None, 'add', embd_author_rev_exp_path)
236 svntest.main.run_svn(None, 'add', embd_bogus_keywords_path)
237 svntest.main.run_svn(None, 'add', fixed_length_keywords_path)
238 svntest.main.run_svn(None, 'add', id_with_space_path)
239 svntest.main.run_svn(None, 'add', id_exp_with_dollar_path)
241 svntest.actions.run_and_verify_status(wc_dir, expected_status)
243 # Add the keyword properties.
244 keywords_on(author_rev_unexp_path)
245 keywords_on(url_unexp_path)
246 keywords_on(url_exp_path)
247 keywords_on(id_unexp_path)
248 keywords_on(id_exp_path)
249 keywords_on(embd_author_rev_exp_path)
250 keywords_on(fixed_length_keywords_path)
251 keywords_on(id_with_space_path)
252 keywords_on(id_exp_with_dollar_path)
254 # Commit.
255 expected_output = svntest.wc.State(wc_dir, {
256 'author_rev_unexp' : Item(verb='Adding'),
257 'author_rev_exp' : Item(verb='Adding'),
258 'url_unexp' : Item(verb='Adding'),
259 'url_exp' : Item(verb='Adding'),
260 'id_unexp' : Item(verb='Adding'),
261 'id_exp' : Item(verb='Adding'),
262 'bogus_keywords' : Item(verb='Adding'),
263 'embd_author_rev_unexp' : Item(verb='Adding'),
264 'embd_author_rev_exp' : Item(verb='Adding'),
265 'embd_bogus_keywords' : Item(verb='Adding'),
266 'fixed_length_keywords' : Item(verb='Adding'),
267 'id with space' : Item(verb='Adding'),
268 'id_exp with_$_sign' : Item(verb='Adding'),
271 svntest.actions.run_and_verify_commit(wc_dir, expected_output,
272 None, None,
273 None, None, None, None, wc_dir)
275 # Make sure the unexpanded URL keyword got expanded correctly.
276 fp = open(url_unexp_path, 'r')
277 lines = fp.readlines()
278 if not ((len(lines) == 1)
279 and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
280 print "URL expansion failed for", url_unexp_path
281 raise svntest.Failure
282 fp.close()
284 # Make sure the preexpanded URL keyword got reexpanded correctly.
285 fp = open(url_exp_path, 'r')
286 lines = fp.readlines()
287 if not ((len(lines) == 1)
288 and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
289 print "URL expansion failed for", url_exp_path
290 raise svntest.Failure
291 fp.close()
293 # Make sure the unexpanded Id keyword got expanded correctly.
294 fp = open(id_unexp_path, 'r')
295 lines = fp.readlines()
296 if not ((len(lines) == 1)
297 and (re.match("\$Id: id_unexp", lines[0]))):
298 print "Id expansion failed for", id_exp_path
299 raise svntest.Failure
300 fp.close()
302 # Make sure the preexpanded Id keyword got reexpanded correctly.
303 fp = open(id_exp_path, 'r')
304 lines = fp.readlines()
305 if not ((len(lines) == 1)
306 and (re.match("\$Id: id_exp", lines[0]))):
307 print "Id expansion failed for", id_exp_path
308 raise svntest.Failure
309 fp.close()
311 # Check fixed length keywords.
312 kw_workingcopy = [
313 '$URL::$\n',
314 '$URL:: $\n',
315 '$URL:: $\n',
316 '$URL:: %s#$\n' % url_expand_test_data[0:1],
317 '$URL:: %s#$\n' % url_expand_test_data[:-1],
318 '$URL:: %s $\n' % url_expand_test_data,
319 '$URL:: %s $\n' % url_expand_test_data,
320 '$URL:: %s $\n'% url_expand_test_data,
321 '$URL::x%s $\n' % (' ' * len(url_expand_test_data)),
322 '$URL:: %sx$\n' % (' ' * len(url_expand_test_data)),
323 '$URL::x%sx$\n' % (' ' * len(url_expand_test_data))
326 fp = open(fixed_length_keywords_path, 'r')
327 actual_workingcopy_kw = fp.readlines()
328 fp.close()
329 check_keywords(actual_workingcopy_kw, kw_workingcopy, "working copy")
331 # Check text base for fixed length keywords.
332 kw_textbase = [
333 '$URL::$\n',
334 '$URL:: $\n',
335 '$URL:: $\n',
336 '$URL:: $\n',
337 '$URL:: %s $\n' % (' ' * len(url_expand_test_data[:-1])),
338 '$URL:: %s $\n' % (' ' * len(url_expand_test_data)),
339 '$URL:: %s $\n' % (' ' * len(url_expand_test_data)),
340 '$URL:: %s $\n'% (' ' * len(url_expand_test_data)),
341 '$URL::x%s $\n' % (' ' * len(url_expand_test_data)),
342 '$URL:: %sx$\n' % (' ' * len(url_expand_test_data)),
343 '$URL::x%sx$\n' % (' ' * len(url_expand_test_data))
346 fp = open(os.path.join(wc_dir, svntest.main.get_admin_name(),
347 'text-base', 'fixed_length_keywords.svn-base'), 'r')
348 actual_textbase_kw = fp.readlines()
349 fp.close()
350 check_keywords(actual_textbase_kw, kw_textbase, "text base")
352 # Check the Id keyword for filename with spaces.
353 fp = open(id_with_space_path, 'r')
354 lines = fp.readlines()
355 if not ((len(lines) == 1)
356 and (re.match("\$Id: .*id with space", lines[0]))):
357 print "Id expansion failed for", id_with_space_path
358 raise svntest.Failure
359 fp.close()
361 # Check the Id keyword for filename with_$_signs.
362 fp = open(id_exp_with_dollar_path, 'r')
363 lines = fp.readlines()
364 if not ((len(lines) == 1)
365 and (re.match("\$Id: .*id_exp with_\$_sign [^$]* jrandom \$",
366 lines[0]))):
367 print "Id expansion failed for", id_exp_with_dollar_path
369 raise svntest.Failure
370 fp.close()
372 #----------------------------------------------------------------------
374 #def enable_translation(sbox):
375 # "enable translation, check status, commit"
377 # TODO: Turn on newline conversion and/or keyword substitution for all
378 # sorts of files, with and without local mods, and verify that
379 # status shows the right stuff. The, commit those mods.
381 #----------------------------------------------------------------------
383 #def checkout_translated():
384 # "checkout files that have translation enabled"
386 # TODO: Checkout a tree which contains files with translation
387 # enabled.
389 #----------------------------------------------------------------------
391 #def disable_translation():
392 # "disable translation, check status, commit"
394 # TODO: Disable translation on files which have had it enabled,
395 # with and without local mods, check status, and commit.
397 #----------------------------------------------------------------------
399 # Regression test for bug discovered by Vladmir Prus <ghost@cs.msu.csu>.
400 # This is a slight rewrite of his test, to use the run_and_verify_* API.
401 # This is for issue #631.
403 def do_nothing(x, y):
404 return 0
406 def update_modified_with_translation(sbox):
407 "update modified file with eol-style 'native'"
409 sbox.build()
410 wc_dir = sbox.wc_dir
412 # Replace contents of rho and set eol translation to 'native'
413 rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
414 svntest.main.file_write(rho_path, "1\n2\n3\n4\n5\n6\n7\n8\n9\n")
415 svntest.actions.run_and_verify_svn(None, None, [],
416 'propset', 'svn:eol-style', 'native',
417 rho_path)
419 # Create expected output and status trees of a commit.
420 expected_output = svntest.wc.State(wc_dir, {
421 'A/D/G/rho' : Item(verb='Sending'),
424 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
425 # rho has props
426 expected_status.tweak('A/D/G/rho', wc_rev=2, status=' ')
428 # Commit revision 2: it has the new rho.
429 svntest.actions.run_and_verify_commit(wc_dir,
430 expected_output,
431 expected_status,
432 None, None, None, None, None,
433 rho_path)
435 # Change rho again
436 svntest.main.file_write(rho_path, "1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n")
438 # Commit revision 3
439 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
440 expected_status.tweak('A/D/G/rho', wc_rev=3, status=' ')
442 svntest.actions.run_and_verify_commit(wc_dir,
443 expected_output,
444 expected_status,
445 None, None, None, None, None,
446 rho_path)
448 # Locally modify rho again.
449 svntest.main.file_write(rho_path, "1\n2\n3\n4\n4.5\n5\n6\n7\n8\n9\n10\n")
451 # Prepare trees for an update to rev 1.
452 expected_output = svntest.wc.State(wc_dir, {
453 'A/D/G/rho' : Item(status='CU'),
456 expected_disk = svntest.main.greek_state.copy()
457 expected_disk.tweak('A/D/G/rho',
458 contents="\n".join(["<<<<<<< .mine",
459 "1",
460 "2",
461 "3",
462 "4",
463 "4.5",
464 "5",
465 "6",
466 "7",
467 "8",
468 "9",
469 "10",
470 "=======",
471 "This is the file 'rho'.",
472 ">>>>>>> .r1",
473 ""]))
475 # Updating back to revision 1 should not error; the merge should
476 # work, with eol-translation turned on.
477 svntest.actions.run_and_verify_update(wc_dir,
478 expected_output,
479 expected_disk,
480 None, None,
481 do_nothing, None,
482 None, None,
483 0, '-r', '1', wc_dir)
486 #----------------------------------------------------------------------
488 # Regression test for issue #1085, whereby setting the eol-style to a
489 # fixed platform-incorrect value on a file whose line endings are
490 # platform-correct causes repository insanity (the eol-style prop
491 # claims one line ending style, the file is in another). This test
492 # assumes that this can be testing by verifying that a) new file
493 # contents are transmitted to the server during commit, and b) that
494 # after the commit, the file and its text-base have been changed to
495 # have the new line-ending style.
497 def eol_change_is_text_mod(sbox):
498 "committing eol-style change forces text send"
500 sbox.build()
502 wc_dir = sbox.wc_dir
504 # add a new file to the working copy.
505 foo_path = os.path.join(wc_dir, 'foo')
506 f = open(foo_path, 'wb')
507 if svntest.main.windows:
508 f.write("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n")
509 else:
510 f.write("1\n2\n3\n4\n5\n6\n7\n8\n9\n")
511 f.close()
513 # commit the file
514 svntest.actions.run_and_verify_svn(None, None, [], 'add', foo_path)
515 svntest.actions.run_and_verify_svn(None, None, [],
516 'ci', '-m', 'log msg',
517 foo_path)
519 if svntest.main.windows:
520 svntest.actions.run_and_verify_svn(None, None, [], 'propset',
521 'svn:eol-style', 'LF', foo_path)
522 else:
523 svntest.actions.run_and_verify_svn(None, None, [], 'propset',
524 'svn:eol-style', 'CRLF', foo_path)
526 # check 1: did new contents get transmitted?
527 expected_output = ["Sending " + foo_path + "\n",
528 "Transmitting file data .\n",
529 "Committed revision 3.\n"]
530 svntest.actions.run_and_verify_svn(None, expected_output, [],
531 'ci', '-m', 'log msg', foo_path)
533 # check 2: do the files have the right contents now?
534 contents = svntest.main.file_read(foo_path, 'rb')
535 if svntest.main.windows:
536 if contents != "1\n2\n3\n4\n5\n6\n7\n8\n9\n":
537 raise svntest.Failure
538 else:
539 if contents != "1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n":
540 raise svntest.Failure
542 foo_base_path = os.path.join(wc_dir, svntest.main.get_admin_name(),
543 'text-base', 'foo.svn-base')
544 base_contents = svntest.main.file_read(foo_base_path, 'rb')
545 if contents != base_contents:
546 raise svntest.Failure
548 #----------------------------------------------------------------------
549 # Regression test for issue #1151. A single file in a directory
550 # didn't get keywords expanded on checkout.
552 def keyword_expanded_on_checkout(sbox):
553 "keyword expansion for lone file in directory"
555 sbox.build()
556 wc_dir = sbox.wc_dir
558 # The bug didn't occur if there were multiple files in the
559 # directory, so setup an empty directory.
560 Z_path = os.path.join(wc_dir, 'Z')
561 svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', Z_path)
563 # Add the file that has the keyword to be expanded
564 url_path = os.path.join(Z_path, 'url')
565 svntest.main.file_append(url_path, "$URL$")
566 svntest.actions.run_and_verify_svn(None, None, [], 'add', url_path)
567 keywords_on(url_path)
569 svntest.actions.run_and_verify_svn(None, None, [],
570 'ci', '-m', 'log msg', wc_dir)
572 other_wc_dir = sbox.add_wc_path('other')
573 other_url_path = os.path.join(other_wc_dir, 'Z', 'url')
574 svntest.actions.run_and_verify_svn(None, None, [], 'checkout',
575 sbox.repo_url,
576 other_wc_dir)
578 # Check keyword got expanded (and thus the mkdir, add, ps, commit
579 # etc. worked)
580 fp = open(other_url_path, 'r')
581 lines = fp.readlines()
582 if not ((len(lines) == 1)
583 and (re.match("\$URL: (http|file|svn|svn\\+ssh)://", lines[0]))):
584 print "URL expansion failed for", other_url_path
585 raise svntest.Failure
586 fp.close()
589 #----------------------------------------------------------------------
590 def cat_keyword_expansion(sbox):
591 "keyword expanded on cat"
593 sbox.build()
594 wc_dir = sbox.wc_dir
595 mu_path = os.path.join(wc_dir, 'A', 'mu')
596 lambda_path = os.path.join(wc_dir, 'A', 'B', 'lambda')
598 # Set up A/mu to do $Rev$ keyword expansion
599 svntest.main.file_append(mu_path , "$Rev$\n$Author$")
600 svntest.actions.run_and_verify_svn(None, None, [],
601 'propset', 'svn:keywords', 'Rev Author',
602 mu_path)
604 expected_output = wc.State(wc_dir, {
605 'A/mu' : Item(verb='Sending'),
607 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
608 expected_status.tweak('A/mu', wc_rev=2)
609 svntest.actions.run_and_verify_commit(wc_dir,
610 expected_output, expected_status,
611 None, None, None, None, None,
612 wc_dir)
614 # Change the author to value which will get truncated on expansion
615 full_author = "x" * 400
616 key_author = "x" * 244
617 svntest.actions.enable_revprop_changes(sbox.repo_dir)
618 svntest.actions.run_and_verify_svn(None, None, [],
619 'propset', '--revprop', '-r2',
620 'svn:author', full_author,
621 sbox.wc_dir)
622 svntest.actions.run_and_verify_svn(None, [ full_author ], [],
623 'propget', '--revprop', '-r2',
624 'svn:author', '--strict',
625 sbox.wc_dir)
627 # Make another commit so that the last changed revision for A/mu is
628 # not HEAD.
629 svntest.actions.run_and_verify_svn(None, None, [],
630 'propset', 'foo', 'bar', lambda_path)
631 expected_output = wc.State(wc_dir, {
632 'A/B/lambda' : Item(verb='Sending'),
634 expected_status.tweak('A/B/lambda', wc_rev=3)
635 svntest.actions.run_and_verify_commit(wc_dir,
636 expected_output, expected_status,
637 None, None, None, None, None,
638 wc_dir)
640 # At one stage the keywords were expanded to values for the requested
641 # revision, not to those committed revision
642 svntest.actions.run_and_verify_svn(None,
643 [ "This is the file 'mu'.\n",
644 "$Rev: 2 $\n",
645 "$Author: " + key_author + " $"], [],
646 'cat', '-r', 'HEAD', mu_path)
649 #----------------------------------------------------------------------
650 def copy_propset_commit(sbox):
651 "copy, propset svn:eol-style, commit"
653 sbox.build()
654 wc_dir = sbox.wc_dir
655 mu_path = os.path.join(wc_dir, 'A', 'mu')
656 mu2_path = os.path.join(wc_dir, 'A', 'mu2')
658 # Copy and propset
659 svntest.actions.run_and_verify_svn(None, None, [], 'copy', mu_path, mu2_path)
660 svntest.actions.run_and_verify_svn(None, None, [],
661 'propset', 'svn:eol-style', 'native',
662 mu2_path)
663 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
664 expected_status.add({
665 'A/mu2' : Item(status='A ', wc_rev='-', copied='+')
667 svntest.actions.run_and_verify_status(wc_dir, expected_status)
669 # Commit, at one stage this dumped core
670 expected_output = wc.State(wc_dir, {
671 'A/mu2' : Item(verb='Adding'),
673 expected_status.tweak('A/mu2', status=' ', wc_rev=2, copied=None)
674 svntest.actions.run_and_verify_commit(wc_dir,
675 expected_output, expected_status,
676 None, None, None, None, None,
677 wc_dir)
679 #----------------------------------------------------------------------
680 # Create a greek tree, commit a keyword into one file,
681 # then commit a keyword property (i.e., turn on keywords), then
682 # try to check out head somewhere else.
683 # This should not cause seg fault
684 def propset_commit_checkout_nocrash(sbox):
685 "propset, commit, check out into another wc"
687 sbox.build()
688 wc_dir = sbox.wc_dir
689 mu_path = os.path.join(wc_dir, 'A', 'mu')
691 # Put a keyword in A/mu, commit
692 svntest.main.file_append(mu_path, "$Rev$")
693 expected_output = wc.State(wc_dir, {
694 'A/mu' : Item(verb='Sending'),
696 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
697 expected_status.tweak('A/mu', wc_rev=2)
698 svntest.actions.run_and_verify_commit(wc_dir,
699 expected_output, expected_status,
700 None, None, None, None, None,
701 wc_dir)
703 # Set property to do keyword expansion on A/mu, commit.
704 svntest.actions.run_and_verify_svn(None, None, [],
705 'propset', 'svn:keywords', 'Rev', mu_path)
706 expected_output = wc.State(wc_dir, {
707 'A/mu' : Item(verb='Sending'),
709 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
710 expected_status.tweak('A/mu', wc_rev=3)
711 svntest.actions.run_and_verify_commit(wc_dir,
712 expected_output, expected_status,
713 None, None, None, None, None,
714 wc_dir)
716 # Check out into another wc dir
717 other_wc_dir = sbox.add_wc_path('other')
718 mu_other_path = os.path.join(other_wc_dir, 'A', 'mu')
720 svntest.actions.run_and_verify_svn(None, None, [], 'checkout',
721 sbox.repo_url,
722 other_wc_dir)
724 mu_other_contents = svntest.main.file_read(mu_other_path)
725 if mu_other_contents != "This is the file 'mu'.\n$Rev: 3 $":
726 print "'%s' does not have the expected contents" % mu_other_path
727 raise svntest.Failure
730 #----------------------------------------------------------------------
731 # Add the keyword property to a file, svn revert the file
732 # This should not display any error message
733 def propset_revert_noerror(sbox):
734 "propset, revert"
736 sbox.build()
737 wc_dir = sbox.wc_dir
738 mu_path = os.path.join(wc_dir, 'A', 'mu')
740 # Set the Rev keyword for the mu file
741 # could use the keywords_on()/keywords_off() functions to
742 # set/del all svn:keywords
743 svntest.actions.run_and_verify_svn(None, None, [],
744 'propset', 'svn:keywords', 'Rev', mu_path)
745 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
746 expected_status.tweak('A/mu', status=' M')
747 svntest.actions.run_and_verify_status(wc_dir, expected_status)
749 # Revert the propset
750 svntest.actions.run_and_verify_svn(None, None, [], 'revert', mu_path)
751 expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
752 svntest.actions.run_and_verify_status(wc_dir, expected_status)
755 ########################################################################
756 # Run the tests
759 # list all tests here, starting with None:
760 test_list = [ None,
761 keywords_from_birth,
762 # enable_translation,
763 # checkout_translated,
764 # disable_translation,
765 update_modified_with_translation,
766 eol_change_is_text_mod,
767 keyword_expanded_on_checkout,
768 cat_keyword_expansion,
769 copy_propset_commit,
770 propset_commit_checkout_nocrash,
771 propset_revert_noerror,
774 if __name__ == '__main__':
775 svntest.main.run_tests(test_list)
776 # NOTREACHED
779 ### End of file.