111
106
return svn_path_compare_paths ((const char *)a->key, (const char *)b->key);
114
kio_svnProtocol::kio_svnProtocol(const QCString &pool_socket, const QCString &app_socket)
109
kio_svnProtocol::kio_svnProtocol(const QByteArray &pool_socket, const QByteArray &app_socket)
115
110
: SlaveBase("kio_svn", pool_socket, app_socket) {
116
kdDebug(7128) << "kio_svnProtocol::kio_svnProtocol()" << endl;
111
kDebug(7128) << "kio_svnProtocol::kio_svnProtocol()";
120
115
apr_initialize();
121
// CleanUP ctx preventing crash in svn_client_update and other
122
memset(&ctx, 0, sizeof(ctx));
123
116
pool = svn_pool_create (NULL);
125
117
svn_error_t *err = svn_client_create_context(&ctx, pool);
127
kdDebug(7128) << "kio_svnProtocol::kio_svnProtocol() create_context ERROR" << endl;
128
error( KIO::ERR_SLAVE_DEFINED, err->message );
119
kDebug(7128) << "kio_svnProtocol::kio_svnProtocol() create_context ERROR";
120
error( KIO::ERR_SLAVE_DEFINED, err->message );
132
124
err = svn_config_ensure (NULL,pool);
134
kdDebug(7128) << "kio_svnProtocol::kio_svnProtocol() configensure ERROR" << endl;
126
kDebug(7128) << "kio_svnProtocol::kio_svnProtocol() configensure ERROR";
135
127
error( KIO::ERR_SLAVE_DEFINED, err->message );
138
svn_config_get_config (&ctx->config, NULL, pool);
130
svn_config_get_config (&ctx->config,NULL,pool);
140
132
ctx->log_msg_func = kio_svnProtocol::commitLogPrompt;
141
133
ctx->log_msg_baton = this; //pass this so that we can get a dcopClient from it
190
182
ctx->notify_func = kio_svnProtocol::notify;
191
183
struct notify_baton *nb = ( struct notify_baton* )apr_palloc(spool, sizeof( *nb ) );
192
184
nb->master = this;
193
nb->received_some_change = FALSE;
194
nb->sent_first_txdelta = FALSE;
185
nb->received_some_change = false;
186
nb->sent_first_txdelta = false;
195
187
nb->is_checkout = is_checkout;
196
188
nb->is_export = is_export;
197
189
nb->suppress_final_line = suppress_final_line;
198
nb->in_external = FALSE;
199
nb->had_print_error = FALSE;
190
nb->in_external = false;
191
nb->had_print_error = false;
200
192
nb->pool = svn_pool_create (spool);
202
194
ctx->notify_baton = nb;
205
197
svn_error_t* kio_svnProtocol::checkAuth(svn_auth_cred_simple_t **cred, void *baton, const char *realm, const char *username, svn_boolean_t /*may_save*/, apr_pool_t *pool) {
206
kdDebug(7128) << "kio_svnProtocol::checkAuth() for " << realm << endl;
198
kDebug(7128) << "kio_svnProtocol::checkAuth() for " << realm;
207
199
kio_svnProtocol *p = ( kio_svnProtocol* )baton;
208
200
svn_auth_cred_simple_t *ret = (svn_auth_cred_simple_t*)apr_pcalloc (pool, sizeof (*ret));
210
202
// p->info.keepPassword = true;
211
203
p->info.verifyPath=true;
212
kdDebug(7128 ) << "auth current URL : " << p->myURL.url() << endl;
204
kDebug(7128 ) << "auth current URL : " << p->myURL.url();
213
205
p->info.url = p->myURL;
214
206
p->info.username = username; //( const char* )svn_auth_get_parameter( p->ctx->auth_baton, SVN_AUTH_PARAM_DEFAULT_USERNAME );
215
207
// if ( !p->checkCachedAuthentication( p->info ) ){
216
p->openPassDlg( p->info );
208
p->openPasswordDialog( p->info );
218
ret->username = apr_pstrdup(pool, p->info.username.utf8());
219
ret->password = apr_pstrdup(pool, p->info.password.utf8());
210
ret->username = apr_pstrdup(pool, p->info.username.toUtf8());
211
ret->password = apr_pstrdup(pool, p->info.password.toUtf8());
220
212
ret->may_save = true;
222
214
return SVN_NO_ERROR;
225
void kio_svnProtocol::recordCurrentURL(const KURL& url) {
217
void kio_svnProtocol::recordCurrentURL(const KUrl& url) {
229
221
//don't implement mimeType() until we don't need to download the whole file
231
void kio_svnProtocol::get(const KURL& url ){
232
kdDebug(7128) << "kio_svn::get(const KURL& url)" << endl ;
223
void kio_svnProtocol::get(const KUrl& url ){
224
kDebug(7128) << "kio_svn::get(const KUrl& url)";
234
226
QString remoteServer = url.host();
235
infoMessage(i18n("Looking for %1...").arg( remoteServer ) );
227
infoMessage(i18n("Looking for %1...", remoteServer ) );
237
229
apr_pool_t *subpool = svn_pool_create (pool);
238
230
kbaton *bt = (kbaton*)apr_pcalloc(subpool, sizeof(*bt));
241
233
svn_stream_set_write(bt->string_stream,write_to_string);
243
235
QString target = makeSvnURL( url );
244
kdDebug(7128) << "SvnURL: " << target << endl;
245
recordCurrentURL( KURL( target ) );
236
kDebug(7128) << "SvnURL: " << target;
237
recordCurrentURL( KUrl( target ) );
247
239
//find the requested revision
248
240
svn_opt_revision_t rev;
249
241
svn_opt_revision_t endrev;
250
int idx = target.findRev( "?rev=" );
242
int idx = target.lastIndexOf( "?rev=" );
251
243
if ( idx != -1 ) {
252
244
QString revstr = target.mid( idx+5 );
254
kdDebug(7128) << "revision string found " << revstr << endl;
246
kDebug(7128) << "revision string found " << revstr;
255
247
if ( revstr == "HEAD" ) {
256
248
rev.kind = svn_opt_revision_head;
257
kdDebug(7128) << "revision searched : HEAD" << endl;
249
kDebug(7128) << "revision searched : HEAD";
259
251
rev.kind = svn_opt_revision_number;
260
252
rev.value.number = revstr.toLong();
261
kdDebug(7128) << "revision searched : " << rev.value.number << endl;
253
kDebug(7128) << "revision searched : " << rev.value.number;
264
svn_opt_parse_revision( &rev, &endrev, revstr.utf8(), subpool );
256
svn_opt_parse_revision( &rev, &endrev, revstr.toUtf8(), subpool );
265
257
target = target.left( idx );
266
kdDebug(7128) << "new target : " << target << endl;
258
kDebug(7128) << "new target : " << target;
268
kdDebug(7128) << "no revision given. searching HEAD " << endl;
260
kDebug(7128) << "no revision given. searching HEAD ";
269
261
rev.kind = svn_opt_revision_head;
271
263
initNotifier(false, false, false, subpool);
273
svn_error_t *err = svn_client_cat (bt->string_stream, svn_path_canonicalize( target.utf8(),subpool ),&rev,ctx, subpool);
265
svn_error_t *err = svn_client_cat (bt->string_stream, svn_path_canonicalize( target.toUtf8(),subpool ),&rev,ctx, subpool);
275
267
error( KIO::ERR_SLAVE_DEFINED, err->message );
276
268
svn_pool_destroy( subpool );
303
295
apr_pool_t *subpool = svn_pool_create (pool);
305
297
QString target = makeSvnURL( url);
306
kdDebug(7128) << "SvnURL: " << target << endl;
307
recordCurrentURL( KURL( target ) );
298
kDebug(7128) << "SvnURL: " << target;
299
recordCurrentURL( KUrl( target ) );
309
301
//find the requested revision
310
302
svn_opt_revision_t rev;
311
303
svn_opt_revision_t endrev;
312
int idx = target.findRev( "?rev=" );
304
int idx = target.lastIndexOf( "?rev=" );
313
305
if ( idx != -1 ) {
314
306
QString revstr = target.mid( idx+5 );
316
kdDebug(7128) << "revision string found " << revstr << endl;
308
kDebug(7128) << "revision string found " << revstr;
317
309
if ( revstr == "HEAD" ) {
318
310
rev.kind = svn_opt_revision_head;
319
kdDebug(7128) << "revision searched : HEAD" << endl;
311
kDebug(7128) << "revision searched : HEAD";
321
313
rev.kind = svn_opt_revision_number;
322
314
rev.value.number = revstr.toLong();
323
kdDebug(7128) << "revision searched : " << rev.value.number << endl;
315
kDebug(7128) << "revision searched : " << rev.value.number;
326
svn_opt_parse_revision( &rev, &endrev, revstr.utf8( ), subpool );
318
svn_opt_parse_revision( &rev, &endrev, revstr.toUtf8( ), subpool );
327
319
target = target.left( idx );
328
kdDebug(7128) << "new target : " << target << endl;
320
kDebug(7128) << "new target : " << target;
330
kdDebug(7128) << "no revision given. searching HEAD " << endl;
322
kDebug(7128) << "no revision given. searching HEAD ";
331
323
rev.kind = svn_opt_revision_head;
335
327
svn_error_t *err = svn_ra_init_ra_libs(&ra_baton,subpool);
337
kdDebug(7128) << "init RA libs failed : " << err->message << endl;
329
kDebug(7128) << "init RA libs failed : " << err->message;
341
err = svn_ra_get_ra_library(&ra_lib,ra_baton,svn_path_canonicalize( target.utf8(), subpool ),subpool);
333
err = svn_ra_get_ra_library(&ra_lib,ra_baton,svn_path_canonicalize( target.toUtf8(), subpool ),subpool);
343
kdDebug(7128) << "RA get libs failed : " << err->message << endl;
335
kDebug(7128) << "RA get libs failed : " << err->message;
346
kdDebug(7128) << "RA init completed" << endl;
338
kDebug(7128) << "RA init completed";
349
svn_ra_callbacks_t *cbtable = (svn_ra_callbacks_t*)apr_pcalloc(subpool, sizeof(*cbtable));
341
svn_ra_callbacks_t *cbtable = (svn_ra_callbacks_t*)apr_pcalloc(subpool, sizeof(*cbtable));
350
342
kio_svn_callback_baton_t *callbackbt = (kio_svn_callback_baton_t*)apr_pcalloc(subpool, sizeof( *callbackbt ));
352
344
cbtable->open_tmp_file = open_tmp_file;
355
347
cbtable->push_wc_prop = NULL;
356
348
cbtable->auth_baton = ctx->auth_baton;
358
callbackbt->base_dir = target.utf8();
350
callbackbt->base_dir = target.toUtf8();
359
351
callbackbt->pool = subpool;
360
352
callbackbt->config = ctx->config;
362
err = ra_lib->open(&session,svn_path_canonicalize( target.utf8(), subpool ),cbtable,callbackbt,ctx->config,subpool);
354
err = ra_lib->open(&session,svn_path_canonicalize( target.toUtf8(), subpool ),cbtable,callbackbt,ctx->config,subpool);
364
kdDebug(7128)<< "Open session " << err->message << endl;
356
kDebug(7128)<< "Open session " << err->message;
367
kdDebug(7128) << "Session opened to " << target << endl;
359
kDebug(7128) << "Session opened to " << target;
368
360
//find number for HEAD
369
361
if (rev.kind == svn_opt_revision_head) {
370
362
err = ra_lib->get_latest_revnum(session,&rev.value.number,subpool);
372
kdDebug(7128)<< "Latest RevNum " << err->message << endl;
364
kDebug(7128)<< "Latest RevNum " << err->message;
375
kdDebug(7128) << "Got rev " << rev.value.number << endl;
367
kDebug(7128) << "Got rev " << rev.value.number;
379
371
ra_lib->check_path(session,"",rev.value.number,&kind,subpool);
380
kdDebug(7128) << "Checked Path" << endl;
372
kDebug(7128) << "Checked Path";
382
374
switch ( kind ) {
383
375
case svn_node_file:
384
kdDebug(7128) << "::stat result : file" << endl;
385
createUDSEntry(url.filename(),"",0,false,0,entry);
376
kDebug(7128) << "::stat result : file";
377
createUDSEntry(url.fileName(),"",0,false,0,entry);
386
378
statEntry( entry );
388
380
case svn_node_dir:
389
kdDebug(7128) << "::stat result : directory" << endl;
390
createUDSEntry(url.filename(),"",0,true,0,entry);
381
kDebug(7128) << "::stat result : directory";
382
createUDSEntry(url.fileName(),"",0,true,0,entry);
391
383
statEntry( entry );
393
385
case svn_node_unknown:
394
386
case svn_node_none:
397
kdDebug(7128) << "::stat result : UNKNOWN ==> WOW :)" << endl;
389
kDebug(7128) << "::stat result : UNKNOWN ==> WOW :)";
401
393
svn_pool_destroy( subpool );
404
void kio_svnProtocol::listDir(const KURL& url){
405
kdDebug(7128) << "kio_svn::listDir(const KURL& url) : " << url.url() << endl ;
396
void kio_svnProtocol::listDir(const KUrl& url){
397
kDebug(7128) << "kio_svn::listDir(const KUrl& url) : " << url.url();
407
399
apr_pool_t *subpool = svn_pool_create (pool);
408
400
apr_hash_t *dirents;
410
402
QString target = makeSvnURL( url);
411
kdDebug(7128) << "SvnURL: " << target << endl;
412
recordCurrentURL( KURL( target ) );
403
kDebug(7128) << "SvnURL: " << target;
404
recordCurrentURL( KUrl( target ) );
414
406
//find the requested revision
415
407
svn_opt_revision_t rev;
416
408
svn_opt_revision_t endrev;
417
int idx = target.findRev( "?rev=" );
409
int idx = target.lastIndexOf( "?rev=" );
418
410
if ( idx != -1 ) {
419
411
QString revstr = target.mid( idx+5 );
420
svn_opt_parse_revision( &rev, &endrev, revstr.utf8(), subpool );
412
svn_opt_parse_revision( &rev, &endrev, revstr.toUtf8(), subpool );
422
kdDebug(7128) << "revision string found " << revstr << endl;
414
kDebug(7128) << "revision string found " << revstr;
423
415
if ( revstr == "HEAD" ) {
424
416
rev.kind = svn_opt_revision_head;
425
kdDebug(7128) << "revision searched : HEAD" << endl;
417
kDebug(7128) << "revision searched : HEAD";
427
419
rev.kind = svn_opt_revision_number;
428
420
rev.value.number = revstr.toLong();
429
kdDebug(7128) << "revision searched : " << rev.value.number << endl;
421
kDebug(7128) << "revision searched : " << rev.value.number;
432
424
target = target.left( idx );
433
kdDebug(7128) << "new target : " << target << endl;
425
kDebug(7128) << "new target : " << target;
435
kdDebug(7128) << "no revision given. searching HEAD " << endl;
427
kDebug(7128) << "no revision given. searching HEAD ";
436
428
rev.kind = svn_opt_revision_head;
439
431
initNotifier(false, false, false, subpool);
440
svn_error_t *err = svn_client_ls (&dirents, svn_path_canonicalize( target.utf8(), subpool ), &rev, false, ctx, subpool);
432
svn_error_t *err = svn_client_ls (&dirents, svn_path_canonicalize( target.toUtf8(), subpool ), &rev, false, ctx, subpool);
442
434
error( KIO::ERR_SLAVE_DEFINED, err->message );
443
435
svn_pool_destroy( subpool );
489
481
bool kio_svnProtocol::createUDSEntry( const QString& filename, const QString& user, long long int size, bool isdir, time_t mtime, UDSEntry& entry) {
490
kdDebug(7128) << "MTime : " << ( long )mtime << endl;
491
kdDebug(7128) << "UDS filename : " << filename << endl;
493
atom.m_uds = KIO::UDS_NAME;
494
atom.m_str = filename;
495
entry.append( atom );
497
atom.m_uds = KIO::UDS_FILE_TYPE;
498
atom.m_long = isdir ? S_IFDIR : S_IFREG;
499
entry.append( atom );
501
atom.m_uds = KIO::UDS_SIZE;
503
entry.append( atom );
505
atom.m_uds = KIO::UDS_MODIFICATION_TIME;
507
entry.append( atom );
509
atom.m_uds = KIO::UDS_USER;
511
entry.append( atom );
482
kDebug(7128) << "MTime : " << ( long )mtime;
483
kDebug(7128) << "UDS filename : " << filename;
484
entry.insert(KIO::UDSEntry::UDS_NAME,filename);
486
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE,isdir ? S_IFDIR : S_IFREG);
488
entry.insert(KIO::UDSEntry::UDS_SIZE,size);
490
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME,mtime);
492
entry.insert(KIO::UDSEntry::UDS_USER,user);
516
void kio_svnProtocol::copy(const KURL & src, const KURL& dest, int /*permissions*/, bool /*overwrite*/) {
517
kdDebug(7128) << "kio_svnProtocol::copy() Source : " << src.url() << " Dest : " << dest.url() << endl;
497
void kio_svnProtocol::copy(const KUrl & src, const KUrl& dest, int /*permissions*/, KIO::JobFlags) {
498
kDebug(7128) << "kio_svnProtocol::copy() Source : " << src.url() << " Dest : " << dest.url();
519
500
apr_pool_t *subpool = svn_pool_create (pool);
520
501
svn_client_commit_info_t *commit_info = NULL;
524
505
nsrc.setProtocol( chooseProtocol( src.protocol() ) );
525
506
ndest.setProtocol( chooseProtocol( dest.protocol() ) );
526
507
QString srcsvn = nsrc.url();
527
508
QString destsvn = ndest.url();
529
510
recordCurrentURL( nsrc );
531
512
//find the requested revision
532
513
svn_opt_revision_t rev;
533
int idx = srcsvn.findRev( "?rev=" );
514
int idx = srcsvn.lastIndexOf( "?rev=" );
534
515
if ( idx != -1 ) {
535
516
QString revstr = srcsvn.mid( idx+5 );
536
kdDebug(7128) << "revision string found " << revstr << endl;
517
kDebug(7128) << "revision string found " << revstr;
537
518
if ( revstr == "HEAD" ) {
538
519
rev.kind = svn_opt_revision_head;
539
kdDebug(7128) << "revision searched : HEAD" << endl;
520
kDebug(7128) << "revision searched : HEAD";
541
522
rev.kind = svn_opt_revision_number;
542
523
rev.value.number = revstr.toLong();
543
kdDebug(7128) << "revision searched : " << rev.value.number << endl;
524
kDebug(7128) << "revision searched : " << rev.value.number;
545
526
srcsvn = srcsvn.left( idx );
546
kdDebug(7128) << "new src : " << srcsvn << endl;
527
kDebug(7128) << "new src : " << srcsvn;
548
kdDebug(7128) << "no revision given. searching HEAD " << endl;
529
kDebug(7128) << "no revision given. searching HEAD ";
549
530
rev.kind = svn_opt_revision_head;
552
533
initNotifier(false, false, false, subpool);
553
svn_error_t *err = svn_client_copy(&commit_info, srcsvn.utf8(), &rev, destsvn.utf8(), ctx, subpool);
534
svn_error_t *err = svn_client_copy(&commit_info, srcsvn.toUtf8(), &rev, destsvn.toUtf8(), ctx, subpool);
555
536
error( KIO::ERR_SLAVE_DEFINED, err->message );
559
540
svn_pool_destroy (subpool);
562
void kio_svnProtocol::mkdir( const KURL::List& list, int /*permissions*/ ) {
563
kdDebug(7128) << "kio_svnProtocol::mkdir(LIST) : " << list << endl;
543
void kio_svnProtocol::mkdir( const KUrl::List& list, int /*permissions*/ ) {
544
kDebug(7128) << "kio_svnProtocol::mkdir(LIST) : " << list;
565
546
apr_pool_t *subpool = svn_pool_create (pool);
566
547
svn_client_commit_info_t *commit_info = NULL;
568
549
recordCurrentURL( list[ 0 ] );
570
551
apr_array_header_t *targets = apr_array_make(subpool, list.count()+1, sizeof(const char *));
572
KURL::List::const_iterator it = list.begin(), end = list.end();
553
KUrl::List::const_iterator it = list.begin(), end = list.end();
573
554
for ( ; it != end; ++it ) {
574
555
QString cur = makeSvnURL( *it );
575
kdDebug( 7128 ) << "kio_svnProtocol::mkdir raw url for subversion : " << cur << endl;
576
const char *_target = apr_pstrdup( subpool, svn_path_canonicalize( apr_pstrdup( subpool, cur.utf8() ), subpool ) );
556
kDebug( 7128 ) << "kio_svnProtocol::mkdir raw url for subversion : " << cur;
557
const char *_target = apr_pstrdup( subpool, svn_path_canonicalize( apr_pstrdup( subpool, cur.toUtf8() ), subpool ) );
577
558
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = _target;
583
564
error( KIO::ERR_COULD_NOT_MKDIR, err->message );
587
568
svn_pool_destroy (subpool);
590
void kio_svnProtocol::mkdir( const KURL& url, int /*permissions*/ ) {
591
kdDebug(7128) << "kio_svnProtocol::mkdir() : " << url.url() << endl;
571
void kio_svnProtocol::mkdir( const KUrl& url, int /*permissions*/ ) {
572
kDebug(7128) << "kio_svnProtocol::mkdir() : " << url.url();
593
574
apr_pool_t *subpool = svn_pool_create (pool);
594
575
svn_client_commit_info_t *commit_info = NULL;
596
577
QString target = makeSvnURL( url);
597
kdDebug(7128) << "SvnURL: " << target << endl;
598
recordCurrentURL( KURL( target ) );
578
kDebug(7128) << "SvnURL: " << target;
579
recordCurrentURL( KUrl( target ) );
600
581
apr_array_header_t *targets = apr_array_make(subpool, 2, sizeof(const char *));
601
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = apr_pstrdup( subpool, target.utf8() );
582
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = apr_pstrdup( subpool, target.toUtf8() );
603
584
initNotifier(false, false, false, subpool);
604
585
svn_error_t *err = svn_client_mkdir(&commit_info,targets,ctx,subpool);
606
587
error( KIO::ERR_COULD_NOT_MKDIR, err->message );
610
591
svn_pool_destroy (subpool);
613
void kio_svnProtocol::del( const KURL& url, bool /*isfile*/ ) {
614
kdDebug(7128) << "kio_svnProtocol::del() : " << url.url() << endl;
594
void kio_svnProtocol::del( const KUrl& url, bool /*isfile*/ ) {
595
kDebug(7128) << "kio_svnProtocol::del() : " << url.url();
616
597
apr_pool_t *subpool = svn_pool_create (pool);
617
598
svn_client_commit_info_t *commit_info = NULL;
619
600
QString target = makeSvnURL(url);
620
kdDebug(7128) << "SvnURL: " << target << endl;
621
recordCurrentURL( KURL( target ) );
601
kDebug(7128) << "SvnURL: " << target;
602
recordCurrentURL( KUrl( target ) );
623
604
apr_array_header_t *targets = apr_array_make(subpool, 2, sizeof(const char *));
624
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = apr_pstrdup( subpool, target.utf8() );
605
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = apr_pstrdup( subpool, target.toUtf8() );
626
607
initNotifier(false, false, false, subpool);
627
608
svn_error_t *err = svn_client_delete(&commit_info,targets,false/*force remove locally modified files in wc*/,ctx,subpool);
629
610
error( KIO::ERR_CANNOT_DELETE, err->message );
633
614
svn_pool_destroy (subpool);
636
void kio_svnProtocol::rename(const KURL& src, const KURL& dest, bool /*overwrite*/) {
637
kdDebug(7128) << "kio_svnProtocol::rename() Source : " << src.url() << " Dest : " << dest.url() << endl;
617
void kio_svnProtocol::rename(const KUrl& src, const KUrl& dest, KIO::JobFlags) {
618
kDebug(7128) << "kio_svnProtocol::rename() Source : " << src.url() << " Dest : " << dest.url();
639
620
apr_pool_t *subpool = svn_pool_create (pool);
640
621
svn_client_commit_info_t *commit_info = NULL;
644
625
nsrc.setProtocol( chooseProtocol( src.protocol() ) );
645
626
ndest.setProtocol( chooseProtocol( dest.protocol() ) );
646
627
QString srcsvn = nsrc.url();
647
628
QString destsvn = ndest.url();
649
630
recordCurrentURL( nsrc );
651
632
//find the requested revision
652
633
svn_opt_revision_t rev;
653
int idx = srcsvn.findRev( "?rev=" );
634
int idx = srcsvn.lastIndexOf( "?rev=" );
654
635
if ( idx != -1 ) {
655
636
QString revstr = srcsvn.mid( idx+5 );
656
kdDebug(7128) << "revision string found " << revstr << endl;
637
kDebug(7128) << "revision string found " << revstr;
657
638
if ( revstr == "HEAD" ) {
658
639
rev.kind = svn_opt_revision_head;
659
kdDebug(7128) << "revision searched : HEAD" << endl;
640
kDebug(7128) << "revision searched : HEAD";
661
642
rev.kind = svn_opt_revision_number;
662
643
rev.value.number = revstr.toLong();
663
kdDebug(7128) << "revision searched : " << rev.value.number << endl;
644
kDebug(7128) << "revision searched : " << rev.value.number;
665
646
srcsvn = srcsvn.left( idx );
666
kdDebug(7128) << "new src : " << srcsvn << endl;
647
kDebug(7128) << "new src : " << srcsvn;
668
kdDebug(7128) << "no revision given. searching HEAD " << endl;
649
kDebug(7128) << "no revision given. searching HEAD ";
669
650
rev.kind = svn_opt_revision_head;
672
653
initNotifier(false, false, false, subpool);
673
svn_error_t *err = svn_client_move(&commit_info, srcsvn.utf8(), &rev, destsvn.utf8(), false/*force remove locally modified files in wc*/, ctx, subpool);
654
svn_error_t *err = svn_client_move(&commit_info, srcsvn.toUtf8(), &rev, destsvn.toUtf8(), false/*force remove locally modified files in wc*/, ctx, subpool);
675
656
error( KIO::ERR_CANNOT_RENAME, err->message );
679
660
svn_pool_destroy (subpool);
682
663
void kio_svnProtocol::special( const QByteArray& data ) {
683
kdDebug(7128) << "kio_svnProtocol::special" << endl;
664
kDebug(7128) << "kio_svnProtocol::special";
685
QDataStream stream(data, IO_ReadOnly);
666
QByteArray tmpData(data);
667
QDataStream stream(&tmpData, QIODevice::ReadOnly);
689
kdDebug(7128) << "kio_svnProtocol::special " << tmp << endl;
671
kDebug(7128) << "kio_svnProtocol::special " << tmp;
697
679
stream >> repository;
699
681
stream >> revnumber;
700
682
stream >> revkind;
701
kdDebug(7128) << "kio_svnProtocol CHECKOUT from " << repository.url() << " to " << wc.url() << " at " << revnumber << " or " << revkind << endl;
683
kDebug(7128) << "kio_svnProtocol CHECKOUT from " << repository.url() << " to " << wc.url() << " at " << revnumber << " or " << revkind;
702
684
checkout( repository, wc, revnumber, revkind );
711
693
stream >> revnumber;
712
694
stream >> revkind;
713
kdDebug(7128) << "kio_svnProtocol UPDATE " << wc.url() << " at " << revnumber << " or " << revkind << endl;
695
kDebug(7128) << "kio_svnProtocol UPDATE " << wc.url() << " at " << revnumber << " or " << revkind;
714
696
update(wc, revnumber, revkind );
720
702
while ( !stream.atEnd() ) {
725
kdDebug(7128) << "kio_svnProtocol COMMIT" << endl;
707
kDebug(7128) << "kio_svnProtocol COMMIT";
726
708
commit( wclist );
731
kdDebug(7128) << "kio_svnProtocol LOG" << endl;
713
kDebug(7128) << "kio_svnProtocol LOG";
732
714
int revstart, revend;
733
715
QString revkindstart, revkindend;
735
717
stream >> revstart;
736
718
stream >> revkindstart;
737
719
stream >> revend;
738
720
stream >> revkindend;
739
721
while ( !stream.atEnd() ) {
744
726
svn_log( revstart, revkindstart, revend, revkindend, targets );
752
kdDebug(7128) << "kio_svnProtocol IMPORT" << endl;
734
kDebug(7128) << "kio_svnProtocol IMPORT";
753
735
import(repos,wc);
760
kdDebug(7128) << "kio_svnProtocol ADD" << endl;
742
kDebug(7128) << "kio_svnProtocol ADD";
767
749
while ( !stream.atEnd() ) {
772
kdDebug(7128) << "kio_svnProtocol DEL" << endl;
754
kDebug(7128) << "kio_svnProtocol DEL";
773
755
wc_delete(wclist);
779
761
while ( !stream.atEnd() ) {
784
kdDebug(7128) << "kio_svnProtocol REVERT" << endl;
766
kDebug(7128) << "kio_svnProtocol REVERT";
785
767
wc_revert(wclist);
791
773
int checkRepos=false;
792
774
int fullRecurse=false;
794
776
stream >> checkRepos;
795
777
stream >> fullRecurse;
796
kdDebug(7128) << "kio_svnProtocol STATUS" << endl;
778
kDebug(7128) << "kio_svnProtocol STATUS";
797
779
wc_status(wc,checkRepos,fullRecurse);
804
kdDebug(7128) << "kio_svnProtocol MKDIR" << endl;
786
kDebug(7128) << "kio_svnProtocol MKDIR";
808
790
case SVN_RESOLVE:
813
795
stream >> recurse;
814
kdDebug(7128) << "kio_svnProtocol RESOLVE" << endl;
796
kDebug(7128) << "kio_svnProtocol RESOLVE";
815
797
wc_resolve(url,recurse);
844
826
stream >> revkind2;
845
827
stream >> recurse;
846
kdDebug(7128) << "kio_svnProtocol DIFF" << endl;
828
kDebug(7128) << "kio_svnProtocol DIFF";
847
829
svn_diff(url1,url2,rev1,rev2,revkind1,revkind2,recurse);
852
kdDebug(7128) << "kio_svnProtocol DEFAULT" << endl;
834
kDebug(7128) << "kio_svnProtocol DEFAULT";
858
840
void kio_svnProtocol::popupMessage( const QString& message ) {
860
QDataStream stream(params, IO_WriteOnly);
842
#warning "kde4: port dbus stuff"
846
QDataStream stream(¶ms, QIODevice::WriteOnly);
863
849
if ( !dcopClient()->send( "kded","ksvnd","popupMessage(QString)", params ) )
864
kdWarning() << "Communication with KDED:KSvnd failed" << endl;
850
kWarning() << "Communication with KDED:KSvnd failed";
867
void kio_svnProtocol::svn_log( int revstart, const QString& revkindstart, int revend, const QString& revkindend, const KURL::List& targets ) {
868
kdDebug(7128) << "kio_svn::log : " << targets << " from revision " << revstart << " or " << revkindstart << " to "
854
void kio_svnProtocol::svn_log( int revstart, const QString& revkindstart, int revend, const QString& revkindend, const KUrl::List& targets ) {
855
kDebug(7128) << "kio_svn::log : " << targets << " from revision " << revstart << " or " << revkindstart << " to "
869
856
" revision " << revend << " or " << revkindend
890
877
result.kind = svn_opt_revision_working;
891
878
} else if ( revkind == "BASE" ) {
892
879
result.kind = svn_opt_revision_base;
893
} else if ( !revkind.isNull() ) {
894
svn_opt_parse_revision(&result,&endrev,revkind.utf8(),pool);
880
} else if ( revkind == "HEAD" ) {
881
result.kind = svn_opt_revision_head;
882
} else if ( revkind == "COMMITTED" ) {
883
result.kind = svn_opt_revision_committed;
884
} else if ( revkind == "PREV" ) {
885
result.kind = svn_opt_revision_previous;
888
else if ( !revkind.isNull() ) {
889
svn_opt_parse_revision(&result,&endrev,revkind.toUtf8(),pool);
891
result.kind = svn_opt_revision_unspecified;
899
void kio_svnProtocol::svn_diff(const KURL & url1, const KURL& url2,int rev1, int rev2,const QString& revkind1,const QString& revkind2,bool recurse) {
900
kdDebug(7128) << "kio_svn::diff : " << url1.path() << " at revision " << rev1 << " or " << revkind1 << " with "
896
void kio_svnProtocol::svn_diff(const KUrl & url1, const KUrl& url2,int rev1, int rev2,const QString& revkind1,const QString& revkind2,bool recurse) {
897
kDebug(7128) << "kio_svn::diff : " << url1.path() << " at revision " << rev1 << " or " << revkind1 << " with "
901
898
<< url2.path() << " at revision " << rev2 << " or " << revkind2
904
901
apr_pool_t *subpool = svn_pool_create (pool);
905
apr_array_header_t *options = svn_cstring_split( "", "\t\r\n", TRUE, subpool );
902
apr_array_header_t *options = svn_cstring_split( "", "\t\r\n", true, subpool );
909
906
nurl1.setProtocol( chooseProtocol( url1.protocol() ) ); //svn+https -> https for eg
910
907
nurl2.setProtocol( chooseProtocol( url2.protocol() ) );
911
908
recordCurrentURL( nurl1 );
912
909
QString source = makeSvnURL( nurl1 );
913
910
QString target = makeSvnURL( nurl2 );
915
const char *path1 = svn_path_canonicalize( apr_pstrdup( subpool, source.utf8() ), subpool );
916
const char *path2 = svn_path_canonicalize( apr_pstrdup( subpool, target.utf8() ), subpool );
912
const char *path1 = svn_path_canonicalize( apr_pstrdup( subpool, source.toUtf8() ), subpool );
913
const char *path2 = svn_path_canonicalize( apr_pstrdup( subpool, target.toUtf8() ), subpool );
917
914
//remove file:/// so we can diff for working copies, needs a better check (so we support URL for file:/// _repositories_ )
918
915
if ( nurl1.protocol() == "file" ) {
919
path1 = svn_path_canonicalize( apr_pstrdup( subpool, nurl1.path().utf8() ), subpool );
916
path1 = svn_path_canonicalize( apr_pstrdup( subpool, nurl1.path().toUtf8() ), subpool );
921
918
if ( nurl2.protocol() == "file" ) {
922
path2 = svn_path_canonicalize( apr_pstrdup( subpool, nurl2.path().utf8() ), subpool );
919
path2 = svn_path_canonicalize( apr_pstrdup( subpool, nurl2.path().toUtf8() ), subpool );
924
kdDebug( 7128 ) << "1 : " << path1 << " 2: " << path2 << endl;
921
kDebug( 7128 ) << "1 : " << path1 << " 2: " << path2;
926
923
svn_opt_revision_t revision1,revision2;
927
924
revision1 = createRevision(rev1, revkind1, subpool);
960
957
svn_pool_destroy (subpool);
963
void kio_svnProtocol::svn_switch( const KURL& wc, const KURL& repos, int revnumber, const QString& revkind, bool recurse) {
964
kdDebug(7128) << "kio_svn::switch : " << wc.path() << " at revision " << revnumber << " or " << revkind << endl ;
960
void kio_svnProtocol::svn_switch( const KUrl& wc, const KUrl& repos, int revnumber, const QString& revkind, bool recurse) {
961
kDebug(7128) << "kio_svn::switch : " << wc.path() << " at revision " << revnumber << " or " << revkind;
966
963
apr_pool_t *subpool = svn_pool_create (pool);
970
967
nurl.setProtocol( chooseProtocol( repos.protocol() ) );
971
968
dest.setProtocol( "file" );
972
969
recordCurrentURL( nurl );
973
970
QString source = dest.path();
974
971
QString target = makeSvnURL( repos );
976
const char *path = svn_path_canonicalize( apr_pstrdup( subpool, source.utf8() ), subpool );
977
const char *url = svn_path_canonicalize( apr_pstrdup( subpool, target.utf8() ), subpool );
973
const char *path = svn_path_canonicalize( apr_pstrdup( subpool, source.toUtf8() ), subpool );
974
const char *url = svn_path_canonicalize( apr_pstrdup( subpool, target.toUtf8() ), subpool );
979
976
svn_opt_revision_t rev = createRevision( revnumber, revkind, subpool );
981
978
initNotifier(false, false, false, subpool);
982
979
svn_error_t *err = svn_client_switch (NULL/*result revision*/, path, url, &rev, recurse, ctx, subpool);
987
984
svn_pool_destroy (subpool);
990
void kio_svnProtocol::update( const KURL& wc, int revnumber, const QString& revkind ) {
991
kdDebug(7128) << "kio_svn::update : " << wc.path() << " at revision " << revnumber << " or " << revkind << endl ;
987
void kio_svnProtocol::update( const KUrl& wc, int revnumber, const QString& revkind ) {
988
kDebug(7128) << "kio_svn::update : " << wc.path() << " at revision " << revnumber << " or " << revkind;
993
990
apr_pool_t *subpool = svn_pool_create (pool);
995
992
dest.setProtocol( "file" );
996
993
QString target = dest.path();
997
994
recordCurrentURL( dest );
999
996
svn_opt_revision_t rev = createRevision( revnumber, revkind, subpool );
1001
998
initNotifier(false, false, false, subpool);
1002
svn_error_t *err = svn_client_update (NULL, svn_path_canonicalize( target.utf8(), subpool ), &rev, true, ctx, subpool);
999
svn_error_t *err = svn_client_update (NULL, svn_path_canonicalize( target.toUtf8(), subpool ), &rev, true, ctx, subpool);
1004
1001
error( KIO::ERR_SLAVE_DEFINED, err->message );
1007
1004
svn_pool_destroy (subpool);
1010
void kio_svnProtocol::import( const KURL& repos, const KURL& wc ) {
1011
kdDebug(7128) << "kio_svnProtocol::import() : " << wc.url() << " into " << repos.url() << endl;
1007
void kio_svnProtocol::import( const KUrl& repos, const KUrl& wc ) {
1008
kDebug(7128) << "kio_svnProtocol::import() : " << wc.url() << " into " << repos.url();
1013
1010
apr_pool_t *subpool = svn_pool_create (pool);
1014
1011
svn_client_commit_info_t *commit_info = NULL;
1015
1012
bool nonrecursive = false;
1019
1016
nurl.setProtocol( chooseProtocol( repos.protocol() ) );
1020
1017
dest.setProtocol( "file" );
1021
1018
recordCurrentURL( nurl );
1022
dest.cleanPath( true ); // remove doubled '/'
1023
QString source = dest.path(-1);
1019
dest.cleanPath( KUrl::SimplifyDirSeparators ); // remove doubled '/'
1020
QString source = dest.path( KUrl::RemoveTrailingSlash );
1024
1021
QString target = makeSvnURL( repos );
1026
const char *path = svn_path_canonicalize( apr_pstrdup( subpool, source.utf8() ), subpool );
1027
const char *url = svn_path_canonicalize( apr_pstrdup( subpool, target.utf8() ), subpool );
1023
const char *path = svn_path_canonicalize( apr_pstrdup( subpool, source.toUtf8() ), subpool );
1024
const char *url = svn_path_canonicalize( apr_pstrdup( subpool, target.toUtf8() ), subpool );
1029
1026
initNotifier(false, false, false, subpool);
1030
1027
svn_error_t *err = svn_client_import(&commit_info,path,url,nonrecursive,ctx,subpool);
1032
1029
error( KIO::ERR_SLAVE_DEFINED, err->message );
1035
1032
svn_pool_destroy (subpool);
1038
void kio_svnProtocol::checkout( const KURL& repos, const KURL& wc, int revnumber, const QString& revkind ) {
1039
kdDebug(7128) << "kio_svn::checkout : " << repos.url() << " into " << wc.path() << " at revision " << revnumber << " or " << revkind << endl ;
1035
void kio_svnProtocol::checkout( const KUrl& repos, const KUrl& wc, int revnumber, const QString& revkind ) {
1036
kDebug(7128) << "kio_svn::checkout : " << repos.url() << " into " << wc.path() << " at revision " << revnumber << " or " << revkind;
1041
1038
apr_pool_t *subpool = svn_pool_create (pool);
1044
1041
nurl.setProtocol( chooseProtocol( repos.protocol() ) );
1045
1042
dest.setProtocol( "file" );
1046
1043
QString target = makeSvnURL( repos );
1047
1044
recordCurrentURL( nurl );
1048
1045
QString dpath = dest.path();
1050
1047
//find the requested revision
1051
1048
svn_opt_revision_t rev = createRevision( revnumber, revkind, subpool );
1053
1050
initNotifier(true, false, false, subpool);
1054
svn_error_t *err = svn_client_checkout (NULL/* rev actually checkedout */, svn_path_canonicalize( target.utf8(), subpool ), svn_path_canonicalize ( dpath.utf8(), subpool ), &rev, true, ctx, subpool);
1051
svn_error_t *err = svn_client_checkout (NULL/* rev actually checkedout */, svn_path_canonicalize( target.toUtf8(), subpool ), svn_path_canonicalize ( dpath.toUtf8(), subpool ), &rev, true, ctx, subpool);
1056
1053
error( KIO::ERR_SLAVE_DEFINED, err->message );
1081
1078
error( KIO::ERR_SLAVE_DEFINED, err->message );
1083
1080
if ( commit_info ) {
1084
for ( QValueListConstIterator<KURL> it = wc.begin(); it != wc.end() ; ++it ) {
1081
for ( QList<KUrl>::const_iterator it = wc.begin(); it != wc.end() ; ++it ) {
1086
1083
nurl.setProtocol( "file" );
1088
1085
QString userstring = i18n ( "Nothing to commit." );
1089
1086
if ( SVN_IS_VALID_REVNUM( commit_info->revision ) )
1090
userstring = i18n( "Committed revision %1." ).arg(commit_info->revision);
1091
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "path", nurl.path() );
1092
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "action", "0" );
1093
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "kind", "0" );
1094
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "mime_t", "" );
1095
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "content", "0" );
1096
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "prop", "0" );
1097
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "rev" , QString::number( commit_info->revision ) );
1098
setMetaData(QString::number( m_counter ).rightJustify( 10,'0' )+ "string", userstring );
1087
userstring = i18n( "Committed revision %1." , commit_info->revision);
1088
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "path", nurl.path() );
1089
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "action", "0" );
1090
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "kind", "0" );
1091
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "mime_t", "" );
1092
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "content", "0" );
1093
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "prop", "0" );
1094
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "rev" , QString::number( commit_info->revision ) );
1095
setMetaData(QString::number( m_counter ).rightJustified( 10,'0' )+ "string", userstring );
1104
1101
svn_pool_destroy (subpool);
1107
void kio_svnProtocol::add(const KURL& wc) {
1108
kdDebug(7128) << "kio_svnProtocol::add() : " << wc.url() << endl;
1104
void kio_svnProtocol::add(const KUrl& wc) {
1105
kDebug(7128) << "kio_svnProtocol::add() : " << wc.url();
1110
1107
apr_pool_t *subpool = svn_pool_create (pool);
1111
1108
bool nonrecursive = false;
1114
1111
nurl.setProtocol( "file" );
1115
1112
QString target = nurl.url();
1116
1113
recordCurrentURL( nurl );
1118
1115
initNotifier(false, false, false, subpool);
1119
svn_error_t *err = svn_client_add(svn_path_canonicalize( nurl.path().utf8(), subpool ),nonrecursive,ctx,subpool);
1116
svn_error_t *err = svn_client_add(svn_path_canonicalize( nurl.path().toUtf8(), subpool ),nonrecursive,ctx,subpool);
1121
1118
error( KIO::ERR_SLAVE_DEFINED, err->message );
1124
1121
svn_pool_destroy (subpool);
1127
void kio_svnProtocol::wc_delete(const KURL::List& wc) {
1128
kdDebug(7128) << "kio_svnProtocol::wc_delete() : " << wc << endl;
1124
void kio_svnProtocol::wc_delete(const KUrl::List& wc) {
1125
kDebug(7128) << "kio_svnProtocol::wc_delete() : " << wc;
1130
1127
apr_pool_t *subpool = svn_pool_create (pool);
1131
1128
svn_client_commit_info_t *commit_info = NULL;
1132
1129
bool nonrecursive = false;
1134
1131
apr_array_header_t *targets = apr_array_make(subpool, 1+wc.count(), sizeof(const char *));
1136
for ( QValueListConstIterator<KURL> it = wc.begin(); it != wc.end() ; ++it ) {
1133
for ( QList<KUrl>::const_iterator it = wc.begin(); it != wc.end() ; ++it ) {
1138
1135
nurl.setProtocol( "file" );
1139
1136
recordCurrentURL( nurl );
1140
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = svn_path_canonicalize( nurl.path().utf8(), subpool );
1137
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = svn_path_canonicalize( nurl.path().toUtf8(), subpool );
1143
1140
initNotifier(false, false, false, subpool);
1147
1144
error( KIO::ERR_SLAVE_DEFINED, err->message );
1150
1147
svn_pool_destroy (subpool);
1153
void kio_svnProtocol::wc_revert(const KURL::List& wc) {
1154
kdDebug(7128) << "kio_svnProtocol::revert() : " << wc << endl;
1150
void kio_svnProtocol::wc_revert(const KUrl::List& wc) {
1151
kDebug(7128) << "kio_svnProtocol::revert() : " << wc;
1156
1153
apr_pool_t *subpool = svn_pool_create (pool);
1157
1154
bool nonrecursive = false;
1159
1156
apr_array_header_t *targets = apr_array_make(subpool, 1 + wc.count(), sizeof(const char *));
1161
for ( QValueListConstIterator<KURL> it = wc.begin(); it != wc.end() ; ++it ) {
1158
for ( QList<KUrl>::const_iterator it = wc.begin(); it != wc.end() ; ++it ) {
1163
1160
nurl.setProtocol( "file" );
1164
1161
recordCurrentURL( nurl );
1165
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = svn_path_canonicalize( nurl.path().utf8(), subpool );
1162
(*(( const char ** )apr_array_push(( apr_array_header_t* )targets)) ) = svn_path_canonicalize( nurl.path().toUtf8(), subpool );
1168
1165
initNotifier(false, false, false, subpool);
1169
1166
svn_error_t *err = svn_client_revert(targets,nonrecursive,ctx,subpool);
1171
1168
error( KIO::ERR_SLAVE_DEFINED, err->message );
1174
1171
svn_pool_destroy (subpool);
1177
void kio_svnProtocol::wc_status(const KURL& wc, bool checkRepos, bool fullRecurse, bool getAll, int revnumber, const QString& revkind) {
1178
kdDebug(7128) << "kio_svnProtocol::status() : " << wc.url() << endl;
1174
void kio_svnProtocol::wc_status(const KUrl& wc, bool checkRepos, bool fullRecurse, bool getAll, int revnumber, const QString& revkind) {
1175
kDebug(7128) << "kio_svnProtocol::status() : " << wc.url();
1180
1177
apr_pool_t *subpool = svn_pool_create (pool);
1181
1178
svn_revnum_t result_rev;
1182
bool no_ignore = FALSE;
1179
bool no_ignore = false;
1185
1182
nurl.setProtocol( "file" );
1186
1183
recordCurrentURL( nurl );
1188
1185
svn_opt_revision_t rev = createRevision( revnumber, revkind, subpool );
1190
1187
initNotifier(false, false, false, subpool);
1192
svn_error_t *err = svn_client_status(&result_rev, svn_path_canonicalize( nurl.path().utf8(), subpool ), &rev, kio_svnProtocol::status, this, fullRecurse, getAll, checkRepos, no_ignore, ctx, subpool);
1188
svn_error_t *err = svn_client_status(&result_rev, svn_path_canonicalize( nurl.path().toUtf8(), subpool ), &rev, kio_svnProtocol::status, this, fullRecurse, getAll, checkRepos, no_ignore, ctx, subpool);
1195
1190
error( KIO::ERR_SLAVE_DEFINED, err->message );
1198
1193
svn_pool_destroy (subpool);
1201
1196
//change the proto and remove trailing /
1202
//remove double / also
1203
QString kio_svnProtocol::makeSvnURL ( const KURL& url ) const {
1197
//remove double / also
1198
QString kio_svnProtocol::makeSvnURL ( const KUrl& url ) const {
1204
1199
QString kproto = url.protocol();
1206
tpURL.cleanPath( true );
1201
tpURL.cleanPath( KUrl::SimplifyDirSeparators );
1207
1202
QString svnUrl;
1208
1203
if ( kproto == "svn+http" ) {
1209
kdDebug(7128) << "http:/ " << url.url() << endl;
1204
kDebug(7128) << "http:/ " << url.url();
1210
1205
tpURL.setProtocol("http");
1211
svnUrl = tpURL.url(-1);
1206
svnUrl = tpURL.url( KUrl::RemoveTrailingSlash );
1214
1209
else if ( kproto == "svn+https" ) {
1215
kdDebug(7128) << "https:/ " << url.url() << endl;
1210
kDebug(7128) << "https:/ " << url.url();
1216
1211
tpURL.setProtocol("https");
1217
svnUrl = tpURL.url(-1);
1212
svnUrl = tpURL.url( KUrl::RemoveTrailingSlash );
1220
1215
else if ( kproto == "svn+ssh" ) {
1221
kdDebug(7128) << "svn+ssh:/ " << url.url() << endl;
1216
kDebug(7128) << "svn+ssh:/ " << url.url();
1222
1217
tpURL.setProtocol("svn+ssh");
1223
svnUrl = tpURL.url(-1);
1218
svnUrl = tpURL.url( KUrl::RemoveTrailingSlash );
1226
1221
else if ( kproto == "svn" ) {
1227
kdDebug(7128) << "svn:/ " << url.url() << endl;
1222
kDebug(7128) << "svn:/ " << url.url();
1228
1223
tpURL.setProtocol("svn");
1229
svnUrl = tpURL.url(-1);
1224
svnUrl = tpURL.url( KUrl::RemoveTrailingSlash );
1232
1227
else if ( kproto == "svn+file" ) {
1233
kdDebug(7128) << "file:/ " << url.url() << endl;
1228
kDebug(7128) << "file:/ " << url.url();
1234
1229
tpURL.setProtocol("file");
1235
svnUrl = tpURL.url(-1);
1230
svnUrl = tpURL.url( KUrl::RemoveTrailingSlash );
1236
1231
//hack : add one more / after file:/
1237
int idx = svnUrl.find("/");
1232
int idx = svnUrl.indexOf('/');
1238
1233
svnUrl.insert( idx, "//" );
1241
return tpURL.url(-1);
1236
return tpURL.url( KUrl::RemoveTrailingSlash );
1244
1239
QString kio_svnProtocol::chooseProtocol ( const QString& kproto ) const {
1308
1300
list += prop_mod;
1311
kdDebug(7128) << " Commiting items : " << list << endl;
1303
kDebug(7128) << " Committing items : " << list;
1315
QDataStream stream(params, IO_WriteOnly);
1316
stream << slist.join("\n");
1318
if ( !p->dcopClient()->call( "kded","ksvnd","commitDialog(QString)", params, replyType, reply ) ) {
1319
kdWarning() << "Communication with KDED:KSvnd failed" << endl;
1320
return SVN_NO_ERROR;
1323
if ( replyType != "QString" ) {
1324
kdWarning() << "Unexpected reply type" << endl;
1325
return SVN_NO_ERROR;
1328
QDataStream stream2 ( reply, IO_ReadOnly );
1306
OrgKdeKsvndInterface ksvndInterface( "org.kde.kded", "/modules/ksvnd", QDBusConnection::sessionBus() );
1307
if(!ksvndInterface.isValid())
1309
kWarning() << "Communication with KDED:KSvnd failed";
1310
return SVN_NO_ERROR;
1313
QString lst = slist.join("\n");
1314
QDBusReply<QString> reply = ksvndInterface.commitDialog(lst);
1315
if ( !reply.isValid() )
1317
kWarning() << "Unexpected reply type";
1318
return SVN_NO_ERROR;
1331
1321
if ( result.isNull() ) { //cancelled
1332
1322
*log_msg = NULL;
1333
1323
return SVN_NO_ERROR;
1336
message = svn_stringbuf_create( result.utf8(), pool );
1325
message = svn_stringbuf_create( result.toUtf8(), pool );
1337
1326
*log_msg = message->data;
1339
1327
return SVN_NO_ERROR;
1342
1330
void kio_svnProtocol::notify(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) {
1343
kdDebug(7128) << "NOTIFY : " << path << " updated at revision " << revision << " action : " << action << ", kind : " << kind << " , content_state : " << content_state << ", prop_state : " << prop_state << endl;
1331
kDebug(7128) << "NOTIFY : " << path << " updated at revision " << revision << " action : " << action << ", kind : " << kind << " , content_state : " << content_state << ", prop_state : " << prop_state;
1345
1333
QString userstring;
1346
1334
struct notify_baton *nb = ( struct notify_baton* ) baton;
1349
1337
switch ( action ) {
1350
1338
case svn_wc_notify_add : //add
1351
1339
if (mime_type && (svn_mime_type_is_binary (mime_type)))
1352
userstring = i18n( "A (bin) %1" ).arg( path );
1340
userstring = i18n( "A (bin) %1", path );
1354
userstring = i18n( "A %1" ).arg( path );
1342
userstring = i18n( "A %1", path );
1356
1344
case svn_wc_notify_copy: //copy
1358
1346
case svn_wc_notify_delete: //delete
1359
nb->received_some_change = TRUE;
1360
userstring = i18n( "D %1" ).arg( path );
1347
nb->received_some_change = true;
1348
userstring = i18n( "D %1", path );
1362
1350
case svn_wc_notify_restore : //restore
1363
userstring=i18n( "Restored %1." ).arg( path );
1351
userstring=i18n( "Restored %1.", path );
1365
1353
case svn_wc_notify_revert : //revert
1366
userstring=i18n( "Reverted %1." ).arg( path );
1354
userstring=i18n( "Reverted %1.", path );
1368
1356
case svn_wc_notify_failed_revert: //failed revert
1369
userstring=i18n( "Failed to revert %1.\nTry updating instead." ).arg( path );
1357
userstring=i18n( "Failed to revert %1.\nTry updating instead.", path );
1371
1359
case svn_wc_notify_resolved: //resolved
1372
userstring=i18n( "Resolved conflicted state of %1." ).arg( path );
1360
userstring=i18n( "Resolved conflicted state of %1.", path );
1374
1362
case svn_wc_notify_skip: //skip
1375
1363
if ( content_state == svn_wc_notify_state_missing )
1376
userstring=i18n("Skipped missing target %1.").arg( path );
1378
userstring=i18n("Skipped %1.").arg( path );
1364
userstring=i18n("Skipped missing target %1.", path );
1366
userstring=i18n("Skipped %1.", path );
1380
1368
case svn_wc_notify_update_delete: //update_delete
1381
nb->received_some_change = TRUE;
1382
userstring=i18n( "D %1" ).arg( path );
1369
nb->received_some_change = true;
1370
userstring=i18n( "D %1", path );
1384
1372
case svn_wc_notify_update_add: //update_add
1385
nb->received_some_change = TRUE;
1386
userstring=i18n( "A %1" ).arg( path );
1373
nb->received_some_change = true;
1374
userstring=i18n( "A %1", path );
1388
1376
case svn_wc_notify_update_update: //update_update
1472
1460
if (nb->in_external)
1473
nb->in_external = FALSE;
1461
nb->in_external = false;
1475
1463
case svn_wc_notify_update_external: //update_external
1476
nb->in_external = TRUE;
1477
userstring = i18n("Fetching external item into %1." ).arg( path );
1464
nb->in_external = true;
1465
userstring = i18n("Fetching external item into %1.", path );
1479
1467
case svn_wc_notify_status_completed: //status_completed
1480
1468
if (SVN_IS_VALID_REVNUM (revision))
1481
userstring = i18n( "Status against revision: %1.").arg( revision );
1469
userstring = i18n( "Status against revision: %1.", revision );
1483
1471
case svn_wc_notify_status_external: //status_external
1484
userstring = i18n("Performing status on external item at %1.").arg( path );
1472
userstring = i18n("Performing status on external item at %1.", path );
1486
1474
case svn_wc_notify_commit_modified: //commit_modified
1487
userstring = i18n( "Sending %1").arg( path );
1475
userstring = i18n( "Sending %1", path );
1489
1477
case svn_wc_notify_commit_added: //commit_added
1490
1478
if (mime_type && svn_mime_type_is_binary (mime_type)) {
1491
userstring = i18n( "Adding (bin) %1.").arg( path );
1479
userstring = i18n( "Adding (bin) %1.", path );
1493
userstring = i18n( "Adding %1.").arg( path );
1481
userstring = i18n( "Adding %1.", path );
1496
1484
case svn_wc_notify_commit_deleted: //commit_deleted
1497
userstring = i18n( "Deleting %1.").arg( path );
1485
userstring = i18n( "Deleting %1.", path );
1499
1487
case svn_wc_notify_commit_replaced: //commit_replaced
1500
userstring = i18n( "Replacing %1.").arg( path );
1488
userstring = i18n( "Replacing %1.", path );
1502
1490
case svn_wc_notify_commit_postfix_txdelta: //commit_postfix_txdelta
1503
1491
if (! nb->sent_first_txdelta) {
1504
nb->sent_first_txdelta = TRUE;
1492
nb->sent_first_txdelta = true;
1505
1493
userstring=i18n("Transmitting file data ");
1507
1495
userstring=".";
1519
1507
kio_svnProtocol *p = ( kio_svnProtocol* )nb->master;
1521
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "path" , QString::fromUtf8( path ));
1522
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "action", QString::number( action ));
1523
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "kind", QString::number( kind ));
1524
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "mime_t", QString::fromUtf8( mime_type ));
1525
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "content", QString::number( content_state ));
1526
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "prop", QString::number( prop_state ));
1527
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "rev", QString::number( revision ));
1528
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "string", userstring );
1509
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "path" , QString::fromUtf8( path ));
1510
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "action", QString::number( action ));
1511
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "kind", QString::number( kind ));
1512
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "mime_t", QString::fromUtf8( mime_type ));
1513
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "content", QString::number( content_state ));
1514
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "prop", QString::number( prop_state ));
1515
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "rev", QString::number( revision ));
1516
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "string", userstring );
1529
1517
p->incCounter();
1532
1520
void kio_svnProtocol::status(void *baton, const char *path, svn_wc_status_t *status) {
1533
kdDebug(7128) << "STATUS : " << path << ", wc text status : " << status->text_status
1521
kDebug(7128) << "STATUS : " << path << ", wc text status : " << status->text_status
1534
1522
<< ", wc prop status : " << status->prop_status
1535
1523
<< ", repos text status : " << status->repos_text_status
1536
<< ", repos prop status : " << status->repos_prop_status
1524
<< ", repos prop status : " << status->repos_prop_status
1539
1527
QByteArray params;
1540
1528
kio_svnProtocol *p = ( kio_svnProtocol* )baton;
1542
QDataStream stream(params, IO_WriteOnly);
1530
QDataStream stream(¶ms, QIODevice::WriteOnly);
1543
1531
long int rev = status->entry ? status->entry->revision : 0;
1544
stream << QString::fromUtf8( path ) << status->text_status << status->prop_status << status->repos_text_status << status->repos_prop_status << rev;
1532
stream << QString::fromUtf8( path ) << QString::number( status->text_status ) << QString::number( status->prop_status ) << QString::number( status->repos_text_status ) << QString::number( status->repos_prop_status ) << QString::number( rev );
1546
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "path", QString::fromUtf8( path ));
1547
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "text", QString::number( status->text_status ));
1548
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "prop", QString::number( status->prop_status ));
1549
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "reptxt", QString::number( status->repos_text_status ));
1550
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "repprop", QString::number( status->repos_prop_status ));
1551
p->setMetaData(QString::number( p->counter() ).rightJustify( 10,'0' )+ "rev", QString::number( rev ));
1534
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "path", QString::fromUtf8( path ));
1535
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "text", QString::number( status->text_status ));
1536
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "prop", QString::number( status->prop_status ));
1537
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "reptxt", QString::number( status->repos_text_status ));
1538
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "repprop", QString::number( status->repos_prop_status ));
1539
p->setMetaData(QString::number( p->counter() ).rightJustified( 10,'0' )+ "rev", QString::number( rev ));
1552
1540
p->incCounter();
1556
void kio_svnProtocol::wc_resolve( const KURL& wc, bool recurse ) {
1557
kdDebug(7128) << "kio_svnProtocol::wc_resolve() : " << wc.url() << endl;
1544
void kio_svnProtocol::wc_resolve( const KUrl& wc, bool recurse ) {
1545
kDebug(7128) << "kio_svnProtocol::wc_resolve() : " << wc.url();
1559
1547
apr_pool_t *subpool = svn_pool_create (pool);
1562
1550
nurl.setProtocol( "file" );
1563
1551
recordCurrentURL( nurl );
1565
1553
initNotifier(false, false, false, subpool);
1566
svn_error_t *err = svn_client_resolved(svn_path_canonicalize( nurl.path().utf8(), subpool ), recurse,ctx,subpool);
1554
svn_error_t *err = svn_client_resolved(svn_path_canonicalize( nurl.path().toUtf8(), subpool ), recurse,ctx,subpool);
1568
1556
error( KIO::ERR_SLAVE_DEFINED, err->message );
1571
1559
svn_pool_destroy (subpool);