Changeset View
Changeset View
Standalone View
Standalone View
src/kiosvn/kiosvn.cpp
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 201 | { | |||
---|---|---|---|---|---|
204 | svn::DirEntries dlist; | 204 | svn::DirEntries dlist; | ||
205 | svn::Revision rev = m_pData->urlToRev(url); | 205 | svn::Revision rev = m_pData->urlToRev(url); | ||
206 | if (rev == svn::Revision::UNDEFINED) { | 206 | if (rev == svn::Revision::UNDEFINED) { | ||
207 | rev = svn::Revision::HEAD; | 207 | rev = svn::Revision::HEAD; | ||
208 | } | 208 | } | ||
209 | 209 | | |||
210 | try { | 210 | try { | ||
211 | // we ignoring the result 'cause it is done via kiolistener for a smoother insert of items. | 211 | // we ignoring the result 'cause it is done via kiolistener for a smoother insert of items. | ||
212 | dlist = m_pData->m_Svnclient->list(makeSvnUrl(url), rev, rev, svn::DepthImmediates, false); | 212 | dlist = m_pData->m_Svnclient->list(makeSvnPath(url), rev, rev, svn::DepthImmediates, false); | ||
213 | } catch (const svn::ClientException &e) { | 213 | } catch (const svn::ClientException &e) { | ||
214 | QString ex = e.msg(); | 214 | QString ex = e.msg(); | ||
215 | qCDebug(KDESVN_LOG) << ex << endl; | 215 | qCDebug(KDESVN_LOG) << ex << endl; | ||
216 | extraError(KIO::ERR_SLAVE_DEFINED, ex); | 216 | extraError(KIO::ERR_SLAVE_DEFINED, ex); | ||
217 | return; | 217 | return; | ||
218 | } | 218 | } | ||
219 | finished(); | 219 | finished(); | ||
220 | qCDebug(KDESVN_LOG) << "Listing finished" << endl; | 220 | qCDebug(KDESVN_LOG) << "Listing finished" << endl; | ||
221 | } | 221 | } | ||
222 | 222 | | |||
223 | void kio_svnProtocol::stat(const QUrl &url) | 223 | void kio_svnProtocol::stat(const QUrl &url) | ||
224 | { | 224 | { | ||
225 | qCDebug(KDESVN_LOG) << "kio_svn::stat " << url << endl; | 225 | qCDebug(KDESVN_LOG) << "kio_svn::stat " << url << endl; | ||
226 | m_pData->resetListener(); | 226 | m_pData->resetListener(); | ||
227 | svn::Revision rev = m_pData->urlToRev(url); | 227 | svn::Revision rev = m_pData->urlToRev(url); | ||
228 | if (rev == svn::Revision::UNDEFINED) { | 228 | if (rev == svn::Revision::UNDEFINED) { | ||
229 | rev = svn::Revision::HEAD; | 229 | rev = svn::Revision::HEAD; | ||
230 | } | 230 | } | ||
231 | svn::Revision peg = rev; | 231 | svn::Revision peg = rev; | ||
232 | bool dummy = false; | 232 | bool dummy = false; | ||
233 | svn::InfoEntries e; | 233 | svn::InfoEntries e; | ||
234 | try { | 234 | try { | ||
235 | e = m_pData->m_Svnclient->info(makeSvnUrl(url), svn::DepthEmpty, rev, peg); | 235 | e = m_pData->m_Svnclient->info(makeSvnPath(url), svn::DepthEmpty, rev, peg); | ||
236 | } catch (const svn::ClientException &e) { | 236 | } catch (const svn::ClientException &e) { | ||
237 | QString ex = e.msg(); | 237 | QString ex = e.msg(); | ||
238 | qCDebug(KDESVN_LOG) << ex << endl; | 238 | qCDebug(KDESVN_LOG) << ex << endl; | ||
239 | extraError(KIO::ERR_SLAVE_DEFINED, ex); | 239 | extraError(KIO::ERR_SLAVE_DEFINED, ex); | ||
240 | return; | 240 | return; | ||
241 | } | 241 | } | ||
242 | 242 | | |||
243 | if (e.isEmpty()) { | 243 | if (e.isEmpty()) { | ||
Show All 22 Lines | 264 | if (m_pData->m_Listener.contextCancel()) { | |||
266 | return; | 266 | return; | ||
267 | } | 267 | } | ||
268 | svn::Revision rev = m_pData->urlToRev(url); | 268 | svn::Revision rev = m_pData->urlToRev(url); | ||
269 | if (rev == svn::Revision::UNDEFINED) { | 269 | if (rev == svn::Revision::UNDEFINED) { | ||
270 | rev = svn::Revision::HEAD; | 270 | rev = svn::Revision::HEAD; | ||
271 | } | 271 | } | ||
272 | KioByteStream dstream(this, url.fileName()); | 272 | KioByteStream dstream(this, url.fileName()); | ||
273 | try { | 273 | try { | ||
274 | QUrl _url = makeSvnUrl(url); | 274 | const svn::Path path = makeSvnPath(url); | ||
275 | svn::InfoEntries e; | 275 | svn::InfoEntries e; | ||
276 | e = m_pData->m_Svnclient->info(_url, svn::DepthEmpty, rev, rev); | 276 | e = m_pData->m_Svnclient->info(path, svn::DepthEmpty, rev, rev); | ||
277 | if (!e.isEmpty()) { | 277 | if (!e.isEmpty()) { | ||
278 | totalSize(e.at(0).size()); | 278 | totalSize(e.at(0).size()); | ||
279 | } | 279 | } | ||
280 | m_pData->m_Svnclient->cat(dstream, _url, rev, rev); | 280 | m_pData->m_Svnclient->cat(dstream, path, rev, rev); | ||
281 | } catch (const svn::ClientException &e) { | 281 | } catch (const svn::ClientException &e) { | ||
282 | QString ex = e.msg(); | 282 | QString ex = e.msg(); | ||
283 | // dolphin / Konqueror try to get the content without check if it is a folder when listing a folder | 283 | // dolphin / Konqueror try to get the content without check if it is a folder when listing a folder | ||
284 | // which results in a lot of error messages via kio notify | 284 | // which results in a lot of error messages via kio notify | ||
285 | if (e.apr_err() != SVN_ERR_CLIENT_IS_DIRECTORY) { | 285 | if (e.apr_err() != SVN_ERR_CLIENT_IS_DIRECTORY) { | ||
286 | extraError(KIO::ERR_SLAVE_DEFINED, QStringLiteral("Subversion error ") + ex); | 286 | extraError(KIO::ERR_SLAVE_DEFINED, QStringLiteral("Subversion error ") + ex); | ||
287 | } | 287 | } | ||
288 | return; | 288 | return; | ||
Show All 11 Lines | 299 | if (rev == svn::Revision::UNDEFINED) { | |||
300 | rev = svn::Revision::HEAD; | 300 | rev = svn::Revision::HEAD; | ||
301 | } | 301 | } | ||
302 | if (rev != svn::Revision::HEAD) { | 302 | if (rev != svn::Revision::HEAD) { | ||
303 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | 303 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | ||
304 | return; | 304 | return; | ||
305 | } | 305 | } | ||
306 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | 306 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | ||
307 | try { | 307 | try { | ||
308 | svn::Path p(makeSvnUrl(url)); | 308 | m_pData->m_Svnclient->mkdir(makeSvnPath(url), getDefaultLog()); | ||
309 | m_pData->m_Svnclient->mkdir(p, getDefaultLog()); | | |||
310 | } catch (const svn::ClientException &e) { | 309 | } catch (const svn::ClientException &e) { | ||
311 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 310 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
312 | return; | 311 | return; | ||
313 | } | 312 | } | ||
314 | finished(); | 313 | finished(); | ||
315 | } | 314 | } | ||
316 | 315 | | |||
317 | void kio_svnProtocol::mkdir(const QList<QUrl> &urls, int) | 316 | void kio_svnProtocol::mkdir(const QList<QUrl> &urls, int) | ||
Show All 10 Lines | |||||
328 | void kio_svnProtocol::rename(const QUrl &src, const QUrl &target, KIO::JobFlags flags) | 327 | void kio_svnProtocol::rename(const QUrl &src, const QUrl &target, KIO::JobFlags flags) | ||
329 | { | 328 | { | ||
330 | qCDebug(KDESVN_LOG) << "kio_svn::rename " << src << " to " << target << endl; | 329 | qCDebug(KDESVN_LOG) << "kio_svn::rename " << src << " to " << target << endl; | ||
331 | m_pData->resetListener(); | 330 | m_pData->resetListener(); | ||
332 | Q_UNUSED(flags); | 331 | Q_UNUSED(flags); | ||
333 | //bool force = flags&KIO::Overwrite; | 332 | //bool force = flags&KIO::Overwrite; | ||
334 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | 333 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | ||
335 | try { | 334 | try { | ||
336 | m_pData->m_Svnclient->move(svn::CopyParameter(svn::Path(makeSvnUrl(src)), makeSvnUrl(target))); | 335 | m_pData->m_Svnclient->move(svn::CopyParameter(makeSvnPath(src), makeSvnPath(target))); | ||
337 | } catch (const svn::ClientException &e) { | 336 | } catch (const svn::ClientException &e) { | ||
338 | if (e.apr_err() == SVN_ERR_ENTRY_EXISTS) { | 337 | if (e.apr_err() == SVN_ERR_ENTRY_EXISTS) { | ||
339 | error(KIO::ERR_DIR_ALREADY_EXIST, e.msg()); | 338 | error(KIO::ERR_DIR_ALREADY_EXIST, e.msg()); | ||
340 | } else { | 339 | } else { | ||
341 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 340 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
342 | } | 341 | } | ||
343 | return; | 342 | return; | ||
344 | } | 343 | } | ||
Show All 12 Lines | 349 | { | |||
357 | if (rev != svn::Revision::HEAD) { | 356 | if (rev != svn::Revision::HEAD) { | ||
358 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | 357 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | ||
359 | return; | 358 | return; | ||
360 | } | 359 | } | ||
361 | svn::Revision peg = rev; | 360 | svn::Revision peg = rev; | ||
362 | svn::InfoEntries e; | 361 | svn::InfoEntries e; | ||
363 | bool exists = true; | 362 | bool exists = true; | ||
364 | try { | 363 | try { | ||
365 | e = m_pData->m_Svnclient->info(makeSvnUrl(url), svn::DepthEmpty, rev, peg); | 364 | e = m_pData->m_Svnclient->info(makeSvnPath(url), svn::DepthEmpty, rev, peg); | ||
366 | } catch (const svn::ClientException &e) { | 365 | } catch (const svn::ClientException &e) { | ||
367 | if (e.apr_err() == SVN_ERR_ENTRY_NOT_FOUND || e.apr_err() == SVN_ERR_RA_ILLEGAL_URL) { | 366 | if (e.apr_err() == SVN_ERR_ENTRY_NOT_FOUND || e.apr_err() == SVN_ERR_RA_ILLEGAL_URL) { | ||
368 | exists = false; | 367 | exists = false; | ||
369 | } else { | 368 | } else { | ||
370 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 369 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
371 | return; | 370 | return; | ||
372 | } | 371 | } | ||
373 | } | 372 | } | ||
374 | QSharedPointer<QFile> tmpfile; | 373 | QSharedPointer<QFile> tmpfile; | ||
375 | QSharedPointer<QTemporaryDir> _codir; | 374 | QSharedPointer<QTemporaryDir> _codir; | ||
376 | if (exists) { | 375 | if (exists) { | ||
377 | if (flags & KIO::Overwrite) { | 376 | if (flags & KIO::Overwrite) { | ||
378 | if (!supportOverwrite()) { | 377 | if (!supportOverwrite()) { | ||
379 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Overwriting existing items is disabled in settings.")); | 378 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Overwriting existing items is disabled in settings.")); | ||
380 | return; | 379 | return; | ||
381 | } | 380 | } | ||
382 | _codir = QSharedPointer<QTemporaryDir>(new QTemporaryDir); | 381 | _codir = QSharedPointer<QTemporaryDir>(new QTemporaryDir); | ||
383 | _codir->setAutoRemove(true); | 382 | _codir->setAutoRemove(true); | ||
384 | svn::Path path = makeSvnUrl(url); | 383 | svn::Path path = makeSvnPath(url); | ||
385 | path.removeLast(); | 384 | path.removeLast(); | ||
386 | try { | 385 | try { | ||
387 | notify(i18n("Start checking out to temporary folder")); | 386 | notify(i18n("Start checking out to temporary folder")); | ||
388 | m_pData->dispWritten = true; | 387 | m_pData->dispWritten = true; | ||
389 | registerToDaemon(); | 388 | registerToDaemon(); | ||
390 | startOp(-1, i18n("Checking out %1", path.native())); | 389 | startOp(-1, i18n("Checking out %1", path.native())); | ||
391 | svn::CheckoutParameter params; | 390 | svn::CheckoutParameter params; | ||
392 | params.moduleName(path).destination(svn::Path(_codir->path())).revision(rev).peg(peg).depth(svn::DepthFiles); | 391 | params.moduleName(path).destination(svn::Path(_codir->path())).revision(rev).peg(peg).depth(svn::DepthFiles); | ||
Show All 40 Lines | 431 | if (result != 0) { | |||
433 | error(KIO::ERR_ABORTED, i18n("Could not retrieve data for write.")); | 432 | error(KIO::ERR_ABORTED, i18n("Could not retrieve data for write.")); | ||
434 | return; | 433 | return; | ||
435 | } | 434 | } | ||
436 | 435 | | |||
437 | totalSize(processed_size); | 436 | totalSize(processed_size); | ||
438 | written(0); | 437 | written(0); | ||
439 | m_pData->dispWritten = true; | 438 | m_pData->dispWritten = true; | ||
440 | registerToDaemon(); | 439 | registerToDaemon(); | ||
441 | startOp(processed_size, i18n("Committing %1", makeSvnUrl(url).toDisplayString())); | 440 | startOp(processed_size, i18n("Committing %1", makeSvnPath(url).path())); | ||
442 | bool err = false; | 441 | bool err = false; | ||
443 | if (exists) { | 442 | if (exists) { | ||
444 | svn::CommitParameter commit_parameters; | 443 | svn::CommitParameter commit_parameters; | ||
445 | commit_parameters.targets(svn::Targets(tmpfile->fileName())).message(getDefaultLog()).depth(svn::DepthEmpty).keepLocks(false); | 444 | commit_parameters.targets(svn::Targets(tmpfile->fileName())).message(getDefaultLog()).depth(svn::DepthEmpty).keepLocks(false); | ||
446 | try { | 445 | try { | ||
447 | m_pData->m_Svnclient->commit(commit_parameters); | 446 | m_pData->m_Svnclient->commit(commit_parameters); | ||
448 | } catch (const svn::ClientException &e) { | 447 | } catch (const svn::ClientException &e) { | ||
449 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 448 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
450 | err = true; | 449 | err = true; | ||
451 | } | 450 | } | ||
452 | } else { | 451 | } else { | ||
453 | try { | 452 | try { | ||
454 | m_pData->m_Svnclient->import(tmpfile->fileName(), svn::Url(makeSvnUrl(url)), getDefaultLog(), svn::DepthEmpty, false, false); | 453 | m_pData->m_Svnclient->import(tmpfile->fileName(), svn::Url(makeSvnPath(url)), getDefaultLog(), svn::DepthEmpty, false, false); | ||
455 | } catch (const svn::ClientException &e) { | 454 | } catch (const svn::ClientException &e) { | ||
456 | QString ex = e.msg(); | 455 | QString ex = e.msg(); | ||
457 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 456 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
458 | err = true; | 457 | err = true; | ||
459 | stopOp(ex); | 458 | stopOp(ex); | ||
460 | } | 459 | } | ||
461 | } | 460 | } | ||
462 | m_pData->dispWritten = false; | 461 | m_pData->dispWritten = false; | ||
Show All 12 Lines | 469 | { | |||
475 | qCDebug(KDESVN_LOG) << "kio_svn::copy " << src << " to " << dest << endl; | 474 | qCDebug(KDESVN_LOG) << "kio_svn::copy " << src << " to " << dest << endl; | ||
476 | svn::Revision rev = m_pData->urlToRev(src); | 475 | svn::Revision rev = m_pData->urlToRev(src); | ||
477 | if (rev == svn::Revision::UNDEFINED) { | 476 | if (rev == svn::Revision::UNDEFINED) { | ||
478 | rev = svn::Revision::HEAD; | 477 | rev = svn::Revision::HEAD; | ||
479 | } | 478 | } | ||
480 | m_pData->dispProgress = true; | 479 | m_pData->dispProgress = true; | ||
481 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | 480 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | ||
482 | try { | 481 | try { | ||
483 | m_pData->m_Svnclient->copy(makeSvnUrl(src), rev, makeSvnUrl(dest)); | 482 | m_pData->m_Svnclient->copy(makeSvnPath(src), rev, makeSvnPath(dest)); | ||
484 | } catch (const svn::ClientException &e) { | 483 | } catch (const svn::ClientException &e) { | ||
485 | if (e.apr_err() == SVN_ERR_ENTRY_EXISTS) { | 484 | if (e.apr_err() == SVN_ERR_ENTRY_EXISTS) { | ||
486 | error(KIO::ERR_DIR_ALREADY_EXIST, e.msg()); | 485 | error(KIO::ERR_DIR_ALREADY_EXIST, e.msg()); | ||
487 | } else { | 486 | } else { | ||
488 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 487 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
489 | } | 488 | } | ||
490 | qCDebug(KDESVN_LOG) << "kio_svn::copy aborted" << endl; | 489 | qCDebug(KDESVN_LOG) << "kio_svn::copy aborted" << endl; | ||
491 | return; | 490 | return; | ||
492 | } | 491 | } | ||
493 | m_pData->dispProgress = false; | 492 | m_pData->dispProgress = false; | ||
494 | qCDebug(KDESVN_LOG) << "kio_svn::copy finished" << endl; | 493 | qCDebug(KDESVN_LOG) << "kio_svn::copy finished" << endl; | ||
495 | notify(i18n("Copied %1 to %2", makeSvnUrl(src).toDisplayString(), makeSvnUrl(dest).toDisplayString())); | 494 | notify(i18n("Copied %1 to %2", makeSvnPath(src).path(), makeSvnPath(dest).path())); | ||
496 | finished(); | 495 | finished(); | ||
497 | } | 496 | } | ||
498 | 497 | | |||
499 | void kio_svnProtocol::del(const QUrl &src, bool isfile) | 498 | void kio_svnProtocol::del(const QUrl &src, bool isfile) | ||
500 | { | 499 | { | ||
501 | Q_UNUSED(isfile); | 500 | Q_UNUSED(isfile); | ||
502 | m_pData->resetListener(); | 501 | m_pData->resetListener(); | ||
503 | qCDebug(KDESVN_LOG) << "kio_svn::del " << src << endl; | 502 | qCDebug(KDESVN_LOG) << "kio_svn::del " << src << endl; | ||
504 | //m_pData->reInitClient(); | 503 | //m_pData->reInitClient(); | ||
505 | svn::Revision rev = m_pData->urlToRev(src); | 504 | svn::Revision rev = m_pData->urlToRev(src); | ||
506 | if (rev == svn::Revision::UNDEFINED) { | 505 | if (rev == svn::Revision::UNDEFINED) { | ||
507 | rev = svn::Revision::HEAD; | 506 | rev = svn::Revision::HEAD; | ||
508 | } | 507 | } | ||
509 | if (rev != svn::Revision::HEAD) { | 508 | if (rev != svn::Revision::HEAD) { | ||
510 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | 509 | extraError(KIO::ERR_SLAVE_DEFINED, i18n("Can only write on HEAD revision.")); | ||
511 | return; | 510 | return; | ||
512 | } | 511 | } | ||
513 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | 512 | m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); | ||
514 | try { | 513 | try { | ||
515 | svn::Targets target(makeSvnUrl(src)); | 514 | svn::Targets target(makeSvnPath(src)); | ||
516 | m_pData->m_Svnclient->remove(target, false); | 515 | m_pData->m_Svnclient->remove(target, false); | ||
517 | } catch (const svn::ClientException &e) { | 516 | } catch (const svn::ClientException &e) { | ||
518 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 517 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
519 | qCDebug(KDESVN_LOG) << "kio_svn::del aborted" << endl; | 518 | qCDebug(KDESVN_LOG) << "kio_svn::del aborted" << endl; | ||
520 | return; | 519 | return; | ||
521 | } | 520 | } | ||
522 | qCDebug(KDESVN_LOG) << "kio_svn::del finished" << endl; | 521 | qCDebug(KDESVN_LOG) << "kio_svn::del finished" << endl; | ||
523 | finished(); | 522 | finished(); | ||
524 | } | 523 | } | ||
525 | 524 | | |||
526 | bool kio_svnProtocol::getLogMsg(QString &t) | 525 | bool kio_svnProtocol::getLogMsg(QString &t) | ||
527 | { | 526 | { | ||
528 | svn::CommitItemList _items; | 527 | svn::CommitItemList _items; | ||
529 | return m_pData->m_Listener.contextGetLogMessage(t, _items); | 528 | return m_pData->m_Listener.contextGetLogMessage(t, _items); | ||
530 | } | 529 | } | ||
531 | 530 | | |||
532 | bool kio_svnProtocol::checkWc(const QUrl &url) const | 531 | bool kio_svnProtocol::checkWc(const svn::Path &localPath) const | ||
533 | { | 532 | { | ||
534 | m_pData->resetListener(); | 533 | m_pData->resetListener(); | ||
535 | if (url.isEmpty() || !url.isLocalFile()) { | 534 | if (!localPath.isSet()) { | ||
536 | return false; | 535 | return false; | ||
537 | } | 536 | } | ||
538 | svn::Revision peg(svn_opt_revision_unspecified); | 537 | svn::Revision peg(svn_opt_revision_unspecified); | ||
539 | svn::Revision rev(svn_opt_revision_unspecified); | 538 | svn::Revision rev(svn_opt_revision_unspecified); | ||
540 | svn::InfoEntries e; | 539 | svn::InfoEntries e; | ||
541 | try { | 540 | try { | ||
542 | e = m_pData->m_Svnclient->info(svn::Path(url), svn::DepthEmpty, rev, peg); | 541 | e = m_pData->m_Svnclient->info(localPath, svn::DepthEmpty, rev, peg); | ||
543 | } catch (const svn::ClientException &e) { | 542 | } catch (const svn::ClientException &e) { | ||
544 | if (SVN_ERR_WC_NOT_DIRECTORY == e.apr_err()) { | 543 | if (SVN_ERR_WC_NOT_DIRECTORY == e.apr_err()) { | ||
545 | return false; | 544 | return false; | ||
546 | } | 545 | } | ||
547 | return true; | 546 | return true; | ||
548 | } | 547 | } | ||
549 | return false; | 548 | return false; | ||
550 | } | 549 | } | ||
551 | 550 | | |||
552 | QUrl kio_svnProtocol::makeSvnUrl(const QUrl &url, bool check_Wc) const | 551 | svn::Path kio_svnProtocol::makeSvnPath(const QUrl &url) const | ||
553 | { | 552 | { | ||
554 | const QString scheme = svn::Url::transformProtokoll(url.scheme()); | 553 | const QString scheme = svn::Url::transformProtokoll(url.scheme()); | ||
555 | if (scheme == QLatin1String("file") && check_Wc) { | 554 | if (scheme == QLatin1String("file")) { | ||
556 | if (checkWc(url)) { | 555 | const svn::Path path(url.toLocalFile()); | ||
557 | return url; | 556 | if (checkWc(path)) { | ||
557 | return path; | ||||
558 | } | 558 | } | ||
559 | } | 559 | } | ||
560 | if (url.path().isEmpty()) { | ||||
561 | throw svn::ClientException(QLatin1Char('\'') + url.url() + QLatin1String("' is not a valid subversion url")); | ||||
562 | } | ||||
563 | | ||||
560 | QUrl tmpUrl(url); | 564 | QUrl tmpUrl(url); | ||
561 | tmpUrl.setScheme(scheme); | 565 | tmpUrl.setScheme(scheme); | ||
562 | tmpUrl.setQuery(QString()); // svn doesn't know anything about queries (e.g ?rev=X) | 566 | tmpUrl.setQuery(QString()); // svn doesn't know anything about queries (e.g ?rev=X) | ||
563 | 567 | | |||
564 | if (url.path().isEmpty()) { | 568 | return svn::Path(tmpUrl.toString(QUrl::NormalizePathSegments)); | ||
565 | throw svn::ClientException(QLatin1Char('\'') + url.url() + QLatin1String("' is not a valid subversion url")); | | |||
566 | } | | |||
567 | return tmpUrl; | | |||
568 | } | 569 | } | ||
569 | 570 | | |||
570 | bool kio_svnProtocol::createUDSEntry(const QString &filename, const QString &user, long long int size, bool isdir, time_t mtime, KIO::UDSEntry &entry) | 571 | bool kio_svnProtocol::createUDSEntry(const QString &filename, const QString &user, long long int size, bool isdir, time_t mtime, KIO::UDSEntry &entry) | ||
571 | { | 572 | { | ||
572 | entry.insert(KIO::UDSEntry::UDS_NAME, filename); | 573 | entry.insert(KIO::UDSEntry::UDS_NAME, filename); | ||
573 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, isdir ? S_IFDIR : S_IFREG); | 574 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, isdir ? S_IFDIR : S_IFREG); | ||
574 | entry.insert(KIO::UDSEntry::UDS_SIZE, size); | 575 | entry.insert(KIO::UDSEntry::UDS_SIZE, size); | ||
575 | entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, mtime); | 576 | entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, mtime); | ||
▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Line(s) | 790 | { | |||
835 | } | 836 | } | ||
836 | } | 837 | } | ||
837 | 838 | | |||
838 | void kio_svnProtocol::checkout(const QUrl &src, const QUrl &target, const int rev, const QString &revstring) | 839 | void kio_svnProtocol::checkout(const QUrl &src, const QUrl &target, const int rev, const QString &revstring) | ||
839 | { | 840 | { | ||
840 | svn::Revision where(rev, revstring); | 841 | svn::Revision where(rev, revstring); | ||
841 | try { | 842 | try { | ||
842 | svn::CheckoutParameter params; | 843 | svn::CheckoutParameter params; | ||
843 | params.moduleName(makeSvnUrl(src)).destination(target.path()).revision(where).peg(svn::Revision::UNDEFINED).depth(svn::DepthInfinity); | 844 | params.moduleName(makeSvnPath(src)).destination(target.path()).revision(where).peg(svn::Revision::UNDEFINED).depth(svn::DepthInfinity); | ||
844 | m_pData->m_Svnclient->checkout(params); | 845 | m_pData->m_Svnclient->checkout(params); | ||
845 | } catch (const svn::ClientException &e) { | 846 | } catch (const svn::ClientException &e) { | ||
846 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 847 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
847 | } | 848 | } | ||
848 | } | 849 | } | ||
849 | 850 | | |||
850 | void kio_svnProtocol::svnlog(int revstart, const QString &revstringstart, int revend, const QString &revstringend, const QList<QUrl> &urls) | 851 | void kio_svnProtocol::svnlog(int revstart, const QString &revstringstart, int revend, const QString &revstringend, const QList<QUrl> &urls) | ||
851 | { | 852 | { | ||
852 | svn::Revision start(revstart, revstringstart); | 853 | svn::Revision start(revstart, revstringstart); | ||
853 | svn::Revision end(revend, revstringend); | 854 | svn::Revision end(revend, revstringend); | ||
854 | svn::LogParameter params; | 855 | svn::LogParameter params; | ||
855 | params.revisionRange(start, end).peg(svn::Revision::UNDEFINED).limit(0).discoverChangedPathes(true).strictNodeHistory(true); | 856 | params.revisionRange(start, end).peg(svn::Revision::UNDEFINED).limit(0).discoverChangedPathes(true).strictNodeHistory(true); | ||
856 | 857 | | |||
857 | for (long j = 0; j < urls.count(); ++j) { | 858 | for (long j = 0; j < urls.count(); ++j) { | ||
858 | svn::LogEntriesMap logs; | 859 | svn::LogEntriesMap logs; | ||
859 | try { | 860 | try { | ||
860 | m_pData->m_Svnclient->log(params.targets(svn::Path(makeSvnUrl(urls[j]))), logs); | 861 | m_pData->m_Svnclient->log(params.targets(makeSvnPath(urls[j])), logs); | ||
861 | } catch (const svn::ClientException &e) { | 862 | } catch (const svn::ClientException &e) { | ||
862 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 863 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
863 | break; | 864 | break; | ||
864 | } | 865 | } | ||
865 | if (logs.isEmpty()) { | 866 | if (logs.isEmpty()) { | ||
866 | const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); | 867 | const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); | ||
867 | setMetaData(num + QStringLiteral("path"), urls[j].path()); | 868 | setMetaData(num + QStringLiteral("path"), urls[j].path()); | ||
868 | setMetaData(num + QStringLiteral("string"), | 869 | setMetaData(num + QStringLiteral("string"), | ||
Show All 34 Lines | 899 | { | |||
903 | } | 904 | } | ||
904 | } | 905 | } | ||
905 | 906 | | |||
906 | void kio_svnProtocol::wc_switch(const QUrl &wc, const QUrl &target, bool rec, int rev, const QString &revstring) | 907 | void kio_svnProtocol::wc_switch(const QUrl &wc, const QUrl &target, bool rec, int rev, const QString &revstring) | ||
907 | { | 908 | { | ||
908 | svn::Revision where(rev, revstring); | 909 | svn::Revision where(rev, revstring); | ||
909 | svn::Path wc_path(wc.path()); | 910 | svn::Path wc_path(wc.path()); | ||
910 | try { | 911 | try { | ||
911 | m_pData->m_Svnclient->doSwitch(wc_path, svn::Url(makeSvnUrl(target)), where, rec ? svn::DepthInfinity : svn::DepthFiles); | 912 | m_pData->m_Svnclient->doSwitch(wc_path, svn::Url(makeSvnPath(target)), where, rec ? svn::DepthInfinity : svn::DepthFiles); | ||
912 | } catch (const svn::ClientException &e) { | 913 | } catch (const svn::ClientException &e) { | ||
913 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 914 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
914 | } | 915 | } | ||
915 | } | 916 | } | ||
916 | 917 | | |||
917 | void kio_svnProtocol::diff(const QUrl &uri1, const QUrl &uri2, int rnum1, const QString &rstring1, int rnum2, const QString &rstring2, bool rec) | 918 | void kio_svnProtocol::diff(const QUrl &uri1, const QUrl &uri2, int rnum1, const QString &rstring1, int rnum2, const QString &rstring2, bool rec) | ||
918 | { | 919 | { | ||
919 | QByteArray ex; | 920 | QByteArray ex; | ||
920 | /// @todo read settings for diff (ignore contentype) | 921 | /// @todo read settings for diff (ignore contentype) | ||
921 | try { | 922 | try { | ||
922 | const svn::Revision r1(rnum1, rstring1); | 923 | const svn::Revision r1(rnum1, rstring1); | ||
923 | const svn::Revision r2(rnum2, rstring2); | 924 | const svn::Revision r2(rnum2, rstring2); | ||
924 | const QUrl u1 = makeSvnUrl(uri1, true); | 925 | const svn::Path u1 = makeSvnPath(uri1); | ||
925 | const QUrl u2 = makeSvnUrl(uri2, true); | 926 | const svn::Path u2 = makeSvnPath(uri2); | ||
926 | QTemporaryDir tdir; | 927 | QTemporaryDir tdir; | ||
927 | qCDebug(KDESVN_LOG) << "kio_ksvn::diff : " << u1 << " at revision " << r1.toString() << " with " | 928 | qCDebug(KDESVN_LOG) << "kio_ksvn::diff : " << u1.path() << " at revision " << r1.toString() << " with " | ||
928 | << u2 << " at revision " << r2.toString() | 929 | << u2.path() << " at revision " << r2.toString() | ||
929 | << endl ; | 930 | << endl ; | ||
930 | svn::DiffParameter _opts; | 931 | svn::DiffParameter _opts; | ||
931 | // no peg revision required | 932 | // no peg revision required | ||
932 | _opts.path1(u1).path2(u2).tmpPath(tdir.path()). | 933 | _opts.path1(u1).path2(u2).tmpPath(tdir.path()). | ||
933 | rev1(r1).rev2(r2). | 934 | rev1(r1).rev2(r2). | ||
934 | ignoreContentType(false).extra(svn::StringArray()).depth(rec ? svn::DepthInfinity : svn::DepthEmpty).ignoreAncestry(false).noDiffDeleted(false). | 935 | ignoreContentType(false).extra(svn::StringArray()).depth(rec ? svn::DepthInfinity : svn::DepthEmpty).ignoreAncestry(false).noDiffDeleted(false). | ||
935 | relativeTo(svn::Path((u1 == u2 ? u1 : QUrl()))).changeList(svn::StringArray()); | 936 | relativeTo((u1.path() == u2.path() ? u1 : svn::Path())).changeList(svn::StringArray()); | ||
936 | 937 | | |||
937 | tdir.setAutoRemove(true); | 938 | tdir.setAutoRemove(true); | ||
938 | ex = m_pData->m_Svnclient->diff(_opts); | 939 | ex = m_pData->m_Svnclient->diff(_opts); | ||
939 | } catch (const svn::ClientException &e) { | 940 | } catch (const svn::ClientException &e) { | ||
940 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 941 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
941 | return; | 942 | return; | ||
942 | } | 943 | } | ||
943 | QString out = QString::fromUtf8(ex); | 944 | QString out = QString::fromUtf8(ex); | ||
944 | const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); | 945 | const QString num(QString::number(m_pData->m_Listener.counter()).rightJustified(10, QLatin1Char('0'))); | ||
945 | QTextStream stream(&out); | 946 | QTextStream stream(&out); | ||
946 | while (!stream.atEnd()) { | 947 | while (!stream.atEnd()) { | ||
947 | setMetaData(num + QStringLiteral("diffresult"), stream.readLine()); | 948 | setMetaData(num + QStringLiteral("diffresult"), stream.readLine()); | ||
948 | m_pData->m_Listener.incCounter(); | 949 | m_pData->m_Listener.incCounter(); | ||
949 | } | 950 | } | ||
950 | } | 951 | } | ||
951 | 952 | | |||
952 | void kio_svnProtocol::import(const QUrl &repos, const QUrl &wc) | 953 | void kio_svnProtocol::import(const QUrl &repos, const QUrl &wc) | ||
953 | { | 954 | { | ||
954 | try { | 955 | try { | ||
955 | const QUrl target = makeSvnUrl(repos); | 956 | const svn::Path target = makeSvnPath(repos); | ||
956 | const QString path = wc.path(); | 957 | const QString path = wc.path(); | ||
957 | m_pData->m_Svnclient->import(svn::Path(path), svn::Url(target), QString(), svn::DepthInfinity, false, false); | 958 | m_pData->m_Svnclient->import(path, svn::Url(target), QString(), svn::DepthInfinity, false, false); | ||
958 | } catch (const svn::ClientException &e) { | 959 | } catch (const svn::ClientException &e) { | ||
959 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | 960 | extraError(KIO::ERR_SLAVE_DEFINED, e.msg()); | ||
960 | return; | 961 | return; | ||
961 | } | 962 | } | ||
962 | finished(); | 963 | finished(); | ||
963 | } | 964 | } | ||
964 | 965 | | |||
965 | void kio_svnProtocol::add(const QUrl &wc) | 966 | void kio_svnProtocol::add(const QUrl &wc) | ||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |