File: pysvn_client_cmd_switch.cpp

package info (click to toggle)
pysvn 1.9.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,212 kB
  • sloc: cpp: 20,327; python: 5,485; sh: 869; javascript: 57; makefile: 56; ansic: 52
file content (208 lines) | stat: -rw-r--r-- 6,048 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//
// ====================================================================
// Copyright (c) 2003-2009 Barry A Scott.  All rights reserved.
//
// This software is licensed as described in the file LICENSE.txt,
// which you should have received as part of this distribution.
//
// ====================================================================
//
//
//  pysvn_client_cmd_prop.cpp
//
#if defined( _MSC_VER )
// disable warning C4786: symbol greater than 255 character,
// nessesary to ignore as <map> causes lots of warning
#pragma warning(disable: 4786)
#endif

#include "pysvn.hpp"
#include "pysvn_static_strings.hpp"

Py::Object pysvn_client::cmd_relocate( const Py::Tuple &a_args, const Py::Dict &a_kws )
{
    static argument_description args_desc[] =
    {
    { true,  name_from_url },
    { true,  name_to_url },
    { true,  name_path },
    { false, name_recurse },
#if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
    { false, name_ignore_externals },
#endif
    { false, NULL }
    };
    FunctionArguments args( "relocate", args_desc, a_args, a_kws );
    args.check();

    std::string from_url( args.getUtf8String( name_from_url ) );
    std::string to_url( args.getUtf8String( name_to_url ) );
    std::string path( args.getUtf8String( name_path ) );

#if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
    bool ignore_externals = args.getBoolean( name_ignore_externals, true );
#else
    bool recurse = args.getBoolean( name_recurse, true );
#endif

    SvnPool pool( m_context );

    try
    {
        std::string norm_path( svnNormalisedIfPath( path, pool ) );
        std::string norm_to_url( svnNormalisedIfPath( to_url, pool ) );
        std::string norm_from_url( svnNormalisedIfPath( from_url, pool ) );

        checkThreadPermission();

        PythonAllowThreads permission( m_context );

#if defined( PYSVN_HAS_CLIENT_RELOCATE2 )
        svn_error_t *error = svn_client_relocate2
            (
            norm_path.c_str(),
            norm_from_url.c_str(),
            norm_to_url.c_str(),
            ignore_externals,
            m_context,
            pool
            );

#else
        svn_error_t *error = svn_client_relocate
            (
            norm_path.c_str(),
            norm_from_url.c_str(),
            norm_to_url.c_str(),
            recurse,
            m_context,
            pool
            );
#endif
        permission.allowThisThread();

        if( error != NULL )
            throw SvnException( error );
    }
    catch( SvnException &e )
    {
        // use callback error over ClientException
        m_context.checkForError( m_module.client_error );

        throw_client_error( e );
    }

    return Py::None();
}

Py::Object pysvn_client::cmd_switch( const Py::Tuple &a_args, const Py::Dict &a_kws )
{
    static argument_description args_desc[] =
    {
    { true,  name_path },
    { true,  name_url },
    { false, name_recurse },
    { false, name_revision },
#if defined( PYSVN_HAS_CLIENT_SWITCH2 )
    { false, name_depth },
    { false, name_peg_revision },
    { false, name_depth_is_sticky },
    { false, name_ignore_externals },
    { false, name_allow_unver_obstructions },
#endif
#if defined( PYSVN_HAS_CLIENT_SWITCH3 )
    { false, name_ignore_ancestry },
#endif
    { false, NULL }
    };
    FunctionArguments args( "switch", args_desc, a_args, a_kws );
    args.check();

    std::string path( args.getUtf8String( name_path ) );
    std::string url( args.getUtf8String( name_url ) );
    svn_opt_revision_t revision = args.getRevision( name_revision, svn_opt_revision_head );
#if defined( PYSVN_HAS_CLIENT_SWITCH2 )
    svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_infinity, svn_depth_infinity, svn_depth_files );
    svn_opt_revision_t peg_revision = args.getRevision( name_peg_revision, revision );

    svn_boolean_t depth_is_sticky = args.getBoolean( name_depth_is_sticky, false );
    svn_boolean_t ignore_externals = args.getBoolean( name_ignore_externals, false );
    svn_boolean_t allow_unver_obstructions = args.getBoolean( name_allow_unver_obstructions, false );
#else
    bool recurse = args.getBoolean( name_recurse, true );
#endif

#if defined( PYSVN_HAS_CLIENT_SWITCH3 )
    bool ignore_ancestry = args.getBoolean( name_ignore_ancestry, false );
#endif

    SvnPool pool( m_context );

    svn_revnum_t revnum = 0;
    try
    {
        std::string norm_path( svnNormalisedIfPath( path, pool ) );
        std::string norm_url( svnNormalisedIfPath( url, pool ) );

        checkThreadPermission();

        PythonAllowThreads permission( m_context );

#if defined( PYSVN_HAS_CLIENT_SWITCH3 )
        svn_error_t *error = svn_client_switch3
            (
            &revnum,
            norm_path.c_str(),
            norm_url.c_str(),
            &peg_revision,
            &revision,
            depth,
            depth_is_sticky,
            ignore_externals,
            allow_unver_obstructions,
            ignore_ancestry,
            m_context,
            pool
            );

#elif defined( PYSVN_HAS_CLIENT_SWITCH2 )
        svn_error_t *error = svn_client_switch2
            (
            &revnum,
            norm_path.c_str(),
            norm_url.c_str(),
            &peg_revision,
            &revision,
            depth,
            depth_is_sticky,
            ignore_externals,
            allow_unver_obstructions,
            m_context,
            pool
            );
#else
        svn_error_t *error = svn_client_switch
            (
            &revnum,
            norm_path.c_str(),
            norm_url.c_str(),
            &revision,
            recurse,
            m_context,
            pool
            );
#endif
        permission.allowThisThread();
        if( error != NULL )
            throw SvnException( error );
    }
    catch( SvnException &e )
    {
        // use callback error over ClientException
        m_context.checkForError( m_module.client_error );

        throw_client_error( e );
    }

    return Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, revnum ) );
}