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_MERGEINFO
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
, wc_dir
)
66 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
67 [1], sbox
.repo_url
, wc_dir
)
69 def explicit_mergeinfo_source(sbox
):
70 "'mergeinfo' with source selection"
74 H_path
= os
.path
.join(wc_dir
, 'A', 'D', 'H')
75 H2_path
= os
.path
.join(wc_dir
, 'A', 'D', 'H2')
76 B_url
= sbox
.repo_url
+ '/A/B'
77 G_url
= sbox
.repo_url
+ '/A/D/G'
78 H2_url
= sbox
.repo_url
+ '/A/D/H2'
80 # Make a copy, and dummy up some mergeinfo.
81 mergeinfo
= '/A/B:1\n/A/D/G:1\n'
82 propval_path
= os
.path
.join(wc_dir
, 'propval.tmp')
83 svntest
.actions
.set_prop(None, SVN_PROP_MERGEINFO
, mergeinfo
, H_path
,
85 svntest
.main
.run_svn(None, "cp", H_path
, H2_path
)
86 svntest
.main
.run_svn(None, "ci", "-m", "r2", wc_dir
)
88 # Check using --from-source on each of our recorded merge sources.
89 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
91 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
94 # Now check on a source we haven't "merged" from.
95 svntest
.actions
.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
98 #----------------------------------------------------------------------
100 def mergeinfo_on_unknown_url(sbox
):
101 "mergeinfo of an unknown url should return error"
106 # remove a path from the repo and commit.
107 iota_path
= os
.path
.join(wc_dir
, 'iota')
108 svntest
.actions
.run_and_verify_svn(None, None, [], 'rm', iota_path
)
109 svntest
.actions
.run_and_verify_svn("", None, [],
110 "ci", wc_dir
, "-m", "log message")
112 url
= sbox
.repo_url
+ "/iota"
113 expected_err
= adjust_error_for_server_version(".*File not found.*iota.*|"
114 ".*iota.*path not found.*")
115 svntest
.actions
.run_and_verify_svn("", None, expected_err
,
116 "mergeinfo", "--show-revs", "eligible",
119 ########################################################################
123 # list all tests here, starting with None:
127 XFail(explicit_mergeinfo_source
, server_has_mergeinfo
),
128 mergeinfo_on_unknown_url
,
131 if __name__
== '__main__':
132 svntest
.main
.run_tests(test_list
)