1
/***************************************************************************
2
* Copyright (C) 2003 by Mario Scalas *
3
* mario.scalas@libero.it *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
***************************************************************************/
13
#include <qfileinfo.h>
17
#include <kapplication.h>
18
#include <kmessagebox.h>
20
#include <kdeversion.h>
23
#include <kstandarddirs.h>
24
#include <kmainwindow.h>
27
#include <repository_stub.h>
28
#include <cvsservice_stub.h>
29
#include <cvsjob_stub.h>
32
#include <kdevproject.h>
33
#include <kdevmainwindow.h>
35
#include <kdevdifffrontend.h>
36
#include <kdevmakefrontend.h>
37
#include <kdevpartcontroller.h>
39
#include "cvsprocesswidget.h"
40
#include "checkoutdialog.h"
41
#include "commitdlg.h"
42
#include "tagdialog.h"
43
#include "diffdialog.h"
44
#include "releaseinputdialog.h"
45
#include "cvslogdialog.h"
46
#include "editorsdialog.h"
47
#include "annotatedialog.h"
49
#include "changelog.h"
50
#include "cvsoptions.h"
53
#include "jobscheduler.h"
54
#include "cvsfileinfoprovider.h"
57
#include "cvspartimpl.h"
59
///////////////////////////////////////////////////////////////////////////////
61
///////////////////////////////////////////////////////////////////////////////
63
// Nice name (relative to projectDirectory()) ;-)
64
const QString CvsServicePartImpl::changeLogFileName( "ChangeLog" );
65
// Four spaces for every log line (except the first, which includes the
67
const QString CvsServicePartImpl::changeLogPrependString( " " );
69
///////////////////////////////////////////////////////////////////////////////
70
// class CvsServicePartImpl
71
///////////////////////////////////////////////////////////////////////////////
73
CvsServicePartImpl::CvsServicePartImpl( CvsServicePart *part, const char *name )
74
: QObject( this, name? name : "cvspartimpl" ),
75
m_scheduler( 0 ), m_part( part ), m_widget( 0 )
77
if (requestCvsService())
79
m_widget = new CvsProcessWidget( m_cvsService, part, 0, "cvsprocesswidget" );
80
m_scheduler = new DirectScheduler( m_widget );
81
m_fileInfoProvider = new CVSFileInfoProvider( part, m_cvsService );
83
connect( core(), SIGNAL(projectOpened()), this, SLOT(slotProjectOpened()) );
87
kdDebug(9006) << "CvsServicePartImpl::CvsServicePartImpl(): somebody kills me because"
88
"I could not request a valid CvsService!!!! :-((( " << endl;
93
///////////////////////////////////////////////////////////////////////////////
95
CvsServicePartImpl::~CvsServicePartImpl()
99
// Inform toplevel, that the output view is gone
100
mainWindow()->removeView( m_widget );
104
//delete m_fileInfoProvider;
108
///////////////////////////////////////////////////////////////////////////////
110
bool CvsServicePartImpl::prepareOperation( const KURL::List &someUrls, CvsOperation op )
112
kdDebug(9006) << k_funcinfo << endl;
114
bool correctlySetup = (m_cvsService != 0) && (m_repository != 0);
117
kdDebug(9006) << "DCOP CvsService is not available!!!" << endl;
121
KURL::List urls = someUrls;
122
URLUtil::dump( urls, "Requested CVS operation for: " );
124
if (!m_part->project())
126
kdDebug(9006) << k_funcinfo << "No project???" << endl;
127
KMessageBox::sorry( 0, i18n("Open a project first.\nOperation will be aborted.") );
131
if (m_widget->isAlreadyWorking())
133
if (KMessageBox::warningYesNo( 0,
134
i18n("Another CVS operation is executing: do you want to cancel it \n"
135
"and start this new one?"),
136
i18n("CVS: Operation Already Pending ")) == KMessageBox::Yes)
138
m_widget->cancelJob();
140
else // Operation canceled
142
kdDebug(9006) << k_funcinfo << "Operation canceled by user request" << endl;
147
validateURLs( projectDirectory(), urls, op );
148
if (urls.count() <= 0) // who knows? ;)
150
kdDebug(9006) << "CvsServicePartImpl::prepareOperation(): No valid document URL selected!!!" << endl;
151
KMessageBox::sorry( 0, i18n("None of the file(s) you selected seem to be valid for repository.") );
155
URLUtil::dump( urls );
156
// Save for later use
158
m_lastOperation = op;
163
///////////////////////////////////////////////////////////////////////////////
165
void CvsServicePartImpl::doneOperation( const KURL::List &/*someUrls*/, CvsOperation /*op*/ )
167
kdDebug(9006) << k_funcinfo << endl;
169
// @ todo notify clients (filetree) about changed status?)
172
///////////////////////////////////////////////////////////////////////////////
174
const KURL::List &CvsServicePartImpl::urlList() const
179
///////////////////////////////////////////////////////////////////////////////
181
QStringList CvsServicePartImpl::fileList( bool relativeToProjectDir ) const
183
if (relativeToProjectDir)
184
return URLUtil::toRelativePaths( projectDirectory(), urlList() );
186
return urlList().toStringList();
189
///////////////////////////////////////////////////////////////////////////////
191
bool CvsServicePartImpl::isRegisteredInRepository( const QString &projectDirectory, const KURL &url )
193
kdDebug(9006) << k_funcinfo << endl;
195
// KURL::directory() is a bit tricky when used on file or _dir_ paths ;-)
196
KURL projectURL = KURL::fromPathOrURL( projectDirectory );
197
kdDebug(9006) << k_funcinfo << "projectURL = " << projectURL.url() << endl;
198
kdDebug(9006) << k_funcinfo << "url = " << url.url() << endl;
200
if ( projectURL == url)
202
CVSDir cvsdir = CVSDir( projectDirectory );
203
return cvsdir.isValid();
207
CVSDir cvsdir = CVSDir( url.directory() );
209
if (!cvsdir.isValid())
211
kdDebug(9006) << k_funcinfo << " Error: " << cvsdir.path() << " is not a valid CVS directory " << endl;
214
CVSEntry entry = cvsdir.fileStatus( url.fileName() );
215
return entry.isValid();
219
///////////////////////////////////////////////////////////////////////////////
221
void CvsServicePartImpl::validateURLs( const QString &projectDirectory, KURL::List &urls, CvsOperation op )
223
kdDebug(9006) << k_funcinfo << endl;
225
// If files are to be added, we can avoid to check them to see if they are registered in the
229
kdDebug(9006) << "This is a Cvs Add operation and will not be checked against repository ;-)" << endl;
232
QValueList<KURL>::iterator it = urls.begin();
233
while (it != urls.end())
235
if (!CvsServicePartImpl::isRegisteredInRepository( projectDirectory, (*it) ))
237
kdDebug(9006) << "Warning: file " << (*it).path() << " does NOT belong to repository and will not be used" << endl;
239
it = urls.erase( it );
243
kdDebug(9006) << "Warning: file " << (*it).path() << " is in repository and will be accepted" << endl;
250
///////////////////////////////////////////////////////////////////////////////
252
void CvsServicePartImpl::addToIgnoreList( const QString &projectDirectory, const KURL &url )
254
kdDebug(9006) << k_funcinfo << endl;
256
if ( url.path() == projectDirectory )
258
kdDebug(9006) << "Can't add to ignore list current project directory " << endl;
262
CVSDir cvsdir( url.directory() );
263
cvsdir.ignoreFile( url.fileName() );
266
void CvsServicePartImpl::addToIgnoreList( const QString &projectDirectory, const KURL::List &urls )
268
for (size_t i=0; i<urls.count(); ++i)
270
addToIgnoreList( projectDirectory, urls[i] );
274
///////////////////////////////////////////////////////////////////////////////
276
void CvsServicePartImpl::removeFromIgnoreList( const QString &/*projectDirectory*/, const KURL &url )
278
kdDebug(9006) << k_funcinfo << endl;
280
QStringList ignoreLines;
282
CVSDir cvsdir( url.directory() );
283
cvsdir.doNotIgnoreFile( url.fileName() );
286
void CvsServicePartImpl::removeFromIgnoreList( const QString &projectDirectory, const KURL::List &urls )
288
for (size_t i=0; i<urls.count(); ++i)
290
removeFromIgnoreList( projectDirectory, urls[i] );
294
///////////////////////////////////////////////////////////////////////////////
296
bool CvsServicePartImpl::isValidDirectory( const QDir &dir ) const
298
CVSDir cvsdir( dir );
300
return cvsdir.isValid();
303
///////////////////////////////////////////////////////////////////////////////
305
CvsProcessWidget *CvsServicePartImpl::processWidget() const
310
///////////////////////////////////////////////////////////////////////////////
312
KDevMainWindow *CvsServicePartImpl::mainWindow() const
314
return m_part->mainWindow();
317
///////////////////////////////////////////////////////////////////////////////
319
QString CvsServicePartImpl::projectDirectory() const
321
return m_part->project() ? m_part->project()->projectDirectory() : QString::null;
324
///////////////////////////////////////////////////////////////////////////////
326
KDevCore *CvsServicePartImpl::core() const
328
return m_part->core();
331
///////////////////////////////////////////////////////////////////////////////
333
KDevDiffFrontend *CvsServicePartImpl::diffFrontend() const
335
return m_part->extension<KDevDiffFrontend>("KDevelop/DiffFrontend");
338
///////////////////////////////////////////////////////////////////////////////
340
void CvsServicePartImpl::login()
342
DCOPRef job = m_cvsService->login( this->projectDirectory() );
344
m_scheduler->schedule( job );
347
///////////////////////////////////////////////////////////////////////////////
349
void CvsServicePartImpl::logout()
351
DCOPRef job = m_cvsService->logout( this->projectDirectory() );
353
m_scheduler->schedule( job );
356
///////////////////////////////////////////////////////////////////////////////
358
bool CvsServicePartImpl::checkout()
360
kdDebug(9006) << k_funcinfo << endl;
362
CheckoutDialog dlg( m_cvsService, mainWindow()->main()->centralWidget() );
364
if ( dlg.exec() == QDialog::Accepted )
366
DCOPRef job = m_cvsService->checkout( dlg.workDir(), dlg.serverPath(),
367
dlg.module(), dlg.tag(), dlg.pruneDirs(), "", false
369
if (!m_cvsService->ok()) {
370
KMessageBox::sorry( mainWindow()->main(), i18n( "Unable to checkout" ) );
372
// Save the path for later retrieval since slotCheckoutFinished(bool,int)
373
// will use it for return the info to the caller.
374
modulePath = dlg.workDir() + dlg.module();
376
m_scheduler->schedule( job );
377
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotCheckoutFinished(bool,int)) );
384
///////////////////////////////////////////////////////////////////////////////
386
void CvsServicePartImpl::commit( const KURL::List& urlList )
388
kdDebug(9006) << k_funcinfo << endl;
389
kdDebug(9006) << "Commit requested for " << urlList.count() << " file(s)." << endl;
391
if (!prepareOperation( urlList, opCommit ))
394
CommitDialog dlg( projectDirectory() + "/ChangeLog" );
395
if (dlg.exec() == QDialog::Rejected)
398
CvsOptions *options = CvsOptions::instance();
399
QString logString = dlg.logMessage().join( "\n" );
401
DCOPRef cvsJob = m_cvsService->commit( fileList(), logString, options->recursiveWhenCommitRemove() );
402
if (!m_cvsService->ok())
404
kdDebug( 9006 ) << "Commit of " << fileList().join( ", " ) << " failed!!!" << endl;
408
m_scheduler->schedule( cvsJob );
409
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
411
// 2. if requested to do so, add an entry to the Changelog too
412
if (dlg.mustAddToChangeLog())
414
// 2.1 Modify the Changelog
415
ChangeLogEntry entry;
416
entry.addLines( dlg.logMessage() );
417
entry.addToLog( dlg.changeLogFileName() );
419
kdDebug( 9006 ) << " *** ChangeLog entry : " <<
420
entry.toString( changeLogPrependString ) << endl;
423
doneOperation( KURL::List( fileList() ), opCommit );
426
///////////////////////////////////////////////////////////////////////////////
428
void CvsServicePartImpl::update( const KURL::List& urlList )
430
kdDebug(9006) << k_funcinfo << endl;
432
if (!prepareOperation( urlList, opCommit ))
435
CvsOptions *options = CvsOptions::instance();
436
ReleaseInputDialog dlg( mainWindow()->main()->centralWidget() );
437
if (dlg.exec() == QDialog::Rejected)
440
QString additionalOptions = dlg.release();
442
additionalOptions = additionalOptions + " " + options->revertOptions();
444
DCOPRef cvsJob = m_cvsService->update( fileList(),
445
options->recursiveWhenUpdate(),
446
options->createDirsWhenUpdate(),
447
options->pruneEmptyDirsWhenUpdate(),
450
m_scheduler->schedule( cvsJob );
451
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
456
///////////////////////////////////////////////////////////////////////////////
458
void CvsServicePartImpl::add( const KURL::List& urlList, bool binary )
460
kdDebug(9006) << k_funcinfo << endl;
462
if (!prepareOperation( urlList, opAdd ))
465
DCOPRef cvsJob = m_cvsService->add( fileList(), binary );
467
m_scheduler->schedule( cvsJob );
468
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
473
///////////////////////////////////////////////////////////////////////////////
475
void CvsServicePartImpl::annotate( const KURL::List& urlList )
477
kdDebug(9006) << k_funcinfo << endl;
479
if (!prepareOperation( urlList, opAnnotate ))
482
//get the directory of the file we want to annotate
483
QString tagFilename = URLUtil::directory(projectDirectory()+"/"+fileList()[0]);
484
//CVS stores tag information in the ./CVS/Tag file
485
tagFilename += "/CVS/Tag";
488
//Check if such a Tag file exists, and try to read the tag/branch from it
489
QFile fileTag(tagFilename);
490
QString strRev = ""; //default revision is empty ...
491
if (fileTag.exists()) { //... but if there is a Tag file, we get the revision from there
492
if ( fileTag.open( IO_ReadOnly ) ) {
493
QTextStream stream( &fileTag );
495
line = stream.readLine();
496
if (line.startsWith("T")) { //the line always starts with a "T"...
497
strRev = line.right(line.length()-1); //...and after this there is the tag name
498
kdDebug(9006) << "The found revision is: >>" << strRev << "<<" <<endl;
504
AnnotateDialog * f = new AnnotateDialog( m_cvsService );
506
//the dialog will do all the work, just give him the file and the revision to start with
507
f->startFirstAnnotate( fileList()[0], strRev );
512
///////////////////////////////////////////////////////////////////////////////
514
void CvsServicePartImpl::unedit( const KURL::List& urlList)
516
kdDebug(9006) << k_funcinfo << endl;
518
int s = KMessageBox::questionYesNo( 0,
519
i18n("Do you really want to unedit the selected files?"),
520
i18n("CVS - Unedit Files"),
522
i18n("Do Not Unedit"),
523
"askUneditingFiles" );
524
if (s == KMessageBox::No) {
528
if (!prepareOperation( urlList, opUnEdit ))
531
DCOPRef cvsJob = m_cvsService->unedit( fileList() );
533
m_scheduler->schedule( cvsJob );
534
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
539
///////////////////////////////////////////////////////////////////////////////
541
void CvsServicePartImpl::edit( const KURL::List& urlList)
543
kdDebug(9006) << k_funcinfo << endl;
545
if (!prepareOperation( urlList, opEdit ))
548
DCOPRef cvsJob = m_cvsService->edit( fileList() );
550
m_scheduler->schedule( cvsJob );
551
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotJobFinished(bool,int)) );
556
///////////////////////////////////////////////////////////////////////////////
558
void CvsServicePartImpl::editors( const KURL::List& urlList)
560
kdDebug(9006) << k_funcinfo << endl;
562
if (!prepareOperation( urlList, opEditors ))
565
EditorsDialog * f = new EditorsDialog( m_cvsService );
567
//the dialog will do all the work
568
f->startjob( fileList()[0] );
573
///////////////////////////////////////////////////////////////////////////////
575
void CvsServicePartImpl::remove( const KURL::List& urlList )
577
kdDebug(9006) << k_funcinfo << endl;
579
if (!prepareOperation( urlList, opRemove ))
582
DCOPRef cvsJob = m_cvsService->remove( fileList(), true );
584
m_scheduler->schedule( cvsJob );
585
connect( processWidget(), SIGNAL(jobFinished(bool,int)),
586
this, SLOT(slotJobFinished(bool,int)) );
591
///////////////////////////////////////////////////////////////////////////////
593
void CvsServicePartImpl::removeStickyFlag( const KURL::List& urlList )
595
kdDebug(9006) << k_funcinfo << endl;
597
if (!prepareOperation( urlList, opUpdate ))
600
CvsOptions *options = CvsOptions::instance();
602
DCOPRef cvsJob = m_cvsService->update( fileList(),
603
options->recursiveWhenUpdate(),
604
options->createDirsWhenUpdate(),
605
options->pruneEmptyDirsWhenUpdate(),
608
m_scheduler->schedule( cvsJob );
609
connect( processWidget(), SIGNAL(jobFinished(bool,int)),
610
this, SLOT(slotJobFinished(bool,int)) );
615
///////////////////////////////////////////////////////////////////////////////
617
void CvsServicePartImpl::log( const KURL::List& urlList )
619
kdDebug(9006) << k_funcinfo << endl;
621
if (!prepareOperation( urlList, opLog ))
624
CVSLogDialog* f = new CVSLogDialog( m_cvsService );
626
// Form will do all the work
627
f->startLog( projectDirectory(), fileList()[0] );
632
///////////////////////////////////////////////////////////////////////////////
634
void CvsServicePartImpl::diff( const KURL::List& urlList )
636
kdDebug(9006) << k_funcinfo << endl;
638
if (!prepareOperation( urlList, opDiff ))
641
CVSDir cvsdir = CVSDir( urlList[0].directory() );
642
CVSEntry entry = cvsdir.fileStatus( urlList[0].fileName() );
644
DiffDialog dlg(entry);
645
if (dlg.exec() != QDialog::Accepted)
648
CvsOptions *options = CvsOptions::instance();
649
DCOPRef cvsJob = m_cvsService->diff( fileList()[0], dlg.revA(),
650
dlg.revB(), options->diffOptions(), options->contextLines() );
651
if (!m_cvsService->ok())
653
KMessageBox::sorry( 0, i18n("Sorry, cannot diff."),
654
i18n("Error During Diff") );
658
m_scheduler->schedule( cvsJob );
659
connect( processWidget(), SIGNAL(jobFinished(bool,int)),
660
this, SLOT(slotDiffFinished(bool,int)) );
665
///////////////////////////////////////////////////////////////////////////////
667
void CvsServicePartImpl::tag( const KURL::List& urlList )
669
kdDebug(9006) << k_funcinfo << endl;
671
if (!prepareOperation( urlList, opTag ))
674
TagDialog dlg( i18n("Creating Tag/Branch for files ..."),
675
mainWindow()->main()->centralWidget() );
676
if (dlg.exec() != QDialog::Accepted)
679
DCOPRef cvsJob = m_cvsService->createTag( fileList(), dlg.tagName(),
680
dlg.isBranch(), dlg.force() );
682
m_scheduler->schedule( cvsJob );
683
connect( processWidget(), SIGNAL(jobFinished(bool,int)),
684
this, SLOT(slotJobFinished(bool,int)) );
689
///////////////////////////////////////////////////////////////////////////////
691
void CvsServicePartImpl::unTag( const KURL::List& urlList )
693
kdDebug(9006) << k_funcinfo << endl;
695
if (!prepareOperation( urlList, opUnTag ))
698
TagDialog dlg( i18n("Removing Tag from files ..."),
699
mainWindow()->main()->centralWidget() );
700
dlg.tagAsBranchCheck->hide();
701
if (dlg.exec() != QDialog::Accepted)
704
DCOPRef cvsJob = m_cvsService->deleteTag( fileList(), dlg.tagName(),
705
dlg.isBranch(), dlg.force() );
707
m_scheduler->schedule( cvsJob );
708
connect( processWidget(), SIGNAL(jobFinished(bool,int)),
709
this, SLOT(slotJobFinished(bool,int)) );
714
///////////////////////////////////////////////////////////////////////////////
716
void CvsServicePartImpl::addToIgnoreList( const KURL::List& urlList )
718
addToIgnoreList( projectDirectory(), urlList );
721
///////////////////////////////////////////////////////////////////////////////
723
void CvsServicePartImpl::removeFromIgnoreList( const KURL::List& urlList )
725
removeFromIgnoreList( projectDirectory(), urlList );
728
///////////////////////////////////////////////////////////////////////////////
731
* \FIXME Current implementation doesn't use CvsService :-( I just ported the
732
* old code which relies on buildcvs.sh script. [marios]
734
void CvsServicePartImpl::createNewProject( const QString &dirName,
735
const QString &cvsRsh, const QString &location,
736
const QString &message, const QString &module, const QString &vendor,
737
const QString &release, bool mustInitRoot )
739
kdDebug( 9006 ) << "====> CvsServicePartImpl::createNewProject( const QString& )" << endl;
741
CvsOptions *options = CvsOptions::instance();
742
options->setCvsRshEnvVar( cvsRsh );
743
options->setLocation( location );
745
//virtual DCOPRef import( const QString& workingDir, const QString& repository, const QString& module, const QString& ignoreList, const QString& comment, const
746
QString filesToIgnore;
747
DCOPRef cvsJob = m_cvsService->import( dirName, location, module, filesToIgnore, message, vendor, release, false );
749
m_scheduler->schedule( cvsJob );
750
connect( processWidget(), SIGNAL(jobFinished(bool,int)), this, SLOT(slotCheckoutFinished(bool,int)) );
752
QString rsh_preamble;
753
if ( !options->cvsRshEnvVar().isEmpty() )
754
rsh_preamble = "CVS_RSH=" + KShellProcess::quote( options->cvsRshEnvVar() );
759
init = rsh_preamble + " cvs -d " + KShellProcess::quote( options->location() ) + " init && ";
761
QString cmdLine = init + "cd " + KShellProcess::quote(dirName) +
762
" && " + rsh_preamble +
763
" cvs -d " + KShellProcess::quote(options->location()) +
764
" import -m " + KShellProcess::quote(message) + " " +
765
KShellProcess::quote(module) + " " +
766
KShellProcess::quote(vendor) + " " +
767
KShellProcess::quote(release) +
768
// CVS build-up magic here ...
770
locate("data","kdevcvsservice/buildcvs.sh") + " . " +
771
KShellProcess::quote(module) + " " +
772
KShellProcess::quote(location);
774
kdDebug( 9006 ) << " ** Will run the following command: " << endl << cmdLine << endl;
775
kdDebug( 9006 ) << " ** on directory: " << dirName << endl;
777
if (KDevMakeFrontend *makeFrontend = m_part->extension<KDevMakeFrontend>("KDevelop/MakeFrontend"))
778
makeFrontend->queueCommand( dirName, cmdLine );
781
///////////////////////////////////////////////////////////////////////////////
783
bool CvsServicePartImpl::requestCvsService()
788
if (KApplication::startServiceByDesktopName( "cvsservice",
789
QStringList(), &error, &appId ))
791
QString msg = i18n( "Unable to find the Cervisia KPart. \n"
792
"Cervisia Integration will not be available. Please check your\n"
793
"Cervisia installation and re-try. Reason was:\n" ) + error;
794
KMessageBox::error( processWidget(), msg, "DCOP Error" );
800
m_cvsService = new CvsService_stub( appId, "CvsService" );
801
m_repository = new Repository_stub( appId, "CvsRepository" );
807
///////////////////////////////////////////////////////////////////////////////
809
void CvsServicePartImpl::releaseCvsService()
812
m_cvsService->quit();
819
///////////////////////////////////////////////////////////////////////////////
821
void CvsServicePartImpl::flushJobs()
823
processWidget()->cancelJob();
826
///////////////////////////////////////////////////////////////////////////////
828
void CvsServicePartImpl::addFilesToProject( const QStringList &filesToAdd )
830
kdDebug( 9006 ) << k_funcinfo << " " << filesToAdd << endl;
832
QStringList filesInCVS = checkFileListAgainstCVS( filesToAdd );
833
if (filesInCVS.isEmpty())
836
kdDebug( 9006 ) << k_funcinfo << " " << filesInCVS << endl;
838
int s = KMessageBox::questionYesNo( 0,
839
i18n("Do you want the files to be added to CVS repository too?"),
840
i18n("CVS - New Files Added to Project"),
843
i18n("askWhenAddingNewFiles") );
844
if (s == KMessageBox::Yes)
846
kdDebug( 9006 ) << "Adding these files: " << filesInCVS.join( ", " ) << endl;
848
const KURL::List urls = KURL::List( filesInCVS );
849
URLUtil::dump( urls );
854
///////////////////////////////////////////////////////////////////////////////
856
void CvsServicePartImpl::removedFilesFromProject(const QStringList &filesToRemove)
858
kdDebug( 9006 ) << k_funcinfo << endl;
860
QStringList filesInCVS = checkFileListAgainstCVS( filesToRemove );
861
if (filesInCVS.isEmpty())
864
int s = KMessageBox::warningContinueCancel( 0,
865
i18n("Do you want them to be removed from CVS repository too?\nWarning: They will be removed from disk too."),
866
i18n("CVS - Files Removed From Project"),
868
i18n("askWhenRemovingFiles") );
870
if (s == KMessageBox::Continue)
872
kdDebug( 9006 ) << "Removing these files: " << filesInCVS.join( ", " ) << endl;
873
const KURL::List urls = KURL::List( filesInCVS );
874
URLUtil::dump( urls );
879
///////////////////////////////////////////////////////////////////////////////
881
QStringList CvsServicePartImpl::checkFileListAgainstCVS( const QStringList &filesToCheck ) const
883
QStringList filesInCVS;
884
for (QStringList::const_iterator it = filesToCheck.begin(); it != filesToCheck.end(); ++it )
886
const QString &fn = (*it);
889
fi = projectDirectory() + QDir::separator() + fn;
890
if (isValidDirectory( fi.dirPath( true ) ))
891
filesInCVS += ( fi.filePath() );
897
///////////////////////////////////////////////////////////////////////////////
899
void CvsServicePartImpl::emitFileStateModified( const KURL::List &/*urls*/, VCSFileInfo::FileState &/*commonState*/ )
903
///////////////////////////////////////////////////////////////////////////////
905
KDevVCSFileInfoProvider *CvsServicePartImpl::fileInfoProvider() const
907
return m_fileInfoProvider;
910
///////////////////////////////////////////////////////////////////////////////
912
///////////////////////////////////////////////////////////////////////////////
914
void CvsServicePartImpl::slotDiffFinished( bool normalExit, int exitStatus )
916
core()->running( m_part, false );
918
QString diff = processWidget()->output().join("\n"),
919
err = processWidget()->errors().join("\n");
921
kdDebug( 9006 ) << "diff = " << diff << endl;
922
kdDebug( 9006 ) << "err = " << err << endl;
925
kdDebug( 9006 ) << " *** Process died nicely with exit status = " <<
928
kdDebug( 9999 ) << " *** Process was killed with exit status = " <<
931
// Now show a message about operation ending status
932
if (diff.isEmpty() && (exitStatus != 0))
934
KMessageBox::information( 0, i18n("Operation aborted (process killed)."),
938
if ( diff.isEmpty() && !err.isEmpty() )
940
KMessageBox::detailedError( 0, i18n("CVS outputted errors during diff."),
941
err, i18n("Errors During Diff") );
945
if ( !err.isEmpty() )
947
int s = KMessageBox::warningContinueCancelList( 0,
948
i18n("CVS output errors during diff. Do you still want to continue?"),
949
QStringList::split( "\n", err, false ), i18n("Errors During Diff")
951
if ( s != KMessageBox::Continue )
955
if ( diff.isEmpty() )
957
KMessageBox::information( 0, i18n("There is no difference to the repository."),
958
i18n("No Difference Found") );
962
Q_ASSERT( diffFrontend() );
963
diffFrontend()->showDiff( diff );
966
///////////////////////////////////////////////////////////////////////////////
968
void CvsServicePartImpl::slotCheckoutFinished( bool exitStatus, int )
970
kdDebug(9006) << "CvsServicePartImpl::slotCheckoutFinished(): job ended with status == "
971
<< exitStatus << endl;
972
// Return a null string if the operation was not succesfull
974
modulePath = QString::null;
976
kdDebug(9006) << " I'll emit modulePath == " << modulePath << endl;
978
emit checkoutFinished( modulePath );
981
///////////////////////////////////////////////////////////////////////////////
983
void CvsServicePartImpl::slotJobFinished( bool /*exitStatus*/, int exitCode )
985
// Return a null string if the operation was not succesfull
986
kdDebug(9006) << "CvsServicePartImpl::slotJobFinished(): job ended with code == "
989
// Operation has been successfull
993
// 1. Assemble the CVSFileInfoList
994
// 2. notify all clients
998
///////////////////////////////////////////////////////////////////////////////
1000
void CvsServicePartImpl::slotProjectOpened()
1002
kdDebug(9006) << "CvsServicePartImpl::slotProjectOpened(): setting work directory to "
1003
<< projectDirectory() << endl;
1007
m_repository->setWorkingCopy( projectDirectory() );
1012
#include "cvspartimpl.moc"