3 # stat_tests.py: testing the svn stat command
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 2000-2007 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 ######################################################################
24 from svntest
import wc
27 Skip
= svntest
.testcase
.Skip
28 SkipUnless
= svntest
.testcase
.SkipUnless
29 XFail
= svntest
.testcase
.XFail
30 Item
= svntest
.wc
.StateItem
34 ######################################################################
37 # Each test must return on success or raise on failure.
39 #----------------------------------------------------------------------
41 def status_unversioned_file_in_current_dir(sbox
):
42 "status on unversioned file in current directory"
44 sbox
.build(read_only
= True)
49 svntest
.main
.file_append('foo', 'a new file')
51 svntest
.actions
.run_and_verify_svn(None, [ "? foo\n" ], [],
54 #----------------------------------------------------------------------
55 # Regression for issue #590
57 def status_update_with_nested_adds(sbox
):
58 "run 'status -u' when nested additions are pending"
63 # Make a backup copy of the working copy
64 wc_backup
= sbox
.add_wc_path('backup')
65 svntest
.actions
.duplicate_dir(wc_dir
, wc_backup
)
67 # Create newdir and newfile
68 newdir_path
= os
.path
.join(wc_dir
, 'newdir')
69 newfile_path
= os
.path
.join(wc_dir
, 'newdir', 'newfile')
70 os
.makedirs(newdir_path
)
71 svntest
.main
.file_append(newfile_path
, 'new text')
73 # Schedule newdir and newfile for addition (note that the add is recursive)
74 svntest
.main
.run_svn(None, 'add', newdir_path
)
76 # Created expected output tree for commit
77 expected_output
= svntest
.wc
.State(wc_dir
, {
78 'newdir' : Item(verb
='Adding'),
79 'newdir/newfile' : Item(verb
='Adding'),
82 # Create expected status tree; all local revisions should be at 1,
83 # but newdir and newfile should be at revision 2.
84 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
86 'newdir' : Item(status
=' ', wc_rev
=2),
87 'newdir/newfile' : Item(status
=' ', wc_rev
=2),
91 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
92 expected_status
, None, wc_dir
)
94 # Now we go to the backup working copy, still at revision 1.
95 # We will run 'svn st -u', and make sure that newdir/newfile is reported
96 # as a nonexistent (but pending) path.
98 # Create expected status tree; all local revisions should be at 1,
99 # but newdir and newfile should be present with 'blank' attributes.
100 expected_status
= svntest
.actions
.get_virginal_state(wc_backup
, 1)
102 # Verify status. Notice that we're running status *without* the
103 # --quiet flag, so the unversioned items will appear.
104 # Unfortunately, the regexp that we currently use to parse status
105 # output is unable to parse a line that has no working revision! If
106 # an error happens, we'll catch it here. So that's a good enough
107 # regression test for now. Someday, though, it would be nice to
108 # positively match the mostly-empty lines.
109 svntest
.actions
.run_and_verify_unquiet_status(wc_backup
,
112 #----------------------------------------------------------------------
114 # svn status -vN should include all entries in a directory
115 def status_shows_all_in_current_dir(sbox
):
116 "status -vN shows all items in current directory"
118 sbox
.build(read_only
= True)
122 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [],
125 if (len(output
) != len(os
.listdir("."))):
126 raise svntest
.Failure
129 #----------------------------------------------------------------------
131 def status_missing_file(sbox
):
132 "status with a versioned file missing"
134 sbox
.build(read_only
= True)
141 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
143 if not re
.match("! +iota", line
):
144 raise svntest
.Failure
146 # This invocation is for issue #2127.
147 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [],
148 'status', '-u', 'iota')
151 if re
.match("! +1 +iota", line
):
154 raise svntest
.Failure
156 #----------------------------------------------------------------------
158 def status_type_change(sbox
):
159 "status on versioned items whose type has changed"
161 sbox
.build(read_only
= True)
166 # First replace a versioned dir with a file and a versioned file
167 # with a versioned dir.
168 os
.rename('iota', 'was_iota')
169 os
.rename('A', 'iota')
170 os
.rename('was_iota', 'A')
172 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
174 raise svntest
.Failure
176 if not re
.match("~ +(iota|A)", line
):
177 raise svntest
.Failure
179 # Now change the file that is obstructing the versioned dir into an
184 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
186 raise svntest
.Failure
188 if not re
.match("~ +(iota|A)", line
):
189 raise svntest
.Failure
191 # Now change the versioned dir that is obstructing the file into an
193 svntest
.main
.safe_rmtree('iota')
196 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
198 raise svntest
.Failure
200 if not re
.match("~ +(iota|A)", line
):
201 raise svntest
.Failure
203 #----------------------------------------------------------------------
205 def status_type_change_to_symlink(sbox
):
206 "status on versioned items replaced by symlinks"
208 sbox
.build(read_only
= True)
215 os
.symlink('foo', 'iota')
216 svntest
.main
.safe_rmtree('A/D')
217 os
.symlink('bar', 'A/D')
219 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
221 raise svntest
.Failure
223 if not re
.match("~ +(iota|A/D)", line
):
224 raise svntest
.Failure
229 os
.symlink('A/mu', 'iota')
230 os
.symlink('C', 'A/D')
232 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'status')
234 raise svntest
.Failure
236 if not re
.match("~ +(iota|A/D)", line
):
237 raise svntest
.Failure
239 #----------------------------------------------------------------------
240 # Regression test for revision 3686.
242 def status_with_new_files_pending(sbox
):
243 "status -u with new files in the repository"
250 svntest
.main
.file_append('newfile', 'this is a new file')
251 svntest
.main
.run_svn(None, 'add', 'newfile')
252 svntest
.main
.run_svn(None,
253 'ci', '-m', 'logmsg')
254 svntest
.main
.run_svn(None,
257 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [],
260 # The bug fixed in revision 3686 was a seg fault. We don't have a
261 # reliable way to detect a seg fault here, since we haven't dealt
262 # with the popen2{Popen3,Popen4} mess in Python yet (the latter two
263 # are classes within the first, which is a module, and the Popen3
264 # class is not the same as os.popen3(). Got that?) See the Python
265 # docs for details; in the meantime, no output means there was a
268 if line
.find('newfile') != -1:
271 raise svntest
.Failure
273 #----------------------------------------------------------------------
275 def status_for_unignored_file(sbox
):
276 "status for unignored file and directory"
278 sbox
.build(read_only
= True)
283 # use a temp file to set properties with wildcards in their values
284 # otherwise Win32/VS2005 will expand them
285 svntest
.main
.file_append('proptmp', 'new*')
286 svntest
.main
.file_append('newfile', 'this is a new file')
287 os
.makedirs('newdir')
288 svntest
.main
.run_svn(None, 'propset', 'svn:ignore', '-F', 'proptmp', '.')
291 # status on the directory with --no-ignore
292 expected
= svntest
.verify
.UnorderedOutput(
296 svntest
.actions
.run_and_verify_svn(None,
299 'status', '--no-ignore', '.')
301 # status specifying the file explicitly on the command line
302 expected
= svntest
.verify
.UnorderedOutput(
305 svntest
.actions
.run_and_verify_svn(None,
308 'status', 'newdir', 'newfile')
310 #----------------------------------------------------------------------
312 def status_for_nonexistent_file(sbox
):
313 "status on missing and unversioned file"
315 sbox
.build(read_only
= True)
321 output
, err
= svntest
.actions
.run_and_verify_svn(None, None, [],
325 # there should *not* be a status line printed for the nonexistent file
327 if re
.match(" +nonexistent-file", line
):
328 raise svntest
.Failure
330 #----------------------------------------------------------------------
332 def status_nonrecursive_update_different_cwd(sbox
):
333 "status -v -N -u from different current directories"
335 # check combination of status -u and -N
336 # create A/C/J in repository
337 # create A/C/K in working copy
338 # check status output with -u and -N on target C
339 # check status output with -u and -N on target . (in C)
344 J_url
= sbox
.repo_url
+ '/A/C/J'
345 K_path
= os
.path
.join(wc_dir
, 'A', 'C', 'K' )
347 svntest
.actions
.run_and_verify_svn(None, None, [],
348 'mkdir', '-m', 'rev 2', J_url
)
350 svntest
.actions
.run_and_verify_svn(None, None, [],
356 ' * %s\n' % os
.path
.join("C", "J"),
357 'A 0 ? ? %s\n' % os
.path
.join("C", "K"),
358 ' * 1 1 jrandom C\n',
359 'Status against revision: 2\n' ]
362 svntest
.actions
.run_and_verify_svn(None,
365 'status', '-v', '-N', '-u', 'C')
370 ' * 1 1 jrandom .\n',
371 'Status against revision: 2\n']
374 svntest
.actions
.run_and_verify_svn(None,
377 'status', '-v', '-N', '-u', '.')
380 #----------------------------------------------------------------------
382 def status_file_needs_update(sbox
):
383 "status -u indicates out-of-dateness"
387 # http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=27975
389 # Basically, Andreas was seeing inconsistent results depending on
390 # whether or not he accompanied 'svn status -u' with '-v':
399 # 56 6 k cron-daily.pl
400 # * 56 44 k crontab.root
405 # The first status should show the asterisk, too. There was never
406 # any issue for this bug, so this comment and the thread are your
412 other_wc
= sbox
.add_wc_path('other')
414 svntest
.actions
.duplicate_dir(wc_dir
, other_wc
)
416 was_cwd
= os
.getcwd()
419 svntest
.main
.file_append('crontab.root', 'New file crontab.root.\n')
420 svntest
.main
.run_svn(None, 'add', 'crontab.root')
421 svntest
.main
.run_svn(None,
422 'ci', '-m', 'log msg')
425 svntest
.main
.run_svn(None,
430 svntest
.main
.file_append('crontab.root', 'New line in crontab.root.\n')
431 svntest
.main
.run_svn(None,
432 'ci', '-m', 'log msg')
434 # The `svntest.actions.run_and_verify_*_status' routines all pass
435 # the -v flag, which we don't want, as this bug never appeared when
436 # -v was passed. So we run status by hand:
438 out
, err
= svntest
.actions
.run_and_verify_svn(None, None, [],
439 'status', '-u', other_wc
)
442 if re
.match("\\s+\\*.*crontab\\.root$", line
):
445 raise svntest
.Failure
447 #----------------------------------------------------------------------
449 def status_uninvited_parent_directory(sbox
):
450 "status -u on outdated, added file shows only that"
452 # To reproduce, check out working copies wc1 and wc2, then do:
455 # $ echo "new file" >> newfile
457 # $ svn ci -m 'log msg'
460 # $ echo "new file" >> newfile
464 # $ svn st wc2/newfile
466 # You *should* get one line of status output, for newfile. The bug
467 # is that you get two instead, one for newfile, and one for its
468 # parent directory, wc2/.
470 # This bug was originally discovered during investigations into
471 # issue #1042, "fixed" in revision 4181, then later the fix was
472 # reverted because it caused other status problems (see the test
473 # status_file_needs_update(), which fails when 4181 is present).
478 other_wc
= sbox
.add_wc_path('other')
480 svntest
.actions
.duplicate_dir(wc_dir
, other_wc
)
482 was_cwd
= os
.getcwd()
485 svntest
.main
.file_append('newfile', 'New file.\n')
486 svntest
.main
.run_svn(None, 'add', 'newfile')
487 svntest
.main
.run_svn(None,
488 'ci', '-m', 'log msg')
492 svntest
.main
.file_append('newfile', 'New file.\n')
493 svntest
.main
.run_svn(None, 'add', 'newfile')
497 # We don't want a full status tree here, just one line (or two, if
498 # the bug is present). So run status by hand:
500 out
, err
= svntest
.actions
.run_and_verify_svn(
502 'status', '-u', os
.path
.join(other_wc
, 'newfile'))
505 # The "/?" is just to allow for an optional trailing slash.
506 if re
.match("\\s+\\*.*\.other/?$", line
):
507 raise svntest
.Failure
509 def status_on_forward_deletion(sbox
):
510 "status -u on working copy deleted in HEAD"
512 sbox
.build(create_wc
= False)
515 top_url
= sbox
.repo_url
516 A_url
= top_url
+ '/A'
518 svntest
.main
.run_svn(None,
519 'rm', '-m', 'Remove A.', A_url
)
521 svntest
.main
.safe_rmtree(wc_dir
)
526 svntest
.main
.run_svn(None,
527 'co', '-r1', top_url
+ "@1", 'wc')
528 # If the bug is present, this will error with
530 # subversion/libsvn_wc/lock.c:513: (apr_err=155005)
531 # svn: Working copy not locked
532 # svn: directory '' not locked
534 svntest
.actions
.run_and_verify_svn(None, None, [], 'st', '-u', 'wc')
536 # Try again another way; the error would look like this:
538 # subversion/libsvn_repos/delta.c:207: (apr_err=160005)
539 # svn: Invalid filesystem path syntax
540 # svn: svn_repos_dir_delta: invalid editor anchoring; at least \
541 # one of the input paths is not a directory and there was \
544 # (Dang! Hope a user never has to see that :-) ).
546 svntest
.main
.safe_rmtree('wc')
547 svntest
.main
.run_svn(None,
548 'co', '-r1', A_url
+ "@1", 'wc')
549 svntest
.actions
.run_and_verify_svn(None, None, [], 'st', '-u', 'wc')
551 #----------------------------------------------------------------------
553 def get_last_changed_date(path
):
554 "get the Last Changed Date for path using svn info"
555 out
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'info', path
)
557 if re
.match("^Last Changed Date", line
):
559 print "Didn't find Last Changed Date for " + path
560 raise svntest
.Failure
562 # Helper for timestamp_behaviour test
563 def get_text_timestamp(path
):
564 "get the text-time for path using svn info"
565 out
, err
= svntest
.actions
.run_and_verify_svn(None, None, [], 'info', path
)
567 if re
.match("^Text Last Updated", line
):
569 print "Didn't find text-time for " + path
570 raise svntest
.Failure
572 # Helper for timestamp_behaviour test
573 def text_time_behaviour(wc_dir
, wc_path
, status_path
, expected_status
, cmd
):
574 "text-time behaviour"
576 # Pristine text and text-time
577 fp
= open(wc_path
, 'rb')
578 pre_text
= fp
.readlines()
579 pre_text_time
= get_text_timestamp(wc_path
)
581 # Modifying the text does not affect text-time
582 svntest
.main
.file_append(wc_path
, "some mod")
583 expected_status
.tweak(status_path
, status
='M ')
584 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
585 text_time
= get_text_timestamp(wc_path
)
586 if text_time
!= pre_text_time
:
587 raise svntest
.Failure
589 # Manually reverting the text does not affect the text-time
590 fp
= open(wc_path
, 'wb')
591 fp
.writelines(pre_text
)
593 expected_status
.tweak(status_path
, status
=' ')
594 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
595 text_time
= get_text_timestamp(wc_path
)
596 if text_time
!= pre_text_time
:
597 raise svntest
.Failure
599 # revert/cleanup change the text-time even though the text doesn't change
601 svntest
.actions
.run_and_verify_svn(None, None, [], cmd
, wc_dir
)
603 svntest
.actions
.run_and_verify_svn(None, None, [], cmd
, wc_path
)
604 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
605 text_time
= get_text_timestamp(wc_path
)
606 if text_time
== pre_text_time
:
607 raise svntest
.Failure
610 # Is this really a status test? I'm not sure, but I don't know where
612 def timestamp_behaviour(sbox
):
613 "timestamp behaviour"
618 A_path
= os
.path
.join(wc_dir
, 'A')
619 iota_path
= os
.path
.join(wc_dir
, 'iota')
621 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
622 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
624 # Sleep to ensure timestamps change
627 # Check behaviour of revert on text-time
628 text_time_behaviour(wc_dir
, iota_path
, 'iota', expected_status
, 'revert')
630 # Sleep to ensure timestamps change
633 # Check behaviour of cleanup on text-time
634 text_time_behaviour(wc_dir
, iota_path
, 'iota', expected_status
, 'cleanup')
636 # Create a config to enable use-commit-times
637 config_dir
= os
.path
.join(os
.path
.abspath(svntest
.main
.temp_dir
),
639 config_contents
= '''\
641 use-commit-times = yes
643 svntest
.main
.create_config_dir(config_dir
, config_contents
)
645 other_wc
= sbox
.add_wc_path('other')
646 svntest
.actions
.run_and_verify_svn("checkout failed", None, [],
649 '--config-dir', config_dir
)
651 other_iota_path
= os
.path
.join(other_wc
, 'iota')
652 iota_text_timestamp
= get_text_timestamp(other_iota_path
)
653 iota_last_changed
= get_last_changed_date(other_iota_path
)
654 if (iota_text_timestamp
[17] != ':' or
655 iota_text_timestamp
[17:] != iota_last_changed
[17:]):
656 raise svntest
.Failure
658 ### FIXME: check the working file's timestamp as well
660 #----------------------------------------------------------------------
662 def status_on_unversioned_dotdot(sbox
):
663 "status on '..' where '..' is not versioned"
664 # See issue #1617 (and #2030).
665 sbox
.build(read_only
= True)
668 new_dir
= os
.path
.join(wc_dir
, 'new_dir')
669 new_subdir
= os
.path
.join(new_dir
, 'new_subdir')
675 out
, err
= svntest
.main
.run_svn(1, 'st', '..')
677 if line
.find('svn: warning: \'..\' is not a working copy') != -1:
680 raise svntest
.Failure
682 #----------------------------------------------------------------------
684 def status_on_partially_nonrecursive_wc(sbox
):
685 "status -u in partially non-recursive wc"
686 # Based on issue #2122.
688 # $ svn co -N -r 213 svn://svn.debian.org/pkg-kde .
690 # Checked out revision 213.
692 # $ svn up -r 213 scripts www
693 # [ List of scripts/* files.]
694 # Updated to revision 213.
695 # [ List of www/* files.]
696 # Updated to revision 213.
699 # * 213 www/IGNORE-ME
701 # svn: subversion/libsvn_wc/status.c:910: tweak_statushash: \
702 # Assertion `repos_text_status == svn_wc_status_added' failed. \
703 # Aborted (core dumped)
705 # You might think that the intermediate "svn up -r 213 scripts www"
706 # step is unnecessary, but when I tried eliminating it, I got
709 # subversion/libsvn_wc/lock.c:642: (apr_err=155005)
710 # svn: Working copy 'www' not locked
713 # instead of the assertion error.
718 top_url
= sbox
.repo_url
719 A_url
= top_url
+ '/A'
720 D_url
= top_url
+ '/A/D'
721 G_url
= top_url
+ '/A/D/G'
722 H_url
= top_url
+ '/A/D/H'
723 rho
= os
.path
.join(wc_dir
, 'A', 'D', 'G', 'rho')
725 # Commit a change to A/D/G/rho. This will be our equivalent of
726 # whatever change it was that happened between r213 and HEAD in the
727 # reproduction recipe. For us, it's r2.
728 svntest
.main
.file_append(rho
, 'Whan that Aprille with his shoores soote\n')
729 svntest
.main
.run_svn(None,
730 'ci', '-m', 'log msg', rho
)
732 # Make the working copy weird in the right way, then try status -u.
733 D_wc
= sbox
.add_wc_path('D')
734 svntest
.main
.run_svn(None,
735 'co', '-r1', '-N', D_url
, D_wc
)
738 svntest
.main
.run_svn(None,
740 svntest
.main
.run_svn(None,
744 def missing_dir_in_anchor(sbox
):
745 "a missing dir in the anchor"
747 sbox
.build(read_only
= True)
750 foo_path
= os
.path
.join(wc_dir
, 'foo')
751 svntest
.actions
.run_and_verify_svn(None, None, [], 'mkdir', foo_path
)
752 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
753 expected_status
.add({
754 'foo' : Item(status
='A ', wc_rev
=0),
756 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
758 # At one point this caused a "foo not locked" error
759 svntest
.main
.safe_rmtree(foo_path
)
760 expected_status
.tweak('foo', status
='! ', wc_rev
='?')
761 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
764 def status_in_xml(sbox
):
765 "status output in XML format"
767 sbox
.build(read_only
= True)
771 file_path
= os
.path
.join(wc_dir
, file_name
)
772 svntest
.main
.file_append(file_path
, "test status --xml\n")
774 # Retrieve last changed date from svn log
775 output
, error
= svntest
.actions
.run_and_verify_svn(None, None, [],
780 if line
.find(info_msg
) >= 0:
781 time_str
= line
[:len(line
)]
784 raise svntest
.Failure
786 template
= ["<?xml version=\"1.0\"?>\n",
789 " path=\"%s\">\n" % (file_path
),
791 " path=\"%s\">\n" % (file_path
),
794 " item=\"modified\"\n",
795 " revision=\"1\">\n",
797 " revision=\"1\">\n",
798 "<author>%s</author>\n" % svntest
.main
.wc_author
,
804 " revision=\"1\"/>\n",
809 output
, error
= svntest
.actions
.run_and_verify_svn(None, None, [],
813 for i
in range(0, len(output
)):
814 if output
[i
] != template
[i
]:
815 print "ERROR: expected:", template
[i
], "actual:", output
[i
]
816 raise svntest
.Failure
818 #----------------------------------------------------------------------
820 def status_ignored_dir(sbox
):
821 "status on ignored directory"
824 new_dir
= os
.path
.join(wc_dir
, "dir.o")
825 new_dir_url
= sbox
.repo_url
+ "/dir.o"
827 svntest
.actions
.run_and_verify_svn("Create dir", "\n|Committed revision 2.", [],
828 'mkdir', new_dir_url
, '-m', 'msg')
830 # Make a dir that is ignored by the default ignore patterns.
833 # run_and_verify_status doesn't handle this weird kind of entry.
834 svntest
.actions
.run_and_verify_svn(None,
835 ['I * ' + new_dir
+ "\n",
836 ' * 1 ' + wc_dir
+ "\n",
837 'Status against revision: 2\n'], [],
838 "status", "-u", wc_dir
)
840 #----------------------------------------------------------------------
842 def status_unversioned_dir(sbox
):
843 "status on unversioned dir (issue 2030)"
844 sbox
.build(read_only
= True)
846 expected_err
= ["svn: warning: '" + dir + "' is not a working copy\n",
847 "svn: warning: '" + dir + "' is not a working copy\n"]
848 svntest
.actions
.run_and_verify_svn(None, [], expected_err
, "status", dir, dir)
850 #----------------------------------------------------------------------
852 def status_missing_dir(sbox
):
853 "status with a versioned directory missing"
854 sbox
.build(read_only
= True)
856 a_d_g
= os
.path
.join(wc_dir
, "A", "D", "G")
858 # ok, blow away the A/D/G directory
859 svntest
.main
.safe_rmtree(a_d_g
)
861 expected
= svntest
.verify
.UnorderedOutput(["! " + a_d_g
+ "\n"])
862 svntest
.actions
.run_and_verify_svn(None, expected
, [], "status", wc_dir
)
864 expected
= svntest
.verify
.UnorderedOutput(
865 [" * " + os
.path
.join(a_d_g
, "pi") + "\n",
866 " * " + os
.path
.join(a_d_g
, "rho") + "\n",
867 " * " + os
.path
.join(a_d_g
, "tau") + "\n",
868 "! * ? " + a_d_g
+ "\n",
869 " * 1 " + os
.path
.join(wc_dir
, "A", "D") + "\n",
870 "Status against revision: 1\n" ])
872 # now run status -u, we should be able to do this without crashing
873 svntest
.actions
.run_and_verify_svn(None, expected
, [],
874 "status", "-u", wc_dir
)
876 def status_add_plus_conflict(sbox
):
877 "status on conflicted added file"
879 svntest
.actions
.do_sleep_for_timestamps()
883 branch_url
= sbox
.repo_url
+ '/branch'
884 trunk_url
= sbox
.repo_url
+ '/trunk'
886 svntest
.actions
.run_and_verify_svn(None, None, [],
887 'mkdir', '-m', 'rev 2',
888 branch_url
, trunk_url
)
890 svntest
.actions
.run_and_verify_svn(None, None, [],
893 branch_file
= os
.path
.join(wc_dir
, 'branch', 'file')
895 svntest
.main
.file_write(branch_file
, "line 1\nline2\nline3\n", 'wb+')
897 svntest
.actions
.run_and_verify_svn(None, None, [], 'add', branch_file
)
899 svntest
.actions
.run_and_verify_svn(None, None, [],
901 branch_file
, '-m', 'rev 3')
903 svntest
.main
.file_write(branch_file
, "line 1\nline3\n", 'wb')
905 svntest
.actions
.run_and_verify_svn(None, None, [],
907 branch_file
, '-m', 'rev 4')
909 svntest
.main
.file_write(branch_file
, "line 1\nline2\n", 'wb')
911 svntest
.actions
.run_and_verify_svn(None, None, [],
913 branch_file
, '-m', 'rev 5')
915 trunk_dir
= os
.path
.join(wc_dir
, 'trunk')
917 svntest
.actions
.run_and_verify_svn(None, None, [],
919 branch_url
, '-r', '2:3', trunk_dir
)
921 svntest
.actions
.run_and_verify_svn(None, None, [],
923 branch_url
, '-r', '4:5', trunk_dir
)
925 expected_output
= svntest
.verify
.UnorderedOutput([
926 "? " + os
.path
.join(wc_dir
, "trunk", "file.merge-left.r4") + "\n",
927 "? " + os
.path
.join(wc_dir
, "trunk", "file.merge-right.r5") + "\n",
928 "? " + os
.path
.join(wc_dir
, "trunk", "file.working") + "\n",
929 " M " + os
.path
.join(wc_dir
, "trunk") + "\n",
930 "C + " + os
.path
.join(wc_dir
, "trunk", "file") + "\n",
933 svntest
.actions
.run_and_verify_svn(None, expected_output
, [],
936 #----------------------------------------------------------------------
938 def inconsistent_eol(sbox
):
939 "status with inconsistent eol style"
943 iota_path
= os
.path
.join(wc_dir
, "iota")
945 svntest
.main
.file_write(iota_path
, "line 1\nline 2\n", "wb")
947 svntest
.actions
.run_and_verify_svn(None,
948 "property 'svn:eol-style' set on.*iota",
950 'propset', 'svn:eol-style', 'native',
951 os
.path
.join(wc_dir
, 'iota'))
953 expected_output
= svntest
.wc
.State(wc_dir
, {
954 'iota' : Item(verb
='Sending'),
957 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
958 expected_status
.tweak('iota', wc_rev
=2)
960 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
961 expected_status
, None, wc_dir
)
963 # Make the eol style inconsistent and verify that status says nothing.
964 svntest
.main
.file_write(iota_path
, "line 1\nline 2\r\n", "wb")
965 svntest
.actions
.run_and_verify_status(wc_dir
, expected_status
)
967 #----------------------------------------------------------------------
968 # Test for issue #2533
969 def status_update_with_incoming_props(sbox
):
970 "run 'status -u' variations w/ incoming propchanges"
974 A_path
= os
.path
.join(wc_dir
, 'A')
976 # Add a property to the root folder and a subdir
977 svntest
.main
.run_svn(None, 'propset', 'red', 'rojo', wc_dir
)
978 svntest
.main
.run_svn(None, 'propset', 'black', 'bobo', A_path
)
980 # Create expected output tree.
981 expected_output
= svntest
.wc
.State(wc_dir
, {
982 '' : Item(verb
='Sending'),
983 'A' : Item(verb
='Sending'),
986 # Created expected status tree.
987 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
988 expected_status
.tweak('', wc_rev
=2, status
=' ')
989 expected_status
.tweak('A', wc_rev
=2, status
=' ')
991 # Commit the working copy
992 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
996 # Create expected trees for an update to revision 1.
997 expected_output
= svntest
.wc
.State(wc_dir
, {
998 '' : Item(status
=' U'),
999 'A' : Item(status
=' U'),
1001 expected_disk
= svntest
.main
.greek_state
.copy()
1002 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1004 # Do the update and check the results in three ways... INCLUDING PROPS
1005 svntest
.actions
.run_and_verify_update(wc_dir
,
1009 None, None, None, None, None, 1,
1012 # Can't use run_and_verify_status here because the out-of-date
1013 # information in the status output isn't copied in the status tree.
1014 expected
= svntest
.verify
.UnorderedOutput(
1015 [" * 1 " + A_path
+ "\n",
1016 " * 1 " + wc_dir
+ "\n",
1017 "Status against revision: 2\n" ])
1019 svntest
.actions
.run_and_verify_svn(None,
1025 expected
= svntest
.verify
.UnorderedOutput(
1027 os
.path
.join(wc_dir
, "iota") + "\n",
1028 " * 1 1 jrandom " + A_path
+ "\n",
1029 " * 1 1 jrandom " + wc_dir
+ "\n",
1030 "Status against revision: 2\n" ])
1032 svntest
.actions
.run_and_verify_svn(None, expected
, [],
1036 # Retrieve last changed date from svn log
1037 output
, error
= svntest
.actions
.run_and_verify_svn(None, None, [],
1043 if line
.find(info_msg
) >= 0:
1044 time_str
= line
[:len(line
)]
1047 raise svntest
.Failure
1049 xout
= ["<?xml version=\"1.0\"?>\n",
1052 " path=\"%s\">\n" % (wc_dir
),
1054 " path=\"%s\">\n" % (A_path
),
1056 " props=\"none\"\n",
1057 " item=\"normal\"\n",
1058 " revision=\"1\">\n",
1060 " revision=\"1\">\n",
1061 "<author>%s</author>\n" % svntest
.main
.wc_author
,
1066 " props=\"modified\"\n",
1067 " item=\"none\">\n",
1068 "</repos-status>\n",
1071 " path=\"%s\">\n" % (wc_dir
),
1073 " props=\"none\"\n",
1074 " item=\"normal\"\n",
1075 " revision=\"1\">\n",
1077 " revision=\"1\">\n",
1078 "<author>%s</author>\n" % svntest
.main
.wc_author
,
1083 " props=\"modified\"\n",
1084 " item=\"none\">\n",
1085 "</repos-status>\n",
1088 " revision=\"2\"/>\n",
1092 output
, error
= svntest
.actions
.run_and_verify_svn(None, xout
, [],
1096 # more incoming prop updates.
1097 def status_update_verbose_with_incoming_props(sbox
):
1098 "run 'status -uv' w/ incoming propchanges"
1101 wc_dir
= sbox
.wc_dir
1102 A_path
= os
.path
.join(wc_dir
, 'A')
1103 D_path
= os
.path
.join(A_path
, 'D')
1104 B_path
= os
.path
.join(A_path
, 'B')
1105 E_path
= os
.path
.join(A_path
, 'B', 'E')
1106 G_path
= os
.path
.join(A_path
, 'D', 'G')
1107 H_path
= os
.path
.join(A_path
, 'D', 'H')
1108 # Add a property to the root folder and a subdir
1109 svntest
.main
.run_svn(None, 'propset', 'red', 'rojo', D_path
)
1110 svntest
.main
.run_svn(None, 'propset', 'black', 'bobo', E_path
)
1111 svntest
.main
.run_svn(None, 'propset', 'black', 'bobo', wc_dir
)
1113 # Create expected output tree.
1114 expected_output
= svntest
.wc
.State(wc_dir
, {
1115 'A/D' : Item(verb
='Sending'),
1116 'A/B/E' : Item(verb
='Sending'),
1117 '' : Item(verb
='Sending'),
1119 # Created expected status tree.
1120 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1121 expected_status
.tweak('A/D', wc_rev
=2, status
=' ')
1122 expected_status
.tweak('A/B/E', wc_rev
=2, status
=' ')
1123 expected_status
.tweak('', wc_rev
=2, status
=' ')
1125 # Commit the working copy
1126 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
1130 # Create expected trees for an update to revision 1.
1131 expected_output
= svntest
.wc
.State(wc_dir
, {
1132 'A/D' : Item(status
=' U'),
1133 'A/B/E' : Item(status
=' U'),
1134 '' : Item(status
=' U'),
1136 expected_disk
= svntest
.main
.greek_state
.copy()
1137 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1139 # Do the update and check the results in three ways... INCLUDING PROPS
1140 svntest
.actions
.run_and_verify_update(wc_dir
,
1144 None, None, None, None, None, 1,
1147 # Can't use run_and_verify_status here because the out-of-date
1148 # information in the status output isn't copied in the status tree.
1149 common
= " 1 1 jrandom "
1150 expected
= svntest
.verify
.UnorderedOutput(
1151 [" " + common
+ os
.path
.join(E_path
, 'alpha') + "\n",
1152 " " + common
+ os
.path
.join(E_path
, 'beta') + "\n",
1153 " *" + common
+ os
.path
.join(E_path
) + "\n",
1154 " " + common
+ os
.path
.join(B_path
, 'lambda') + "\n",
1155 " " + common
+ os
.path
.join(B_path
, 'F') + "\n",
1156 " " + common
+ B_path
+ "\n",
1157 " " + common
+ os
.path
.join(G_path
, 'pi') + "\n",
1158 " " + common
+ os
.path
.join(G_path
, 'rho') + "\n",
1159 " " + common
+ os
.path
.join(G_path
, 'tau') + "\n",
1160 " " + common
+ G_path
+ "\n",
1161 " " + common
+ os
.path
.join(H_path
, 'chi') + "\n",
1162 " " + common
+ os
.path
.join(H_path
, 'omega') + "\n",
1163 " " + common
+ os
.path
.join(H_path
, 'psi') + "\n",
1164 " " + common
+ H_path
+ "\n",
1165 " " + common
+ os
.path
.join(D_path
, 'gamma') + "\n",
1166 " *" + common
+ D_path
+ "\n",
1167 " " + common
+ os
.path
.join(A_path
, 'mu') + "\n",
1168 " " + common
+ os
.path
.join(A_path
, 'C') + "\n",
1169 " " + common
+ A_path
+ "\n",
1170 " " + common
+ os
.path
.join(wc_dir
, 'iota') + "\n",
1171 " *" + common
+ wc_dir
+ "\n",
1172 "Status against revision: 2\n" ])
1174 svntest
.actions
.run_and_verify_svn(None,
1177 "status", "-uv", wc_dir
)
1179 #----------------------------------------------------------------------
1180 # Test for issue #2468
1181 def status_nonrecursive_update(sbox
):
1182 "run 'status -uN' with incoming changes"
1185 wc_dir
= sbox
.wc_dir
1186 A_path
= os
.path
.join(wc_dir
, 'A')
1187 D_path
= os
.path
.join(A_path
, 'D')
1188 mu_path
= os
.path
.join(A_path
, 'mu')
1189 gamma_path
= os
.path
.join(D_path
, 'gamma')
1191 # Change files in A and D and commit
1192 svntest
.main
.file_append(mu_path
, "new line of text")
1193 svntest
.main
.file_append(gamma_path
, "new line of text")
1195 # Create expected trees for commit
1196 expected_output
= svntest
.wc
.State(wc_dir
, {
1197 'A/mu' : Item(verb
='Sending'),
1198 'A/D/gamma' : Item(verb
='Sending')
1200 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1201 expected_status
.tweak('A/mu', wc_rev
=2, status
=' ')
1202 expected_status
.tweak('A/D/gamma', wc_rev
=2, status
=' ')
1204 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
1208 # Create expected trees for an update to revision 1.
1209 expected_output
= svntest
.wc
.State(wc_dir
, {
1210 'A/mu' : Item(status
='U '),
1211 'A/D/gamma' : Item(status
='U '),
1213 expected_disk
= svntest
.main
.greek_state
.copy()
1214 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1216 # Do the update and check the results in three ways
1217 svntest
.actions
.run_and_verify_update(wc_dir
,
1221 None, None, None, None, None, 0,
1224 # Check the remote status of folder A (non-recursively)
1225 xout
= [" * 1 " + os
.path
.join(wc_dir
, "A", "mu") + "\n",
1226 "Status against revision: 2\n" ]
1228 svntest
.actions
.run_and_verify_svn(None,
1231 "status", "-uN", A_path
)
1233 def change_files(wc_dir
, files
):
1234 """Make a basic change to the files.
1235 files = a list of paths relative to the wc root directory
1239 filepath
= os
.path
.join(wc_dir
, file)
1240 svntest
.main
.file_append(filepath
, "new line of text")
1242 def change_files_and_commit(wc_dir
, files
, baserev
=1):
1243 """Make a basic change to the files and commit them.
1244 files = a list of paths relative to the wc root directory
1247 change_files(wc_dir
, files
)
1249 # Prepare expected trees for commit
1250 expected_output
= svntest
.wc
.State(wc_dir
, {
1251 'A/mu' : Item(verb
='Sending'),
1252 'A/D/gamma' : Item(verb
='Sending')
1254 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
1256 commitrev
= baserev
+ 1
1258 expected_output
.add({file : Item(verb
='Sending')})
1259 expected_status
.tweak(file, wc_rev
=commitrev
, status
=' ')
1261 svntest
.actions
.run_and_verify_commit(wc_dir
, expected_output
,
1265 def status_depth_local(sbox
):
1266 "run 'status --depth=X' with local changes"
1268 sbox
.build(read_only
= True)
1269 wc_dir
= sbox
.wc_dir
1270 A_path
= os
.path
.join(wc_dir
, 'A')
1271 D_path
= os
.path
.join(A_path
, 'D')
1273 mu_path
= os
.path
.join(A_path
, 'mu')
1274 gamma_path
= os
.path
.join(D_path
, 'gamma')
1276 # make some changes to the greek tree
1277 change_files(wc_dir
, ['A/mu', 'A/D/gamma'])
1278 svntest
.main
.run_svn(None, 'propset', 'svn:test', 'value', A_path
)
1279 svntest
.main
.run_svn(None, 'propset', 'svn:test', 'value', D_path
)
1281 # for all the possible types of depth, check the status
1284 expected
= svntest
.verify
.UnorderedOutput(
1285 [" M %s\n" % A_path
])
1286 svntest
.actions
.run_and_verify_svn(None,
1289 "status", "--depth=empty", A_path
)
1292 expected
= svntest
.verify
.UnorderedOutput(
1293 [" M %s\n" % A_path
,
1294 "M %s\n" % mu_path
])
1296 svntest
.actions
.run_and_verify_svn(None,
1299 "status", "--depth=files", A_path
)
1302 expected
= svntest
.verify
.UnorderedOutput(
1303 [" M %s\n" % A_path
,
1305 "M %s\n" % mu_path
])
1307 svntest
.actions
.run_and_verify_svn(None,
1310 "status", "--depth=immediates", A_path
)
1312 # depth=infinity (the default)
1313 expected
= svntest
.verify
.UnorderedOutput(
1314 [" M %s\n" % A_path
,
1317 "M %s\n" % gamma_path
])
1319 svntest
.actions
.run_and_verify_svn(None,
1322 "status", "--depth=infinity", A_path
)
1324 def status_depth_update(sbox
):
1325 "run 'status --depth=X -u' with incoming changes"
1328 wc_dir
= sbox
.wc_dir
1329 A_path
= os
.path
.join(wc_dir
, 'A')
1330 D_path
= os
.path
.join(A_path
, 'D')
1332 mu_path
= os
.path
.join(A_path
, 'mu')
1333 gamma_path
= os
.path
.join(D_path
, 'gamma')
1335 # add some files, change directory properties
1336 change_files_and_commit(wc_dir
, ['A/mu', 'A/D/gamma'])
1337 svntest
.main
.run_svn(None, 'up', wc_dir
)
1338 svntest
.main
.run_svn(None, 'propset', 'svn:test', 'value', A_path
)
1339 svntest
.main
.run_svn(None, 'propset', 'svn:test', 'value', D_path
)
1340 svntest
.main
.run_svn(None, 'ci', '-m', 'log message', wc_dir
)
1343 svntest
.main
.run_svn(None, 'up', '-r', '1', wc_dir
)
1345 # for all the possible types of depth, check the status
1348 expected
= svntest
.verify
.UnorderedOutput(
1349 [" * 1 %s\n" % A_path
,
1350 "Status against revision: 3\n"])
1352 svntest
.actions
.run_and_verify_svn(None,
1355 "status", "-u", "--depth=empty", A_path
)
1358 expected
= svntest
.verify
.UnorderedOutput(
1359 [" * 1 %s\n" % mu_path
,
1360 " * 1 %s\n" % A_path
,
1361 "Status against revision: 3\n"])
1363 svntest
.actions
.run_and_verify_svn(None,
1366 "status", "-u", "--depth=files",
1370 expected
= svntest
.verify
.UnorderedOutput(
1371 [" * 1 %s\n" % A_path
,
1372 " * 1 %s\n" % D_path
,
1373 " * 1 %s\n" % mu_path
,
1374 "Status against revision: 3\n"])
1376 svntest
.actions
.run_and_verify_svn(None,
1379 "status", "-u", "--depth=immediates",
1382 # depth=infinity (the default)
1383 expected
= svntest
.verify
.UnorderedOutput(
1384 [" * 1 %s\n" % A_path
,
1385 " * 1 %s\n" % D_path
,
1386 " * 1 %s\n" % mu_path
,
1387 " * 1 %s\n" % gamma_path
,
1388 "Status against revision: 3\n"])
1390 svntest
.actions
.run_and_verify_svn(None,
1393 "status", "-u", "--depth=infinity",
1397 #----------------------------------------------------------------------
1398 # Test for issue #2420
1399 def status_dash_u_deleted_directories(sbox
):
1400 "run 'status -u' with locally deleted directories"
1403 wc_dir
= sbox
.wc_dir
1404 A_path
= os
.path
.join(wc_dir
, 'A')
1405 B_path
= os
.path
.join(A_path
, 'B')
1407 # delete the B directory
1408 svntest
.actions
.run_and_verify_svn(None, None, [],
1411 # now run status -u on B and its children
1412 was_cwd
= os
.getcwd()
1416 # check status -u of B
1417 expected
= svntest
.verify
.UnorderedOutput(
1419 "D 1 %s\n" % os
.path
.join("B", "lambda"),
1420 "D 1 %s\n" % os
.path
.join("B", "E"),
1421 "D 1 %s\n" % os
.path
.join("B", "E", "alpha"),
1422 "D 1 %s\n" % os
.path
.join("B", "E", "beta"),
1423 "D 1 %s\n" % os
.path
.join("B", "F"),
1424 "Status against revision: 1\n" ])
1425 svntest
.actions
.run_and_verify_svn(None,
1428 "status", "-u", "B")
1430 # again, but now from inside B, should give the same output
1432 expected
= svntest
.verify
.UnorderedOutput(
1434 "D 1 %s\n" % "lambda",
1436 "D 1 %s\n" % os
.path
.join("E", "alpha"),
1437 "D 1 %s\n" % os
.path
.join("E", "beta"),
1439 "Status against revision: 1\n" ])
1440 svntest
.actions
.run_and_verify_svn(None,
1443 "status", "-u", ".")
1445 # check status -u of B/E
1446 expected
= svntest
.verify
.UnorderedOutput(
1447 ["D 1 %s\n" % os
.path
.join("B", "E"),
1448 "D 1 %s\n" % os
.path
.join("B", "E", "alpha"),
1449 "D 1 %s\n" % os
.path
.join("B", "E", "beta"),
1450 "Status against revision: 1\n" ])
1454 svntest
.actions
.run_and_verify_svn(None,
1458 os
.path
.join("B", "E"))
1460 #----------------------------------------------------------------------
1462 # Test for issue #2737: show obstructed status for versioned directories
1463 # replaced by local directories.
1464 def status_dash_u_type_change(sbox
):
1465 "status -u on versioned items whose type changed"
1467 sbox
.build(read_only
= True)
1468 wc_dir
= sbox
.wc_dir
1472 # Change the versioned file iota into an unversioned dir.
1476 xout
= ["~ 1 iota\n",
1477 "Status against revision: 1\n" ]
1479 svntest
.actions
.run_and_verify_svn(None,
1484 # Change the versioned directory A into an unversioned dir.
1485 svntest
.main
.safe_rmtree('A')
1488 expected
= svntest
.verify
.UnorderedOutput(
1491 "Status against revision: 1\n" ])
1493 svntest
.actions
.run_and_verify_svn(None,
1498 ########################################################################
1502 # list all tests here, starting with None:
1504 status_unversioned_file_in_current_dir
,
1505 status_update_with_nested_adds
,
1506 status_shows_all_in_current_dir
,
1507 status_missing_file
,
1509 SkipUnless(status_type_change_to_symlink
,
1510 svntest
.main
.is_posix_os
),
1511 status_with_new_files_pending
,
1512 status_for_unignored_file
,
1513 status_for_nonexistent_file
,
1514 status_file_needs_update
,
1515 status_uninvited_parent_directory
,
1516 status_on_forward_deletion
,
1517 timestamp_behaviour
,
1518 status_on_unversioned_dotdot
,
1519 status_on_partially_nonrecursive_wc
,
1520 missing_dir_in_anchor
,
1523 status_unversioned_dir
,
1525 status_nonrecursive_update_different_cwd
,
1526 status_add_plus_conflict
,
1528 status_update_with_incoming_props
,
1529 status_update_verbose_with_incoming_props
,
1530 status_nonrecursive_update
,
1531 status_dash_u_deleted_directories
,
1533 status_depth_update
,
1534 status_dash_u_type_change
,
1537 if __name__
== '__main__':
1538 svntest
.main
.run_tests(test_list
)