File: pysvn_svnenv.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 (739 lines) | stat: -rw-r--r-- 19,780 bytes parent folder | download | duplicates (3)
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
//
// ====================================================================
// 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.
//
// ====================================================================
//
#include "pysvn_svnenv.hpp"
#include "svn_config.h"
#include "svn_pools.h"
#include "CXX/Objects.hxx"

//--------------------------------------------------------------------------------
//
//        SvnException
//
//--------------------------------------------------------------------------------
SvnException::SvnException( svn_error_t *error )
: m_message()
, m_exception_arg()
{
    std::string whole_message;

    // set the error to be a list of (code, message) tuples
    Py::List error_list;
    while( error != NULL )
    {
        Py::Tuple t( 2 );

        if( !whole_message.empty() )
        {
            whole_message += "\n";
        }

        if( error->message != NULL )
        {
            t[0] = Py::String( error->message );
            whole_message += error->message;
        }
        else
        {
            char buffer[256];
            buffer[0] = '\0';

            svn_strerror( error->apr_err, buffer, sizeof( buffer ) );
            whole_message += buffer;
            t[0] = Py::String( buffer );
        }
        t[1] = Py::Int( error->apr_err );
        error_list.append( t );

        error = error->child;
    }
    m_message = Py::String( whole_message );
    Py::Tuple arg_list(2);
    arg_list[0] = m_message;
    arg_list[1] = error_list;

    m_exception_arg = arg_list;

    svn_error_clear( error );
}

SvnException::SvnException( const SvnException &other )
: m_code( other.m_code )
, m_message( other.m_message )
, m_exception_arg( other.m_exception_arg )
{ }

SvnException::~SvnException()
{ }

Py::String &SvnException::message()
{
    return m_message;
}

apr_status_t SvnException::code()
{
    return m_code;
}

Py::Object &SvnException::pythonExceptionArg( int style )
{
    if( style == 1 )
    {
        return m_exception_arg;
    }
    else
    {
        return m_message;
    }
}

//--------------------------------------------------------------------------------
//
//        SvnContext
//
//--------------------------------------------------------------------------------
#if defined( PYSVN_HAS_CONTEXT_LOG_MSG2 )
extern "C" svn_error_t *handlerLogMsg2
    (
    const char **log_msg,
    const char **tmp_file,
    const apr_array_header_t *commit_items,
    void *baton,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    std::string msg;

    if (!context->contextGetLogMessage( msg ) )
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "" );

    *log_msg = svn_string_ncreate( msg.data(), msg.length(), pool )->data;
    *tmp_file = NULL;

    return SVN_NO_ERROR;
}
#else
extern "C" svn_error_t *handlerLogMsg
    (
    const char **log_msg,
    const char **tmp_file,
    apr_array_header_t *commit_items,
    void *baton,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    std::string msg;

    if (!context->contextGetLogMessage( msg ) )
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "" );

    *log_msg = svn_string_ncreate( msg.data(), msg.length(), pool )->data;
    *tmp_file = NULL;

    return SVN_NO_ERROR;
}
#endif

#if defined( PYSVN_HAS_CONTEXT_NOTIFY2 )
extern "C" void handlerNotify2
    (
    void *baton,
    const svn_wc_notify_t *notify,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    context->contextNotify2( notify, pool );
}
#else
extern "C" void handlerNotify
    (
    void * baton,
    const char *path,
    svn_wc_notify_action_t action,
    svn_node_kind_t kind,
    const char *mime_type,
    svn_wc_notify_state_t content_state,
    svn_wc_notify_state_t prop_state,
    svn_revnum_t revision
    )
{
    pysvn_bpt();

    SvnContext *context = SvnContext::castBaton( baton );

    context->contextNotify( path, action, kind, mime_type, content_state, prop_state, revision );
}
#endif

#if defined( PYSVN_HAS_CONTEXT_PROGRESS )
extern "C" void handlerProgress
    (
    apr_off_t progress,
    apr_off_t total,
    void *baton,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    context->contextProgress( progress, total );
}
#endif

#if defined( PYSVN_HAS_SVN_CLIENT_CTX_T__CONFLICT_FUNC )
extern "C" svn_error_t *handlerConflictResolver
    (
    svn_wc_conflict_result_t **result,
    const svn_wc_conflict_description_t *description,
    void *baton,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    if( context->contextConflictResolver( result, description, pool ) )
        return SVN_NO_ERROR;
    else
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "cancelled by user" );
}
#endif

extern "C" svn_error_t *handlerCancel
    (
    void * baton
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    if( context->contextCancel() )
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "cancelled by user" );
    else
        return SVN_NO_ERROR;
}

