1 //
2 // ====================================================================
3 // Copyright (c) 2003-2009 Barry A Scott. All rights reserved.
4 //
5 // This software is licensed as described in the file LICENSE.txt,
6 // which you should have received as part of this distribution.
7 //
8 // ====================================================================
9 //
10 //
11 // pysvn_client_cmd_prop.cpp
12 //
13 #if defined( _MSC_VER )
14 // disable warning C4786: symbol greater than 255 character,
15 // nessesary to ignore as <map> causes lots of warning
16 #pragma warning(disable: 4786)
17 #endif
18
19 #include "pysvn.hpp"
20 #include "pysvn_static_strings.hpp"
21
cmd_relocate(const Py::Tuple & a_args,const Py::Dict & a_kws)22 Py::Object pysvn_client::cmd_relocate( const Py::Tuple &a_args, const Py::Dict &a_kws )
23 {
24 static argument_description args_desc[] =
25 {
26 { true, name_from_url },
27 { true, name_to_url },
28 { true, name_path },
29 { false, name_recurse },
30 #if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
31 { false, name_ignore_externals },
32 #endif
33 { false, NULL }
34 };
35 FunctionArguments args( "relocate", args_desc, a_args, a_kws );
36 args.check();
37
38 std::string from_url( args.getUtf8String( name_from_url ) );
39 std::string to_url( args.getUtf8String( name_to_url ) );
40 std::string path( args.getUtf8String( name_path ) );
41
42 #if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
43 bool ignore_externals = args.getBoolean( name_ignore_externals, true );
44 #else
45 bool recurse = args.getBoolean( name_recurse, true );
46 #endif
47
48 SvnPool pool( m_context );
49
50 try
51 {
52 std::string norm_path( svnNormalisedIfPath( path, pool ) );
53 std::string norm_to_url( svnNormalisedIfPath( to_url, pool ) );
54 std::string norm_from_url( svnNormalisedIfPath( from_url, pool ) );
55
56 checkThreadPermission();
57
58 PythonAllowThreads permission( m_context );
59
60 #if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
61 svn_error_t *error = svn_client_relocate2
62 (
63 norm_path.c_str(),
64 norm_from_url.c_str(),
65 norm_to_url.c_str(),
66 ignore_externals,
67 m_context,
68 pool
69 );
70
71 #else
72 svn_error_t *error = svn_client_relocate
73 (
74 norm_path.c_str(),
75 norm_from_url.c_str(),
76 norm_to_url.c_str(),
77 recurse,
78 m_context,
79 pool
80 );
81 #endif
82 permission.allowThisThread();
83
84 if( error != NULL )
85 throw SvnException( error );
86 }
87 catch( SvnException &e )
88 {
89 // use callback error over ClientException
90 m_context.checkForError( m_module.client_error );
91
92 throw_client_error( e );
93 }
94
95 return Py::None();
96 }
97
cmd_switch(const Py::Tuple & a_args,const Py::Dict & a_kws)98 Py::Object pysvn_client::cmd_switch( const Py::Tuple &a_args, const Py::Dict &a_kws )
99 {
100 static argument_description args_desc[] =
101 {
102 { true, name_path },
103 { true, name_url },
104 { false, name_recurse },
105 { false, name_revision },
106 #if defined( PYSVN_HAS_CLIENT_SWITCH2 )
107 { false, name_depth },
108 { false, name_peg_revision },
109 { false, name_depth_is_sticky },
110 { false, name_ignore_externals },
111 { false, name_allow_unver_obstructions },
112 #endif
113 #if defined( PYSVN_HAS_CLIENT_SWITCH3 )
114 { false, name_ignore_ancestry },
115 #endif
116 { false, NULL }
117 };
118 FunctionArguments args( "switch", args_desc, a_args, a_kws );
119 args.check();
120
121 std::string path( args.getUtf8String( name_path ) );
122 std::string url( args.getUtf8String( name_url ) );
123 svn_opt_revision_t revision = args.getRevision( name_revision, svn_opt_revision_head );
124 #if defined( PYSVN_HAS_CLIENT_SWITCH2 )
125 svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_infinity, svn_depth_infinity, svn_depth_files );
126 svn_opt_revision_t peg_revision = args.getRevision( name_peg_revision, revision );
127
128 svn_boolean_t depth_is_sticky = args.getBoolean( name_depth_is_sticky, false );
129 svn_boolean_t ignore_externals = args.getBoolean( name_ignore_externals, false );
130 svn_boolean_t allow_unver_obstructions = args.getBoolean( name_allow_unver_obstructions, false );
131 #else
132 bool recurse = args.getBoolean( name_recurse, true );
133 #endif
134
135 #if defined( PYSVN_HAS_CLIENT_SWITCH3 )
136 bool ignore_ancestry = args.getBoolean( name_ignore_ancestry, false );
137 #endif
138
139 SvnPool pool( m_context );
140
141 svn_revnum_t revnum = 0;
142 try
143 {
144 std::string norm_path( svnNormalisedIfPath( path, pool ) );
145 std::string norm_url( svnNormalisedIfPath( url, pool ) );
146
147 checkThreadPermission();
148
149 PythonAllowThreads permission( m_context );
150
151 #if defined( PYSVN_HAS_CLIENT_SWITCH3 )
152 svn_error_t *error = svn_client_switch3
153 (
154 &revnum,
155 norm_path.c_str(),
156 norm_url.c_str(),
157 &peg_revision,
158 &revision,
159 depth,
160 depth_is_sticky,
161 ignore_externals,
162 allow_unver_obstructions,
163 ignore_ancestry,
164 m_context,
165 pool
166 );
167
168 #elif defined( PYSVN_HAS_CLIENT_SWITCH2 )
169 svn_error_t *error = svn_client_switch2
170 (
171 &revnum,
172 norm_path.c_str(),
173 norm_url.c_str(),
174 &peg_revision,
175 &revision,
176 depth,
177 depth_is_sticky,
178 ignore_externals,
179 allow_unver_obstructions,
180 m_context,
181 pool
182 );
183 #else
184 svn_error_t *error = svn_client_switch
185 (
186 &revnum,
187 norm_path.c_str(),
188 norm_url.c_str(),
189 &revision,
190 recurse,
191 m_context,
192 pool
193 );
194 #endif
195 permission.allowThisThread();
196 if( error != NULL )
197 throw SvnException( error );
198 }
199 catch( SvnException &e )
200 {
201 // use callback error over ClientException
202 m_context.checkForError( m_module.client_error );
203
204 throw_client_error( e );
205 }
206
207 return Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, revnum ) );
208 }
209