In the command-line client, forbid
[svn.git] / subversion / tests / cmdline / mergeinfo_tests.py
blob85be008acbeafce4de3195839e7a85f6063254cc
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_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():
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 + "/",
66 wc_dir)
67 svntest.actions.run_and_verify_mergeinfo(adjust_error_for_server_version(""),
68 {wc_dir : {"/" : ("r0:1", None)}},
69 wc_dir)
71 def explicit_mergeinfo_source(sbox):
72 "'mergeinfo' with source selection"
74 sbox.build()
75 wc_dir = sbox.wc_dir
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,
86 propval_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",
93 "r1:2")}},
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",
97 "r1:2")}},
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,
103 "r1:2")}},
104 H_path, '--from-source', H2_url)
107 ########################################################################
108 # Run the tests
111 # list all tests here, starting with None:
112 test_list = [ None,
113 no_mergeinfo,
114 mergeinfo,
115 explicit_mergeinfo_source,
118 if __name__ == '__main__':
119 svntest.main.run_tests(test_list)
120 # NOTREACHED