extern "C" svn_error_t *handlerSimplePrompt
    (
    svn_auth_cred_simple_t **cred,
    void *baton,
    const char *a_realm,
    const char *a_username, 
    svn_boolean_t a_may_save,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    bool may_save = a_may_save != 0;

    if( a_realm == NULL )
        a_realm = "";
    if( a_username == NULL )
        a_username = "";
    std::string realm( a_realm );
    std::string username( a_username );
    std::string password;

    if( !context->contextGetLogin( realm, username, password, may_save ) )
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "" );

    svn_auth_cred_simple_t *lcred = (svn_auth_cred_simple_t *)apr_palloc( pool, sizeof( svn_auth_cred_simple_t ) );
    lcred->username = svn_string_ncreate( username.data(), username.length(), pool )->data;
    lcred->password = svn_string_ncreate( password.data(), password.length(), pool )->data;

    // tell svn if the credentials need to be saved
    lcred->may_save = may_save;
    *cred = lcred;

    return SVN_NO_ERROR;
}

extern "C" svn_error_t *handlerSslServerTrustPrompt 
    (
    svn_auth_cred_ssl_server_trust_t **cred, 
    void *baton,
    const char *a_realm,
    apr_uint32_t failures,
    const svn_auth_ssl_server_cert_info_t *info,
    svn_boolean_t may_save,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    apr_uint32_t accepted_failures = failures;
    bool accept_permanently = true;

    if( a_realm == NULL )
        a_realm = "";
    std::string realm( a_realm );
    if( !context->contextSslServerTrustPrompt( *info, realm, accepted_failures, accept_permanently ) )
    {
        *cred = NULL;

        return SVN_NO_ERROR;
    }

    svn_auth_cred_ssl_server_trust_t *new_cred = (svn_auth_cred_ssl_server_trust_t *)
            apr_palloc( pool, sizeof (svn_auth_cred_ssl_server_trust_t) );

    if( accept_permanently )
    {
        new_cred->may_save = 1;
    }

    new_cred->accepted_failures = accepted_failures;

    *cred = new_cred;

    return SVN_NO_ERROR;
}

extern "C" svn_error_t *handlerSslClientCertPrompt 
    (
    svn_auth_cred_ssl_client_cert_t **cred, 
    void *baton, 
    const char *a_realm,
    svn_boolean_t a_may_save,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    if( a_realm == NULL )
        a_realm = "";
    std::string realm( a_realm );
    bool may_save = a_may_save != 0;
    std::string cert_file;
    if( !context->contextSslClientCertPrompt( cert_file, realm, may_save ) )
        return svn_error_create (SVN_ERR_CANCELLED, NULL, "");

    svn_auth_cred_ssl_client_cert_t *new_cred = (svn_auth_cred_ssl_client_cert_t*)
        apr_palloc (pool, sizeof (svn_auth_cred_ssl_client_cert_t));

    new_cred->cert_file = svn_string_ncreate( cert_file.data(), cert_file.length(), pool )->data;
    new_cred->may_save = may_save;

    *cred = new_cred;

    return SVN_NO_ERROR;
}

extern "C" svn_error_t *handlerSslClientCertPwPrompt
    (
    svn_auth_cred_ssl_client_cert_pw_t **cred, 
    void *baton, 
    const char *a_realm,
    svn_boolean_t a_may_save,
    apr_pool_t *pool
    )
{
    SvnContext *context = SvnContext::castBaton( baton );

    if( a_realm == NULL )
        a_realm = "";
    std::string realm( a_realm );

    std::string password;
    bool may_save = a_may_save != 0;
    if( !context->contextSslClientCertPwPrompt( password, realm, may_save ) )
        return svn_error_create( SVN_ERR_CANCELLED, NULL, "" );

    svn_auth_cred_ssl_client_cert_pw_t *new_cred = (svn_auth_cred_ssl_client_cert_pw_t *)
        apr_palloc (pool, sizeof (svn_auth_cred_ssl_client_cert_pw_t));

    new_cred->password = svn_string_ncreate( password.data(), password.length(), pool )->data;
    new_cred->may_save = may_save;

    *cred = new_cred;

    return SVN_NO_ERROR;
}

