3 # mergeinfo_tests.py: testing Merge Tracking reporting
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 ######################################################################
20 import shutil
, sys
, re
, os
24 from svntest
import wc
28 XFail
= svntest
.testcase
.XFail
29 Skip
= svntest
.testcase
.Skip
30 SkipUnless
= svntest
.testcase
.SkipUnless
32 from svntest
.main
import SVN_PROP_MERGE_INFO
33 from svntest
.main
import server_has_mergeinfo
35 def adjust_error_for_server_version(expected_err
):
36 "Return the expected error regexp appropriate for the server version."
37 if server_has_mergeinfo():
40 return "Retrieval of mergeinfo unsupported by '.+'"
42 ######################################################################
45 # Each test must return on success or raise on failure.
48 #----------------------------------------------------------------------
50 def no_mergeinfo(sbox
):
51 "'mergeinfo' on a URL that lacks mergeinfo"
53 sbox
.build(create_wc
=False)
54 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
55 {sbox
.repo_url
: {}}, sbox
.repo_url
)
58 "'mergeinfo' on a path with mergeinfo"
63 # Dummy up some mergeinfo.
64 svntest
.actions
.run_and_verify_svn(None, None, [], "merge", "-c", "1",
65 "--record-only", sbox
.repo_url
+ "/",
67 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
68 {wc_dir
: {"/" : ("r0:1", None)}},
71 def explicit_mergeinfo_source(sbox
):
72 "'mergeinfo' with source selection"
76 H_path
= os
.path
.join(wc_dir
, 'A', 'D', 'H')
77 H2_path
= os
.path
.join(wc_dir
, 'A', 'D', 'H2')
78 B_url
= sbox
.repo_url
+ '/A/B'
79 G_url
= sbox
.repo_url
+ '/A/D/G'
80 H2_url
= sbox
.repo_url
+ '/A/D/H2'
82 # Make a copy, and dummy up some mergeinfo.
83 mergeinfo
= '/A/B:1\n/A/D/G:1\n'
84 propval_path
= os
.path
.join(wc_dir
, 'propval.tmp')
85 svntest
.actions
.set_prop(None, SVN_PROP_MERGE_INFO
, mergeinfo
, H_path
,
87 svntest
.main
.run_svn(None, "cp", H_path
, H2_path
)
88 svntest
.main
.run_svn(None, "ci", "-m", "r2", wc_dir
)
90 # Check using --from-source on each of our recorded merge sources.
91 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
92 {H_path
: {'/A/B' : ("r0:1",
94 H_path
, '--from-source', B_url
)
95 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
96 {H_path
: {'/A/D/G' : ("r0:1",
98 H_path
, '--from-source', G_url
)
100 # Now check on a source we haven't "merged" from.
101 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
102 {H_path
: {'/A/D/H2' : (None,
104 H_path
, '--from-source', H2_url
)
107 ########################################################################
111 # list all tests here, starting with None:
115 explicit_mergeinfo_source
,
118 if __name__
== '__main__':
119 svntest
.main
.run_tests(test_list
)