Fix compiler warning due to missing function prototype.
[svn.git] / subversion / tests / cmdline / mergeinfo_tests.py
blob4a2584f5e86195eb639da2fb244ae88103207b9b
1 #!/usr/bin/env python
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 ######################################################################
19 # General modules
20 import shutil, sys, re, os
22 # Our testing module
23 import svntest
24 from svntest import wc
26 # (abbreviation)
27 Item = wc.StateItem
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():
38 return expected_err
39 else:
40 return ".*Retrieval of mergeinfo unsupported by '.+'"
42 ######################################################################
43 # Tests
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)
57 def mergeinfo(sbox):
58 "'mergeinfo' on a path with mergeinfo"
60 sbox.build()
61 wc_dir = sbox.wc_dir
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"
72 sbox.build()
73 wc_dir = sbox.wc_dir
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,
84 propval_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(""),
90 [1], B_url, H_path)
91 svntest.actions.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
92 [1], G_url, H_path)
94 # Now check on a source we haven't "merged" from.
95 svntest.actions.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
96 [2], H2_url, H_path)
98 #----------------------------------------------------------------------
99 # Issue #3138
100 def mergeinfo_on_unknown_url(sbox):
101 "mergeinfo of an unknown url should return error"
103 sbox.build()
104 wc_dir = sbox.wc_dir
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",
117 url, wc_dir)
119 ########################################################################
120 # Run the tests
123 # list all tests here, starting with None:
124 test_list = [ None,
125 no_mergeinfo,
126 mergeinfo,
127 XFail(explicit_mergeinfo_source, server_has_mergeinfo),
128 mergeinfo_on_unknown_url,
131 if __name__ == '__main__':
132 svntest.main.run_tests(test_list)
133 # NOTREACHED