3 # svndumpfilter_tests.py: testing the 'svndumpfilter' tool.
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 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 ######################################################################
25 from svntest
.verify
import SVNExpectedStdout
, SVNExpectedStderr
27 # Get some helper routines from svnadmin_tests
28 from svnadmin_tests
import load_and_verify_dumpstream
, test_create
31 Skip
= svntest
.testcase
.Skip
32 SkipUnless
= svntest
.testcase
.SkipUnless
33 XFail
= svntest
.testcase
.XFail
34 Item
= svntest
.wc
.StateItem
37 ######################################################################
41 def filter_and_return_output(dump
, *varargs
):
42 """Filter the array of lines passed in 'dump' and return the output"""
44 if type(dump
) is type(""):
47 ## TODO: Should we need to handle errput and exit_code?
48 exit_code
, output
, errput
= svntest
.main
.run_command_stdin(
49 svntest
.main
.svndumpfilter_binary
, None, 1, dump
, *varargs
)
54 ######################################################################
58 def reflect_dropped_renumbered_revs(sbox
):
59 "reflect dropped renumbered revs in svn:mergeinfo"
61 ## See http://subversion.tigris.org/issues/show_bug.cgi?id=2982. ##
63 # Test svndumpfilter with include option
65 dumpfile_location
= os
.path
.join(os
.path
.dirname(sys
.argv
[0]),
66 'svndumpfilter_tests_data',
68 dumpfile
= svntest
.main
.file_read(dumpfile_location
)
70 filtered_out
= filter_and_return_output(dumpfile
, "include",
72 "--skip-missing-merge-sources",
74 "--renumber-revs", "--quiet")
75 load_and_verify_dumpstream(sbox
, [], [], None, filtered_out
)
77 # Verify the svn:mergeinfo properties
78 svntest
.actions
.run_and_verify_svn(None,
79 [sbox
.repo_url
+"/trunk - /branch1:4-5\n"],
80 [], 'propget', 'svn:mergeinfo', '-R',
81 sbox
.repo_url
+ '/trunk')
82 svntest
.actions
.run_and_verify_svn(None,
83 [sbox
.repo_url
+"/branch1 - /trunk:1-2\n"],
84 [], 'propget', 'svn:mergeinfo', '-R',
85 sbox
.repo_url
+ '/branch1')
87 # Test svndumpfilter with exclude option
89 filtered_out
= filter_and_return_output(dumpfile
, "exclude",
91 "--skip-missing-merge-sources",
93 "--renumber-revs", "--quiet")
94 load_and_verify_dumpstream(sbox
, [], [], None, filtered_out
)
96 # Verify the svn:mergeinfo properties
97 svntest
.actions
.run_and_verify_svn(None,
98 [sbox
.repo_url
+"/trunk - \n"],
99 [], 'propget', 'svn:mergeinfo', '-R',
100 sbox
.repo_url
+ '/trunk')
101 svntest
.actions
.run_and_verify_svn(None,
102 [sbox
.repo_url
+"/branch2 - /trunk:1-2\n"],
103 [], 'propget', 'svn:mergeinfo', '-R',
104 sbox
.repo_url
+ '/branch2')
106 def svndumpfilter_loses_mergeinfo(sbox
):
107 "svndumpfilter loses mergeinfo"
108 #svndumpfilter loses mergeinfo if invoked without --renumber-revs
110 ## See http://subversion.tigris.org/issues/show_bug.cgi?id=3181. ##
113 dumpfile_location
= os
.path
.join(os
.path
.dirname(sys
.argv
[0]),
114 'svndumpfilter_tests_data',
116 dumpfile
= svntest
.main
.file_read(dumpfile_location
)
118 filtered_out
= filter_and_return_output(dumpfile
, "include",
119 "trunk", "branch1", "--quiet")
120 load_and_verify_dumpstream(sbox
, [], [], None, filtered_out
)
122 # Verify the svn:mergeinfo properties
123 svntest
.actions
.run_and_verify_svn(None,
124 [sbox
.repo_url
+"/trunk - /branch1:4-8\n"],
125 [], 'propget', 'svn:mergeinfo', '-R',
126 sbox
.repo_url
+ '/trunk')
127 svntest
.actions
.run_and_verify_svn(None,
128 [sbox
.repo_url
+"/branch1 - /trunk:1-2\n"],
129 [], 'propget', 'svn:mergeinfo', '-R',
130 sbox
.repo_url
+ '/branch1')
133 ########################################################################
137 # list all tests here, starting with None:
139 reflect_dropped_renumbered_revs
,
140 svndumpfilter_loses_mergeinfo
,
143 if __name__
== '__main__':
144 svntest
.main
.run_tests(test_list
)