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