00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qfile.h>
00013 #include <qfileinfo.h>
00014 #include <qdir.h>
00015
00016 #include <kapplication.h>
00017 #include <kmessagebox.h>
00018 #include <kdebug.h>
00019 #include <kdeversion.h>
00020 #include <klocale.h>
00021 #include <kprocess.h>
00022 #include <kstandarddirs.h>
00023 #include <kmainwindow.h>
00024 #include <dcopref.h>
00025 #include <repository_stub.h>
00026 #include <cvsservice_stub.h>
00027 #include <cvsjob_stub.h>
00028
00029 #include <repository_stub.h>
00030 #include <cvsservice_stub.h>
00031 #include <cvsjob_stub.h>
00032
00033 #include <urlutil.h>
00034 #include <kdevproject.h>
00035 #include <kdevmainwindow.h>
00036 #include <kdevcore.h>
00037 #include <kdevdifffrontend.h>
00038 #include <kdevmakefrontend.h>
00039 #include <kdevpartcontroller.h>
00040
00041 #include "cvsprocesswidget.h"
00042 #include "checkoutdialog.h"
00043 #include "commitdlg.h"
00044 #include "tagdialog.h"
00045 #include "diffdialog.h"
00046 #include "releaseinputdialog.h"
00047 #include "cvslogdialog.h"
00048
00049 #include "changelog.h"
00050 #include "cvsoptions.h"
00051 #include "cvsdir.h"
00052 #include "cvsentry.h"
00053 #include "jobscheduler.h"
00054 #include "cvsfileinfoprovider.h"
00055
00056 #include "cvspart.h"
00057 #include "cvspartimpl.h"
00058
00060
00062
00063
00064 const QString CvsServicePartImpl::changeLogFileName( "ChangeLog" );
00065
00066
00067 const QString CvsServicePartImpl::changeLogPrependString( " " );
00068
00070
00072
00073 CvsServicePartImpl::CvsServicePartImpl( CvsServicePart *part, const char *name )
00074 : QObject( this, name? name : "cvspartimpl" ),
00075 m_scheduler( 0 ), m_part( part ), m_widget( 0 )
00076 {
00077 if (requestCvsService())
00078 {
00079 m_widget = new CvsProcessWidget( m_cvsService, part, 0, "cvsprocesswidget" );
00080 m_scheduler = new DirectScheduler( m_widget );
00081 m_fileInfoProvider = new CVSFileInfoProvider( part, m_cvsService );
00082 }
00083 else
00084 {
00085 kdDebug() << "CvsServicePartImpl::CvsServicePartImpl(): somebody kills me because"
00086 "I could not request a valid CvsService!!!! :-((( " << endl;
00087 }
00088
00089 connect( core(), SIGNAL(projectOpened()), this, SLOT(slotProjectOpened()) );
00090 }
00091
00093
00094 CvsServicePartImpl::~CvsServicePartImpl()
00095 {
00096 if (processWidget())
00097 {
00098
00099 mainWindow()->removeView( m_widget );
00100 delete m_widget;
00101 }
00102 delete m_scheduler;
00103
00104 releaseCvsService();
00105 }
00106
00108
00109 bool CvsServicePartImpl::prepareOperation( const KURL::List &someUrls, CvsOperation op )
00110 {
00111 kdDebug() << "===> CvsServicePartImpl::prepareOperation(const KURL::List &, CvsOperation)" << endl;
00112
00113 bool correctlySetup = (m_cvsService != 0) && (m_repository != 0);
00114 if (!correctlySetup)
00115 {
00116 kdDebug(9006) << "DCOP CvsService is not available!!!" << endl;
00117 return false;
00118 }
00119
00120 KURL::List urls = someUrls;
00121 URLUtil::dump( urls, "Requested CVS operation for: " );
00122
00123 if (!m_part->project())
00124 {
00125 kdDebug(9006) << "CvsServicePartImpl::prepareOperation(): No project???" << endl;
00126 KMessageBox::sorry( 0, i18n("Open a project first.\nOperation will be aborted.") );
00127 return false;
00128 }
00129
00130 if (m_widget->isAlreadyWorking())
00131 {
00132 if (KMessageBox::warningYesNo( 0,
00133 i18n("Another CVS operation is executing: do you want to cancel it \n"
00134 "and start this new one?"),
00135 i18n("CVS: Operation Already Pending ")) == KMessageBox::Yes)
00136 {
00137 m_widget->cancelJob();
00138 }
00139 else
00140 {
00141 kdDebug() << "===> Operation canceled by user request" << endl;
00142 return false;
00143 }
00144 }
00145
00146 validateURLs( projectDirectory(), urls, op );
00147 if (urls.count() <= 0)
00148 {
00149 kdDebug(9006) << "CvsServicePartImpl::prepareOperation(): No valid document URL selected!!!" << endl;
00150 KMessageBox::sorry( 0, i18n("None of the file(s) you selected seem to be valid for repository.") );
00151 return false;
00152 }
00153
00154 URLUtil::dump( urls );
00155
00156 m_urlList = urls;
00157 m_lastOperation = op;
00158
00159 return true;
00160 }
00161
00163
00164 void CvsServicePartImpl::doneOperation( const KURL::List &, CvsOperation )
00165 {
00166 kdDebug(9006) << "CvsServicePartImpl::doneOperation(const KURL::List&, CvsOperation)" << endl;
00167
00168
00169 }
00170
00172
00173 const KURL::List &CvsServicePartImpl::urlList() const
00174 {
00175 return m_urlList;
00176 }
00177
00179
00180 QStringList CvsServicePartImpl::fileList( bool relativeToProjectDir ) const
00181 {
00182 if (relativeToProjectDir)
00183 return URLUtil::toRelativePaths( projectDirectory(), urlList() );
00184 else
00185 return urlList().toStringList();
00186 }
00187
00189
00190 bool CvsServicePartImpl::isRegisteredInRepository( const QString &projectDirectory, const KURL &url )
00191 {
00192 kdDebug(9006) << "===> CvsServicePartImpl::isRegisteredInRepository() here! " << endl;
00193
00194
00195 KURL projectURL = KURL::fromPathOrURL( projectDirectory );
00196 kdDebug(9006) << "projectURL = " << projectURL.url() << endl;
00197 kdDebug(9006) << "url = " << url.url() << endl;
00198
00199 if ( projectURL == url)
00200 {
00201 CVSDir cvsdir = CVSDir( projectDirectory );
00202 return cvsdir.isValid();
00203 }
00204 else
00205 {
00206 CVSDir cvsdir = CVSDir( url.directory() );
00207
00208 if (!cvsdir.isValid())
00209 {
00210 kdDebug(9006) << "===> Error: " << cvsdir.path() << " is not a valid CVS directory " << endl;
00211 return false;
00212 }
00213 CVSEntry entry = cvsdir.fileStatus( url.fileName() );
00214 return entry.isValid();
00215 }
00216 }
00217
00219
00220 void CvsServicePartImpl::validateURLs( const QString &projectDirectory, KURL::List &urls, CvsOperation op )
00221 {
00222 kdDebug(9006) << "CvsServicePartImpl::validateURLs() here!" << endl;
00223
00224
00225
00226 if (op == opAdd)
00227 {
00228 kdDebug(9006) << "This is a Cvs Add operation and will not be checked against repository ;-)" << endl;
00229 return;
00230 }
00231 QValueList<KURL>::iterator it = urls.begin();
00232 while (it != urls.end())
00233 {
00234 if (!CvsServicePartImpl::isRegisteredInRepository( projectDirectory, (*it) ))
00235 {
00236 kdDebug(9006) << "Warning: file " << (*it).path() << " does NOT belong to repository and will not be used" << endl;
00237
00238 it = urls.erase( it );
00239 }
00240 else
00241 {
00242 kdDebug(9006) << "Warning: file " << (*it).path() << " is in repository and will be accepted" << endl;
00243
00244 ++it;
00245 }
00246 }
00247 }
00248
00250
00251 void CvsServicePartImpl::addToIgnoreList( const QString &projectDirectory, const KURL &url )
00252 {
00253 kdDebug(9006) << "===> CvsServicePartImpl::addToIgnoreList() here! " << endl;
00254
00255 if ( url.path() == projectDirectory )
00256 {
00257 kdDebug(9006) << "Can't add to ignore list current project directory " << endl;
00258 return;
00259 }
00260
00261 CVSDir cvsdir( url.directory() );
00262 cvsdir.ignoreFile( url.fileName() );
00263 }
00264
00265 void CvsServicePartImpl::addToIgnoreList( const QString &projectDirectory, const KURL::List &urls )
00266 {
00267 for (size_t i=0; i<urls.count(); ++i)
00268 {
00269 addToIgnoreList( projectDirectory, urls[i] );
00270 }
00271 }
00272
00274
00275 void CvsServicePartImpl::removeFromIgnoreList( const QString &, const KURL &url )
00276 {
00277 kdDebug(9006) << "===> CvsServicePartImpl::removeFromIgnoreList() here! " << endl;
00278
00279 QStringList ignoreLines;
00280
00281 CVSDir cvsdir( url.directory() );
00282 cvsdir.doNotIgnoreFile( url.fileName() );
00283 }
00284
00285 void CvsServicePartImpl::removeFromIgnoreList( const QString &projectDirectory, const KURL::List &urls )
00286 {
00287 for (size_t i=0; i<urls.count(); ++i)
00288 {
00289 removeFromIgnoreList( projectDirectory, urls[i] );
00290 }
00291 }
00292
00294
00295 bool CvsServicePartImpl::isValidDirectory( const QDir &dir ) const
00296 {
00297 CVSDir cvsdir( dir );
00298
00299 return cvsdir.isValid();
00300 }
00301
00303
00304 CvsProcessWidget *CvsServicePartImpl::processWidget() const
00305 {
00306 return m_widget;
00307 }
00308
00310
00311 KDevMainWindow *CvsServicePartImpl::mainWindow() const
00312 {
00313 return m_part->mainWindow();
00314 }
00315
00317
00318 QString CvsServicePartImpl::projectDirectory() const
00319 {
00320 return m_part->project() ? m_part->project()->projectDirectory() : QString::null;
00321 }
00322
00324
00325 KDevCore *CvsServicePartImpl::core() const
00326 {
00327 return m_part->core();
00328 }
00329
00331
00332 KDevDiffFrontend *CvsServicePartImpl::diffFrontend() const
00333 {
00334 return m_part->diffFrontend();
00335 }
00336
00338
00339 void CvsServicePartImpl::login()
00340 {
00341 DCOPRef job = m_cvsService->login( this->projectDirectory() );
00342
00343 m_scheduler->schedule( job );
00344 }
00345
00347
00348 void CvsServicePartImpl::logout()
00349 {
00350 DCOPRef job = m_cvsService->logout( this->projectDirectory() );
00351
00352 m_scheduler->schedule( job );
00353 }
00354
00356
00357 bool CvsServicePartImpl::checkout()
00358 {
00359 kdDebug() << "CvsServicePartImpl::checkout()" << endl;
00360
00361 CheckoutDialog dlg( m_cvsService, mainWindow()->main()->centralWidget() );
00362
00363 if ( dlg.exec() == QDialog::Accepted )
00364 {
00365 #if KDE_IS_VERSION(3,2,90)
00366 DCOPRef job = m_cvsService->checkout( dlg.workDir(), dlg.serverPath(),
00367 dlg.module(), dlg.tag(), dlg.pruneDirs(), "", false
00368 );
00369 #else
00370 DCOPRef job = m_cvsService->checkout( dlg.workDir(), dlg.serverPath(),
00371 dlg.module(), dlg.tag(), dlg.pruneDirs()
00372 );
00373 #endif
00374 if (!m_cvsService->ok()) {
00375 KMessageBox::sorry( mainWindow()->main(), i18n( "Unable to checkout" ) );
00376 } else {
00377
00378
00379 modulePath = dlg.workDir() + dlg.module();
00380
00381 m_scheduler->schedule( job );
00382 connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotCheckoutFinished(bool,int)) );
00383 return true;
00384 }
00385 }
00386 return false;
00387 }
00388
00390
00391 void CvsServicePartImpl::commit( const KURL::List& urlList )
00392 {
00393 kdDebug(9006) << "CvsServicePartImpl::commit() here!" << endl;
00394 kdDebug(9006) << "Commit requested for " << urlList.count() << " file(s)." << endl;
00395
00396 if (!prepareOperation( urlList, opCommit ))
00397 return;
00398
00399 CommitDialog dlg( projectDirectory() + "/ChangeLog" );
00400 if (dlg.exec() == QDialog::Rejected)
00401 return;
00402
00403 CvsOptions *options = CvsOptions::instance();
00404 QString logString = dlg.logMessage().join( "\n" );
00405
00406 DCOPRef cvsJob = m_cvsService->commit( fileList(), logString, options->recursiveWhenCommitRemove() );
00407 if (!m_cvsService->ok())
00408 {
00409 kdDebug( 9006 ) << "Commit of " << fileList().join( ", " ) << " failed!!!" << endl;
00410 return;
00411 }
00412
00413 m_scheduler->schedule( cvsJob );
00414 connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
00415
00416
00417 if (dlg.mustAddToChangeLog())
00418 {
00419
00420 ChangeLogEntry entry;
00421 entry.addLines( dlg.logMessage() );
00422 entry.addToLog( dlg.changeLogFileName() );
00423
00424 kdDebug( 9999 ) << " *** ChangeLog entry : " <<
00425 entry.toString( changeLogPrependString ) << endl;
00426 }
00427
00428 doneOperation( KURL::List( fileList() ), opCommit );
00429 }
00430
00432
00433 void CvsServicePartImpl::update( const KURL::List& urlList )
00434 {
00435 kdDebug(9006) << "CvsServicePartImpl::update() here" << endl;
00436
00437 if (!prepareOperation( urlList, opCommit ))
00438 return;
00439
00440 CvsOptions *options = CvsOptions::instance();
00441 ReleaseInputDialog dlg( mainWindow()->main()->centralWidget() );
00442 if (dlg.exec() == QDialog::Rejected)
00443 return;
00444
00445 QString additionalOptions = dlg.release();
00446 if (dlg.isRevert())
00447 additionalOptions = additionalOptions + " " + options->revertOptions();
00448
00449 DCOPRef cvsJob = m_cvsService->update( fileList(),
00450 options->recursiveWhenUpdate(),
00451 options->createDirsWhenUpdate(),
00452 options->pruneEmptyDirsWhenUpdate(),
00453 additionalOptions );
00454
00455 m_scheduler->schedule( cvsJob );
00456 connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
00457
00458 doneOperation();
00459 }
00460
00462
00463 void CvsServicePartImpl::add( const KURL::List& urlList, bool binary )
00464 {
00465 kdDebug(9006) << "CvsServicePartImpl::add() here" << endl;
00466
00467 if (!prepareOperation( urlList, opAdd ))
00468 return;
00469
00470 DCOPRef cvsJob = m_cvsService->add( fileList(), binary );
00471
00472 m_scheduler->schedule( cvsJob );
00473 connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
00474
00475 doneOperation();
00476 }
00477
00479
00480 void CvsServicePartImpl::remove( const KURL::List& urlList )
00481 {
00482 kdDebug(9006) << "CvsServicePartImpl::remove() here" << endl;
00483
00484 if (!prepareOperation( urlList, opRemove ))
00485 return;
00486
00487 DCOPRef cvsJob = m_cvsService->remove( fileList(), true );
00488
00489 m_scheduler->schedule( cvsJob );
00490 connect( processWidget(), SIGNAL(jobFinished(bool,int)),
00491 this, SLOT(slotJobFinished(bool,int)) );
00492
00493 doneOperation();
00494 }
00495
00497
00498 void CvsServicePartImpl::removeStickyFlag( const KURL::List& urlList )
00499 {
00500 kdDebug(9006) << "CvsServicePartImpl::revert() here" << endl;
00501
00502 if (!prepareOperation( urlList, opUpdate ))
00503 return;
00504
00505 CvsOptions *options = CvsOptions::instance();
00506
00507 DCOPRef cvsJob = m_cvsService->update( fileList(),
00508 options->recursiveWhenUpdate(),
00509 options->createDirsWhenUpdate(),
00510 options->pruneEmptyDirsWhenUpdate(),
00511 "-A" );
00512
00513 m_scheduler->schedule( cvsJob );
00514 connect( processWidget(), SIGNAL(jobFinished(bool,int)),
00515 this, SLOT(slotJobFinished(bool,int)) );
00516
00517 doneOperation();
00518 }
00519
00521
00522 void CvsServicePartImpl::log( const KURL::List& urlList )
00523 {
00524 kdDebug(9006) << "CvsServicePartImpl::log() here: " << endl;
00525
00526 if (!prepareOperation( urlList, opLog ))
00527 return;
00528
00529 CVSLogDialog* f = new CVSLogDialog( m_cvsService );
00530 f->show();
00531
00532 f->startLog( projectDirectory(), fileList()[0] );
00533
00534 doneOperation();
00535 }
00536
00538
00539 void CvsServicePartImpl::diff( const KURL::List& urlList )
00540 {
00541 kdDebug(9006) << "CvsServicePartImpl::diff() here" << endl;
00542
00543 if (!prepareOperation( urlList, opDiff ))
00544 return;
00545
00546 DiffDialog dlg;
00547 if (dlg.exec() != QDialog::Accepted)
00548 return;
00549
00550 CvsOptions *options = CvsOptions::instance();
00551 DCOPRef cvsJob = m_cvsService->diff( fileList()[0], dlg.revA(),
00552 dlg.revB(), options->diffOptions(), options->contextLines() );
00553 if (!m_cvsService->ok())
00554 {
00555 KMessageBox::sorry( 0, i18n("Sorry, cannot diff."),
00556 i18n("Error During Diff") );
00557 return;
00558 }
00559
00560 m_scheduler->schedule( cvsJob );
00561 connect( processWidget(), SIGNAL(jobFinished(bool,int)),
00562 this, SLOT(slotDiffFinished(bool,int)) );
00563
00564 doneOperation();
00565 }
00566
00568
00569 void CvsServicePartImpl::tag( const KURL::List& urlList )
00570 {
00571 kdDebug(9006) << "CvsServicePartImpl::tag() here" << endl;
00572
00573 if (!prepareOperation( urlList, opTag ))
00574 return;
00575
00576 TagDialog dlg( i18n("Creating Tag/Branch for files ..."),
00577 mainWindow()->main()->centralWidget() );
00578 if (dlg.exec() != QDialog::Accepted)
00579 return;
00580
00581 DCOPRef cvsJob = m_cvsService->createTag( fileList(), dlg.tagName(),
00582 dlg.isBranch(), dlg.force() );
00583
00584 m_scheduler->schedule( cvsJob );
00585 connect( processWidget(), SIGNAL(jobFinished(bool,int)),
00586 this, SLOT(slotJobFinished(bool,int)) );
00587
00588 doneOperation();
00589 }
00590
00592
00593 void CvsServicePartImpl::unTag( const KURL::List& urlList )
00594 {
00595 kdDebug(9006) << "CvsServicePartImpl::unTag() here" << endl;
00596
00597 if (!prepareOperation( urlList, opUnTag ))
00598 return;
00599
00600 TagDialog dlg( i18n("Removing Tag/Branch from files ..."),
00601 mainWindow()->main()->centralWidget() );
00602 if (dlg.exec() != QDialog::Accepted)
00603 return;
00604
00605 DCOPRef cvsJob = m_cvsService->createTag( fileList(), dlg.tagName(),
00606 dlg.isBranch(), dlg.force() );
00607
00608 m_scheduler->schedule( cvsJob );
00609 connect( processWidget(), SIGNAL(jobFinished(bool,int)),
00610 this, SLOT(slotJobFinished(bool,int)) );
00611
00612 doneOperation();
00613 }
00614
00616
00617 void CvsServicePartImpl::addToIgnoreList( const KURL::List& urlList )
00618 {
00619 addToIgnoreList( projectDirectory(), urlList );
00620 }
00621
00623
00624 void CvsServicePartImpl::removeFromIgnoreList( const KURL::List& urlList )
00625 {
00626 removeFromIgnoreList( projectDirectory(), urlList );
00627 }
00628
00630
00635 void CvsServicePartImpl::createNewProject( const QString &dirName,
00636 const QString &cvsRsh, const QString &location,
00637 const QString &message, const QString &module, const QString &vendor,
00638 const QString &release, bool mustInitRoot )
00639 {
00640 kdDebug( 9006 ) << "====> CvsServicePartImpl::createNewProject( const QString& )" << endl;
00641
00642 CvsOptions *options = CvsOptions::instance();
00643 options->setCvsRshEnvVar( cvsRsh );
00644 options->setLocation( location );
00645
00646
00647
00648
00649
00650
00651
00652
00653 QString rsh_preamble;
00654 if ( !options->cvsRshEnvVar().isEmpty() )
00655 rsh_preamble = "CVS_RSH=" + KShellProcess::quote( options->cvsRshEnvVar() );
00656
00657 QString init;
00658 if (mustInitRoot)
00659 {
00660 init = rsh_preamble + " cvs -d " + KShellProcess::quote( options->location() ) + " init && ";
00661 }
00662 QString cmdLine = init + "cd " + KShellProcess::quote(dirName) +
00663 " && " + rsh_preamble +
00664 " cvs -d " + KShellProcess::quote(options->location()) +
00665 " import -m " + KShellProcess::quote(message) + " " +
00666 KShellProcess::quote(module) + " " +
00667 KShellProcess::quote(vendor) + " " +
00668 KShellProcess::quote(release) +
00669
00670 " && sh " +
00671 locate("data","kdevcvsservice/buildcvs.sh") + " . " +
00672 KShellProcess::quote(module) + " " +
00673 KShellProcess::quote(location);
00674
00675 kdDebug( 9006 ) << " ** Will run the following command: " << endl << cmdLine << endl;
00676 kdDebug( 9006 ) << " ** on directory: " << dirName << endl;
00677
00678 m_part->makeFrontend()->queueCommand( dirName, cmdLine );
00679 }
00680
00682
00683 bool CvsServicePartImpl::requestCvsService()
00684 {
00685 QCString appId;
00686 QString error;
00687
00688 if (KApplication::startServiceByDesktopName( "cvsservice",
00689 QStringList(), &error, &appId ))
00690 {
00691 QString msg = i18n( "Unable to find the Cervisia KPart. \n"
00692 "Cervisia Integration will not be available. Please check your\n"
00693 "Cervisia installation and re-try. Reason was:\n" ) + error;
00694 KMessageBox::error( processWidget(), msg, "DCOP Error" );
00695
00696 return false;
00697 }
00698 else
00699 {
00700 m_cvsService = new CvsService_stub( appId, "CvsService" );
00701 m_repository = new Repository_stub( appId, "CvsRepository" );
00702 }
00703
00704 return true;
00705 }
00706
00708
00709 void CvsServicePartImpl::releaseCvsService()
00710 {
00711 if (m_cvsService)
00712 m_cvsService->quit();
00713 delete m_cvsService;
00714 m_cvsService = 0;
00715 delete m_repository;
00716 m_repository = 0;
00717 }
00718
00720
00721 void CvsServicePartImpl::flushJobs()
00722 {
00723 processWidget()->cancelJob();
00724 }
00725
00727
00728 void CvsServicePartImpl::addFilesToProject( const QStringList &filesToAdd )
00729 {
00730 kdDebug( 9006 ) << "====> CvsServicePart::slotAddFilesToProject(const QStringList &)" << endl;
00731
00732 QStringList filesInCVS = checkFileListAgainstCVS( filesToAdd );
00733 if (filesInCVS.isEmpty())
00734 return;
00735
00736 int s = KMessageBox::questionYesNo( 0,
00737 i18n("Do you want to be added to CVS repository too?"),
00738 i18n("CVS - New Files Added to Project"),
00739 KStdGuiItem::yes(),
00740 KStdGuiItem::no(),
00741 i18n("askWhenAddingNewFiles") );
00742 if (s == KMessageBox::Yes)
00743 {
00744 kdDebug( 9006 ) << "Adding these files: " << filesInCVS.join( ", " ) << endl;
00745
00746 const KURL::List urls = KURL::List( filesInCVS );
00747 URLUtil::dump( urls );
00748 add( urls );
00749 }
00750 }
00751
00753
00754 void CvsServicePartImpl::removedFilesFromProject(const QStringList &filesToRemove)
00755 {
00756 kdDebug( 9006 ) << "====> CvsServicePart::slotRemovedFilesFromProject( const QStringList &)" << endl;
00757
00758 QStringList filesInCVS = checkFileListAgainstCVS( filesToRemove );
00759 if (filesInCVS.isEmpty())
00760 return;
00761
00762 int s = KMessageBox::questionYesNo( 0,
00763 i18n("Do you want them to be removed from CVS repository too?\nWarning: They will be removed from disk too."),
00764 i18n("CVS - Files Removed From Project"),
00765 KStdGuiItem::yes(),
00766 KStdGuiItem::no(),
00767 i18n("askWhenRemovingFiles") );
00768 if (s == KMessageBox::Yes)
00769 {
00770 kdDebug( 9006 ) << "Removing these files: " << filesInCVS.join( ", " ) << endl;
00771 const KURL::List urls = KURL::List( filesInCVS );
00772 URLUtil::dump( urls );
00773 remove( urls );
00774 }
00775 }
00776
00778
00779 QStringList CvsServicePartImpl::checkFileListAgainstCVS( const QStringList &filesToCheck ) const
00780 {
00781 QStringList filesInCVS;
00782 for (QStringList::const_iterator it = filesToCheck.begin(); it != filesToCheck.end(); ++it )
00783 {
00784 const QString &fn = (*it);
00785 QFileInfo fi( fn );
00786 if (isValidDirectory( fi.dirPath( true ) ))
00787 filesInCVS += ( m_part->project()->projectDirectory() + QDir::separator() + fn );
00788 }
00789
00790 return filesInCVS;
00791 }
00792
00794
00795 void CvsServicePartImpl::emitFileStateModified( const KURL::List &, VCSFileInfo::FileState & )
00796 {
00797 }
00798
00800
00801 KDevVCSFileInfoProvider *CvsServicePartImpl::fileInfoProvider() const
00802 {
00803 return m_fileInfoProvider;
00804 }
00805
00807
00809
00810 void CvsServicePartImpl::slotDiffFinished( bool normalExit, int exitStatus )
00811 {
00812 core()->running( m_part, false );
00813
00814 QString diff = processWidget()->output().join("\n"),
00815 err = processWidget()->errors().join("\n");
00816
00817 kdDebug( 9999 ) << "diff = " << diff << endl;
00818 kdDebug( 9999 ) << "err = " << err << endl;
00819
00820 if (normalExit)
00821 kdDebug( 9999 ) << " *** Process died nicely with exit status = " <<
00822 exitStatus << endl;
00823 else
00824 kdDebug( 9999 ) << " *** Process was killed with exit status = " <<
00825 exitStatus << endl;
00826
00827
00828 if (diff.isEmpty() && (exitStatus != 0))
00829 {
00830 KMessageBox::information( 0, i18n("Operation aborted (process killed)."),
00831 i18n("CVS Diff") );
00832 return;
00833 }
00834 if ( diff.isEmpty() && !err.isEmpty() )
00835 {
00836 KMessageBox::detailedError( 0, i18n("CVS outputted errors during diff."),
00837 err, i18n("Errors During Diff") );
00838 return;
00839 }
00840
00841 if ( !err.isEmpty() )
00842 {
00843 int s = KMessageBox::warningContinueCancelList( 0,
00844 i18n("CVS outputted errors during diff. Do you still want to continue?"),
00845 QStringList::split( "\n", err, false ), i18n("Errors During Diff")
00846 );
00847 if ( s != KMessageBox::Continue )
00848 return;
00849 }
00850
00851 if ( diff.isEmpty() )
00852 {
00853 KMessageBox::information( 0, i18n("There is no difference to the repository."),
00854 i18n("No Difference Found") );
00855 return;
00856 }
00857
00858 Q_ASSERT( diffFrontend() );
00859 diffFrontend()->showDiff( diff );
00860 }
00861
00863
00864 void CvsServicePartImpl::slotCheckoutFinished( bool exitStatus, int )
00865 {
00866 kdDebug() << "CvsServicePartImpl::slotCheckoutFinished(): job ended with status == "
00867 << exitStatus << endl;
00868
00869 if (!exitStatus)
00870 modulePath = QString::null;
00871
00872 kdDebug() << " I'll emit modulePath == " << modulePath << endl;
00873
00874 emit checkoutFinished( modulePath );
00875 }
00876
00878
00879 void CvsServicePartImpl::slotJobFinished( bool , int exitCode )
00880 {
00881
00882 kdDebug() << "CvsServicePartImpl::slotJobFinished(): job ended with code == "
00883 << exitCode << endl;
00884
00885
00886
00887
00888
00889
00890
00891
00892 }
00893
00895
00896 void CvsServicePartImpl::slotProjectOpened()
00897 {
00898 kdDebug() << "CvsServicePartImpl::slotProjectOpened(): setting work directory to "
00899 << projectDirectory() << endl;
00900
00901 m_repository->setWorkingCopy( projectDirectory() );
00902 }
00903
00904
00905 #include "cvspartimpl.moc"