SvnContext::SvnContext( const std::string &config_dir_str )
: m_pool( NULL )
, m_context( NULL )
, m_config_dir( NULL )
{
    memset( &m_context, 0, sizeof( m_context ) );

    apr_pool_create( &m_pool, NULL );

#if defined( PYSVN_HAS_CLIENT_CREATE_CONTEXT2 )
    svn_client_create_context2( &m_context, NULL, m_pool );
#else
    svn_client_create_context( &m_context, m_pool );
#endif

    if( !config_dir_str.empty() )
    {
        m_config_dir = svn_dirent_canonicalize( config_dir_str.c_str(), m_pool );
    }

    svn_config_ensure( m_config_dir, m_pool );

    // get the config based on the config dir passed in
    svn_config_get_config( &m_context->config, m_config_dir, m_pool );

    svn_auth_provider_object_t *provider = NULL;
    apr_array_header_t *providers = apr_array_make( m_pool, 11, sizeof( svn_auth_provider_object_t * ) );

#if defined( PYSVN_HAS_SVN_AUTH_PROVIDERS )

    // simple providers
# if defined( PYSVN_HAS_SVN_AUTH_GET_PLATFORM_SPECIFIC_CLIENT_PROVIDERS )
    svn_config_t *cfg = (svn_config_t *)apr_hash_get
        (
        m_context->config,
        SVN_CONFIG_CATEGORY_CONFIG,
        APR_HASH_KEY_STRING
        );
    svn_auth_get_platform_specific_client_providers( &providers, cfg, m_pool );

# else
#  if defined( WIN32 )
    svn_auth_get_windows_simple_provider(&provider, m_pool);
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;
#  endif
#  if defined( DARWIN )
    svn_auth_get_keychain_simple_provider(&provider, m_pool);
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;
#  endif
# endif

#  if defined( PYSVN_HAS_AUTH_GET_SIMPLE_PROVIDER2 )
    svn_auth_get_simple_provider2( &provider, NULL, NULL, m_pool );
#  else
    svn_auth_get_simple_provider( &provider, m_pool );
#  endif
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_auth_get_username_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_auth_get_simple_prompt_provider( &provider, handlerSimplePrompt, this, 1000000, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    // ssl providers

    // order is important - file first then prompt providers
    svn_auth_get_ssl_server_trust_file_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_auth_get_ssl_client_cert_file_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

# if defined( PYSVN_HAS_AUTH_GET_SSL_CLIENT_CERT_PW_FILE_PROVIDER2 )
    svn_auth_get_ssl_client_cert_pw_file_provider2( &provider, NULL, NULL, m_pool );
# else
    svn_auth_get_ssl_client_cert_pw_file_provider( &provider, m_pool );
# endif
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_auth_get_ssl_server_trust_prompt_provider( &provider, handlerSslServerTrustPrompt, this, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;

    svn_auth_get_ssl_client_cert_prompt_provider( &provider, handlerSslClientCertPrompt, this, 3, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;

    svn_auth_get_ssl_client_cert_pw_prompt_provider( &provider, handlerSslClientCertPwPrompt, this, 3, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
#else
    // Pre 1.4.0 version
    apr_array_header_t *providers = apr_array_make( m_pool, 8, sizeof( svn_auth_provider_object_t * ) );

    // simple providers
    svn_auth_provider_object_t *provider = NULL;
    svn_client_get_simple_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_client_get_username_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_client_get_simple_prompt_provider( &provider, handlerSimplePrompt, this, 3, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    // ssl providers

    // order is important - file first then prompt providers
    svn_client_get_ssl_server_trust_file_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_client_get_ssl_client_cert_file_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_client_get_ssl_client_cert_pw_file_provider( &provider, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push( providers ) = provider;

    svn_client_get_ssl_server_trust_prompt_provider( &provider, handlerSslServerTrustPrompt, this, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;

    svn_client_get_ssl_client_cert_prompt_provider( &provider, handlerSslClientCertPrompt, this, 3, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;

    svn_client_get_ssl_client_cert_pw_prompt_provider( &provider, handlerSslClientCertPwPrompt, this, 3, m_pool );
    *(svn_auth_provider_object_t **)apr_array_push (providers) = provider;
#endif

    svn_auth_baton_t *auth_baton = NULL;
    svn_auth_open( &auth_baton, providers, m_pool );

    // tell the auth functions where the config dir is
    svn_auth_set_parameter( auth_baton, SVN_AUTH_PARAM_CONFIG_DIR, m_config_dir );

    m_context->auth_baton = auth_baton;

#if defined( PYSVN_HAS_CONTEXT_LOG_MSG2 )
    m_context->log_msg_func2 = handlerLogMsg2;
    m_context->log_msg_baton2 = this;
#else
    m_context->log_msg_func = handlerLogMsg;
    m_context->log_msg_baton = this;
#endif
}

void SvnContext::installCancel( bool install )
{
    if( install )
    {
        m_context->cancel_func = handlerCancel;
        m_context->cancel_baton = this;
    }
    else
    {
        m_context->cancel_func = NULL;
        m_context->cancel_baton = NULL;
    }
}

void SvnContext::installNotify( bool install )
{
    if( install )
    {
#if defined( PYSVN_HAS_CONTEXT_NOTIFY2 )
        m_context->notify_func2 = handlerNotify2;
        m_context->notify_baton2 = this;
#else
        m_context->notify_func = handlerNotify;
        m_context->notify_baton = this;
#endif
    }
    else
    {
#if defined( PYSVN_HAS_CONTEXT_NOTIFY2 )
        m_context->notify_func2 = NULL;
        m_context->notify_baton2 = NULL;
#else
        m_context->notify_func = NULL;
        m_context->notify_baton = NULL;
#endif
    }
}

#if defined( PYSVN_HAS_CONTEXT_PROGRESS )
void SvnContext::installProgress( bool install )
{
    if( install )
    {
        m_context->progress_func = handlerProgress;
        m_context->progress_baton = this;
    }
    else
    {
        m_context->progress_func = handlerProgress;
        m_context->progress_baton = this;
    }
}
#endif

#if defined( PYSVN_HAS_SVN_CLIENT_CTX_T__CONFLICT_FUNC )
void SvnContext::installConflictResolver( bool install )
{
    if( install )
    {
        m_context->conflict_func = handlerConflictResolver;
        m_context->conflict_baton = this;
    }
    else
    {
        m_context->conflict_func = NULL;
        m_context->conflict_baton = NULL;
    }
}
#endif

SvnContext::~SvnContext()
{
    if( m_pool )
    {
        apr_pool_destroy( m_pool );
    }
}

SvnContext::operator svn_client_ctx_t *()
{
    return m_context;
}

svn_client_ctx_t *SvnContext::ctx()
{
    return m_context;
}

// only use this pool for data that has a life time
// that matches the life time of the context
apr_pool_t *SvnContext::getContextPool()
{
    return m_pool;
}

//--------------------------------------------------------------------------------
//
//        SvnTransaction
//
//--------------------------------------------------------------------------------
SvnTransaction::SvnTransaction()
: m_pool( NULL )
, m_repos( NULL )
, m_fs( NULL )
, m_txn( NULL )
, m_txn_name( NULL )
, m_rev_id( SVN_INVALID_REVNUM )
{
    apr_pool_create( &m_pool, NULL );
}

svn_error_t *SvnTransaction::init( const std::string &repos_path,
    const std::string &transaction_name, bool is_revision )
{
    svn_error_t *error;

    SvnPool scratch_pool( *this );

#if defined( PYSVN_HAS_REPOS_OPEN3 )
    error = svn_repos_open3( &m_repos, repos_path.c_str(), NULL, m_pool, scratch_pool );

# elif defined( PYSNV_HAS_REPOS_OPEN2 )
    error = svn_repos_open2( &m_repos, repos_path.c_str(), NULL, m_pool );

#else
    error = svn_repos_open( &m_repos, repos_path.c_str(), m_pool );
#endif
    if( error != NULL )
        return error;

    m_fs = svn_repos_fs( m_repos );
    // what is a warning function?
    // svn_fs_set_warning_func (m_fs, warning_func, NULL);

    if( is_revision )
    {
        Py::String rev_name( transaction_name );
        Py::Long long_val( rev_name );
        m_rev_id = (long)long_val;
        if (! SVN_IS_VALID_REVNUM( m_rev_id ))
            return svn_error_create( SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
                "invalid revision number supplied" );
    }
    else
    {
        m_txn_name = apr_pstrdup( m_pool, transaction_name.c_str() );
        error = svn_fs_open_txn( &m_txn, m_fs, m_txn_name, m_pool );
    }

    return error;
}

SvnTransaction::~SvnTransaction()
{
}

svn_error_t *SvnTransaction::root( svn_fs_root_t **root, apr_pool_t *pool )
{
    if( is_revision() )
        return svn_fs_revision_root( root, m_fs, m_rev_id, pool );
    else
        return svn_fs_txn_root( root, m_txn, pool );
}

SvnTransaction::operator svn_fs_txn_t *()
{
    return m_txn;
}

SvnTransaction::operator svn_fs_t *()
{
    return m_fs;
}

SvnTransaction::operator svn_repos_t *()
{
    return m_repos;
}


svn_fs_txn_t *SvnTransaction::transaction()
{
    return m_txn;
}

svn_revnum_t SvnTransaction::revision()
{
    return m_rev_id;
}

//--------------------------------------------------------------------------------
//
//        Pool
//
//--------------------------------------------------------------------------------
SvnPool::SvnPool( SvnContext &ctx )
: m_pool( NULL )
{
    m_pool = svn_pool_create( NULL );
}

SvnPool::SvnPool( SvnTransaction &txn )
: m_pool( NULL )
{
    m_pool = svn_pool_create( NULL );
}

SvnPool::~SvnPool()
{
    if( m_pool != NULL )
    {
        svn_pool_destroy( m_pool );
    }
}

SvnPool::operator apr_pool_t *() const 
{
    return m_pool;
}

#if 0
// keep around as it useful for debugging pysvn
static const char *toHex( unsigned int num )
{
    static char buffer[9];
    for( int i=0; i<8; i++ )
    {
        buffer[i] = "0123456789abcdef"[ (num >> (32-(i+1)*4)) & 0x0f ];
    }
    buffer[8] = '\0';
    return buffer;
}
#endif