diff --git a/plugins/cvs/cvsplugin.cpp b/plugins/cvs/cvsplugin.cpp index 6802cbcd9d..36bbdacd11 100644 --- a/plugins/cvs/cvsplugin.cpp +++ b/plugins/cvs/cvsplugin.cpp @@ -1,489 +1,489 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cvsplugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cvsmainview.h" #include "cvsproxy.h" #include "cvsjob.h" #include "editorsview.h" #include "commitdialog.h" #include "cvsgenericoutputview.h" #include "checkoutdialog.h" #include "importdialog.h" #include "importmetadatawidget.h" #include #include #include K_PLUGIN_FACTORY(KDevCvsFactory, registerPlugin();) K_EXPORT_PLUGIN(KDevCvsFactory(KAboutData("kdevcvs", "kdevcvs", ki18n("CVS"), "0.1", ki18n("Support for CVS version control system"), KAboutData::License_GPL))) class KDevCvsViewFactory: public KDevelop::IToolViewFactory { public: KDevCvsViewFactory(CvsPlugin *plugin): m_plugin(plugin) {} virtual QWidget* create(QWidget *parent = 0) { return new CvsMainView(m_plugin, parent); } virtual Qt::DockWidgetArea defaultPosition() { return Qt::BottomDockWidgetArea; } virtual QString id() const { return "org.kdevelop.CVSView"; } private: CvsPlugin *m_plugin; }; class CvsPluginPrivate { public: explicit CvsPluginPrivate(CvsPlugin *pThis) : m_factory(new KDevCvsViewFactory(pThis)) , m_proxy(new CvsProxy(pThis)) , m_common(new KDevelop::VcsPluginHelper(pThis, pThis)) {} KDevCvsViewFactory* m_factory; QPointer m_proxy; std::auto_ptr m_common; }; CvsPlugin::CvsPlugin(QObject *parent, const QVariantList &) : KDevelop::IPlugin(KDevCvsFactory::componentData(), parent) , d(new CvsPluginPrivate(this)) { KDEV_USE_EXTENSION_INTERFACE(KDevelop::IBasicVersionControl) KDEV_USE_EXTENSION_INTERFACE(KDevelop::ICentralizedVersionControl) core()->uiController()->addToolView(i18n("CVS"), d->m_factory); setXMLFile("kdevcvs.rc"); setupActions(); } CvsPlugin::~CvsPlugin() { } void CvsPlugin::unload() { core()->uiController()->removeToolView( d->m_factory ); } CvsProxy* CvsPlugin::proxy() { return d->m_proxy; } void CvsPlugin::setupActions() { KAction *action; action = actionCollection()->addAction("cvs_import"); action->setText(i18n("Import Directory...")); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotImport())); action = actionCollection()->addAction("cvs_checkout"); action->setText(i18n("Checkout...")); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotCheckout())); action = actionCollection()->addAction("cvs_status"); action->setText(i18n("Status...")); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotStatus())); } const KUrl CvsPlugin::urlFocusedDocument() const { KParts::ReadOnlyPart *plugin = dynamic_cast(core()->partController()->activePart()); if (plugin) { if (plugin->url().isLocalFile()) { return plugin->url(); } } return KUrl(); } void CvsPlugin::slotImport() { KUrl url = urlFocusedDocument(); ImportDialog dlg(this, url); dlg.exec(); } void CvsPlugin::slotCheckout() { ///@todo don't use proxy directly; use interface instead CheckoutDialog dlg(this); dlg.exec(); } void CvsPlugin::slotStatus() { KUrl url = urlFocusedDocument(); KUrl::List urls; urls << url; KDevelop::VcsJob* j = status(url, KDevelop::IBasicVersionControl::Recursive); CvsJob* job = dynamic_cast(j); if (job) { CvsGenericOutputView* view = new CvsGenericOutputView(this, job); emit addNewTabToMainView(view, i18n("Status")); KDevelop::ICore::self()->runController()->registerJob(job); } } KDevelop::ContextMenuExtension CvsPlugin::contextMenuExtension(KDevelop::Context* context) { d->m_common->setupFromContext(context); KUrl::List const & ctxUrlList = d->m_common->contextUrlList(); bool hasVersionControlledEntries = false; foreach(const KUrl &url, ctxUrlList) { - if (isVersionControlled(url)) { + if (d->m_proxy->isValidDirectory(url)) { hasVersionControlledEntries = true; break; } } kDebug() << "version controlled?" << hasVersionControlledEntries; if (!hasVersionControlledEntries) return IPlugin::contextMenuExtension(context); QMenu* menu = d->m_common->commonActions(); menu->addSeparator(); KAction *action; // Just add actions which are not covered by the cvscommon plugin action = new KAction(i18n("Edit"), this); connect(action, SIGNAL(triggered()), this, SLOT(ctxEdit())); menu->addAction(action); action = new KAction(i18n("Unedit"), this); connect(action, SIGNAL(triggered()), this, SLOT(ctxUnEdit())); menu->addAction(action); action = new KAction(i18n("Show Editors"), this); connect(action, SIGNAL(triggered()), this, SLOT(ctxEditors())); menu->addAction(action); KDevelop::ContextMenuExtension menuExt; menuExt.addAction(KDevelop::ContextMenuExtension::VcsGroup, menu->menuAction()); return menuExt; } void CvsPlugin::ctxEdit() { KUrl::List const & urls = d->m_common->contextUrlList(); Q_ASSERT(!urls.empty()); KDevelop::VcsJob* j = edit(urls.front()); CvsJob* job = dynamic_cast(j); if (job) { connect(job, SIGNAL(result(KJob*)), this, SIGNAL(jobFinished(KJob*))); KDevelop::ICore::self()->runController()->registerJob(job); } } void CvsPlugin::ctxUnEdit() { KUrl::List const & urls = d->m_common->contextUrlList(); Q_ASSERT(!urls.empty()); KDevelop::VcsJob* j = unedit(urls.front()); CvsJob* job = dynamic_cast(j); if (job) { connect(job, SIGNAL(result(KJob*)), this, SIGNAL(jobFinished(KJob*))); KDevelop::ICore::self()->runController()->registerJob(job); } } void CvsPlugin::ctxEditors() { KUrl::List const & urls = d->m_common->contextUrlList(); Q_ASSERT(!urls.empty()); CvsJob* job = d->m_proxy->editors(findWorkingDir(urls.front().toLocalFile()), urls); if (job) { KDevelop::ICore::self()->runController()->registerJob(job); EditorsView* view = new EditorsView(this, job); emit addNewTabToMainView(view, i18n("Editors")); } } QString CvsPlugin::findWorkingDir(const KUrl& location) { QFileInfo fileInfo(location.toLocalFile()); // find out correct working directory if (fileInfo.isFile()) { return fileInfo.absolutePath(); } else { return fileInfo.absoluteFilePath(); } } // Begin: KDevelop::IBasicVersionControl bool CvsPlugin::isVersionControlled(const KUrl & localLocation) { - return d->m_proxy->isValidDirectory(localLocation); + return d->m_proxy->isVersionControlled(localLocation); } KDevelop::VcsJob * CvsPlugin::repositoryLocation(const KUrl & localLocation) { Q_UNUSED(localLocation); return NULL; } KDevelop::VcsJob * CvsPlugin::add(const KUrl::List & localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) { CvsJob* job = d->m_proxy->add(findWorkingDir(localLocations[0].toLocalFile()), localLocations, (recursion == KDevelop::IBasicVersionControl::Recursive) ? true : false); return job; } KDevelop::VcsJob * CvsPlugin::remove(const KUrl::List & localLocations) { CvsJob* job = d->m_proxy->remove(findWorkingDir(localLocations[0].toLocalFile()), localLocations); return job; } KDevelop::VcsJob * CvsPlugin::localRevision(const KUrl & localLocation, KDevelop::VcsRevision::RevisionType) { Q_UNUSED(localLocation) return NULL; } KDevelop::VcsJob * CvsPlugin::status(const KUrl::List & localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) { CvsJob* job = d->m_proxy->status(findWorkingDir(localLocations[0].toLocalFile()), localLocations, (recursion == KDevelop::IBasicVersionControl::Recursive) ? true : false); return job; } KDevelop::VcsJob * CvsPlugin::unedit(const KUrl & localLocation) { CvsJob* job = d->m_proxy->unedit(findWorkingDir(localLocation.toLocalFile()), localLocation); return job; } KDevelop::VcsJob * CvsPlugin::edit(const KUrl & localLocation) { CvsJob* job = d->m_proxy->edit(findWorkingDir(localLocation.toLocalFile()), localLocation); return job; } KDevelop::VcsJob * CvsPlugin::copy(const KUrl & localLocationSrc, const KUrl & localLocationDstn) { bool ok = QFile::copy(localLocationSrc.toLocalFile(), localLocationDstn.path()); if (!ok) { return NULL; } KUrl::List listDstn; listDstn << localLocationDstn; CvsJob* job = d->m_proxy->add(findWorkingDir(localLocationDstn.toLocalFile()), listDstn, true); return job; } KDevelop::VcsJob * CvsPlugin::move(const KUrl &, const KUrl &) { return NULL; } KDevelop::VcsJob * CvsPlugin::revert(const KUrl::List & localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) { KDevelop::VcsRevision rev; CvsJob* job = d->m_proxy->update(findWorkingDir(localLocations[0].toLocalFile()), localLocations, rev, "-C", (recursion == KDevelop::IBasicVersionControl::Recursive) ? true : false, false, false); return job; } KDevelop::VcsJob * CvsPlugin::update(const KUrl::List & localLocations, const KDevelop::VcsRevision & rev, KDevelop::IBasicVersionControl::RecursionMode recursion) { CvsJob* job = d->m_proxy->update(findWorkingDir(localLocations[0].toLocalFile()), localLocations, rev, "", (recursion == KDevelop::IBasicVersionControl::Recursive) ? true : false, false, false); return job; } KDevelop::VcsJob * CvsPlugin::commit(const QString & message, const KUrl::List & localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) { Q_UNUSED(recursion); QString msg = message; if (msg.isEmpty()) { CommitDialog dlg; if (dlg.exec() == QDialog::Accepted) { msg = dlg.message(); } } CvsJob* job = d->m_proxy->commit(findWorkingDir(localLocations[0].toLocalFile()), localLocations, msg); return job; } KDevelop::VcsJob * CvsPlugin::diff(const KUrl & fileOrDirectory, const KDevelop::VcsRevision & srcRevision, const KDevelop::VcsRevision & dstRevision, KDevelop::VcsDiff::Type, KDevelop::IBasicVersionControl::RecursionMode) { CvsJob* job = d->m_proxy->diff(fileOrDirectory, srcRevision, dstRevision, "-uN"/*always unified*/); return job; } KDevelop::VcsJob * CvsPlugin::log(const KUrl & localLocation, const KDevelop::VcsRevision & rev, unsigned long limit) { Q_UNUSED(limit) CvsJob* job = d->m_proxy->log(localLocation, rev); return job; } KDevelop::VcsJob * CvsPlugin::log(const KUrl & localLocation, const KDevelop::VcsRevision & rev, const KDevelop::VcsRevision & limit) { Q_UNUSED(limit) return log(localLocation, rev, 0); } KDevelop::VcsJob * CvsPlugin::annotate(const KUrl & localLocation, const KDevelop::VcsRevision & rev) { CvsJob* job = d->m_proxy->annotate(localLocation, rev); return job; } KDevelop::VcsJob * CvsPlugin::resolve(const KUrl::List & localLocations, KDevelop::IBasicVersionControl::RecursionMode recursion) { Q_UNUSED(localLocations); Q_UNUSED(recursion); return NULL; } KDevelop::VcsJob * CvsPlugin::import(const QString& commitMessage, const KUrl& sourceDirectory, const KDevelop::VcsLocation& destinationRepository) { if (commitMessage.isEmpty() || !sourceDirectory.isLocalFile() || !destinationRepository.isValid() || destinationRepository.type() != KDevelop::VcsLocation::RepositoryLocation) { return 0; } kDebug(9500) << "CVS Import requested " << "src:" << sourceDirectory.toLocalFile() << "srv:" << destinationRepository.repositoryServer() << "module:" << destinationRepository.repositoryModule(); CvsJob* job = d->m_proxy->import(sourceDirectory, destinationRepository.repositoryServer(), destinationRepository.repositoryModule(), destinationRepository.userData().toString(), destinationRepository.repositoryTag(), commitMessage); return job; } KDevelop::VcsJob * CvsPlugin::createWorkingCopy(const KDevelop::VcsLocation & sourceRepository, const KUrl & destinationDirectory, KDevelop::IBasicVersionControl::RecursionMode recursion) { Q_UNUSED(recursion); if (!destinationDirectory.isLocalFile() || !sourceRepository.isValid() || sourceRepository.type() != KDevelop::VcsLocation::RepositoryLocation) { return 0; } kDebug(9500) << "CVS Checkout requested " << "dest:" << destinationDirectory.toLocalFile() << "srv:" << sourceRepository.repositoryServer() << "module:" << sourceRepository.repositoryModule() << "branch:" << sourceRepository.repositoryBranch() << endl; CvsJob* job = d->m_proxy->checkout(destinationDirectory, sourceRepository.repositoryServer(), sourceRepository.repositoryModule(), "", sourceRepository.repositoryBranch(), true, true); return job; } QString CvsPlugin::name() const { return i18n("CVS"); } KDevelop::VcsImportMetadataWidget* CvsPlugin::createImportMetadataWidget(QWidget* parent) { return new ImportMetadataWidget(parent); } KDevelop::VcsLocationWidget* CvsPlugin::vcsLocation(QWidget* parent) const { return new KDevelop::StandardVcsLocationWidget(parent); } // End: KDevelop::IBasicVersionControl #include "cvsplugin.moc" diff --git a/plugins/cvs/cvsproxy.cpp b/plugins/cvs/cvsproxy.cpp index b21c624fc7..a2cb216518 100644 --- a/plugins/cvs/cvsproxy.cpp +++ b/plugins/cvs/cvsproxy.cpp @@ -1,463 +1,485 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cvsproxy.h" #include #include #include #include #include #include #include #include #include "cvsjob.h" #include "cvsannotatejob.h" #include "cvslogjob.h" #include "cvsstatusjob.h" #include "cvsdiffjob.h" #include CvsProxy::CvsProxy(KDevelop::IPlugin* parent) : QObject(parent), vcsplugin(parent) { } CvsProxy::~CvsProxy() { } bool CvsProxy::isValidDirectory(const KUrl & dirPath) const { - QString path = dirPath.toLocalFile(); - QFileInfo fsObject(path); - if (fsObject.isFile()) - path = fsObject.path() + QDir::separator() + "CVS"; - else - path = path + QDir::separator() + "CVS"; - fsObject.setFile(path); + QFileInfo fsObject( dirPath.toLocalFile() ); + if( !fsObject.isDir() ) + dirPath.setFileName( QString() ); + + dirPath.addPath( "CVS" ); + fsObject.setFile( dirPath.toLocalFile() ); return fsObject.exists(); } +bool CvsProxy::isVersionControlled(const KUrl& filePath) const +{ + QFileInfo fsObject( filePath.toLocalFile() ); + if( !fsObject.isDir() ) + filePath.setFileName( QString() ); + + filePath.addPath( "CVS" ); + QFileInfo cvsObject( filePath.toLocalFile() ); + if( !cvsObject.exists() ) + return false; + + if( fsObject.isDir() ) + return true; + + filePath.addPath( "Entries" ); + QFile cvsEntries( filePath.toLocalFile() ); + cvsEntries.open( QIODevice::ReadOnly ); + QString cvsEntriesData = cvsEntries.readAll(); + cvsEntries.close(); + return ( cvsEntriesData.indexOf( fsObject.fileName() ) != -1 ); +} + + bool CvsProxy::prepareJob(CvsJob* job, const QString& repository, enum RequestedOperation op) { // Only do this check if it's a normal operation like diff, log ... // For other operations like "cvs import" isValidDirectory() would fail as the // directory is not yet under CVS control if (op == CvsProxy::NormalOperation && !isValidDirectory(repository)) { kDebug(9500) << repository << " is not a valid CVS repository"; return false; } // clear commands and args from a possible previous run job->clear(); // setup the working directory for the new job job->setDirectory(repository); return true; } bool CvsProxy::addFileList(CvsJob* job, const QString& repository, const KUrl::List& urls) { QStringList args; foreach(const KUrl &url, urls) { ///@todo this is ok for now, but what if some of the urls are not /// to the given repository QString file = KUrl::relativeUrl(QString(repository + QDir::separator()), url); args << KShell::quoteArg( file ); } *job << args; return true; } QString CvsProxy::convertVcsRevisionToString(const KDevelop::VcsRevision & rev) { QString str; switch (rev.revisionType()) { case KDevelop::VcsRevision::Special: break; case KDevelop::VcsRevision::FileNumber: if (rev.revisionValue().isValid()) str = "-r"+rev.revisionValue().toString(); break; case KDevelop::VcsRevision::Date: if (rev.revisionValue().isValid()) str = "-D"+rev.revisionValue().toString(); break; case KDevelop::VcsRevision::GlobalNumber: // !! NOT SUPPORTED BY CVS !! default: break; } return str; } QString CvsProxy::convertRevisionToPrevious(const KDevelop::VcsRevision& rev) { QString str; // this only works if the revision is a real revisionnumber and not a date or special switch (rev.revisionType()) { case KDevelop::VcsRevision::FileNumber: if (rev.revisionValue().isValid()) { QString orig = rev.revisionValue().toString(); // First we need to find the base (aka branch-part) of the revision number which will not change QString base(orig); base.truncate(orig.lastIndexOf(".")); // next we need to cut off the last part of the revision number // this number is a count of revisions with a branch // so if we want to diff to the previous we just need to lower it by one int number = orig.mid(orig.lastIndexOf(".")+1).toInt(); if (number > 1) // of course this is only possible if our revision is not the first on the branch number--; str = QString("-r") + base + '.' + QString::number(number); kDebug(9500) << "Converted revision "<(); if (specialtype == KDevelop::VcsRevision::Previous) { rA = convertRevisionToPrevious(revB); } } else { rA = convertVcsRevisionToString(revA); } if (!rA.isEmpty()) *job << rA; QString rB = convertVcsRevisionToString(revB); if (!rB.isEmpty()) *job << rB; // in case the KUrl is a directory there is no filename if (!info.fileName().isEmpty()) *job << KShell::quoteArg(info.fileName()); return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::annotate(const KUrl & url, const KDevelop::VcsRevision& rev) { QFileInfo info(url.toLocalFile()); CvsAnnotateJob* job = new CvsAnnotateJob(vcsplugin); if ( prepareJob(job, info.absolutePath()) ) { *job << "cvs"; *job << "annotate"; QString revision = convertVcsRevisionToString(rev); if (!revision.isEmpty()) *job << revision; *job << KShell::quoteArg(info.fileName()); return job; } if (job) delete job; return NULL; } CvsJob* CvsProxy::edit(const QString& repo, const KUrl::List& files) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "edit"; addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob* CvsProxy::unedit(const QString& repo, const KUrl::List& files) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "unedit"; addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob* CvsProxy::editors(const QString& repo, const KUrl::List& files) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "editors"; addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob* CvsProxy::commit(const QString& repo, const KUrl::List& files, const QString& message) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "commit"; *job << "-m"; *job << KShell::quoteArg( message ); addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob* CvsProxy::add(const QString & repo, const KUrl::List & files, bool recursiv, bool binary) { Q_UNUSED(recursiv); // FIXME recursiv is not implemented yet CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "add"; if (binary) { *job << "-kb"; } addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::remove(const QString & repo, const KUrl::List & files) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "remove"; *job << "-f"; //existing files will be deleted addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::update(const QString & repo, const KUrl::List & files, const KDevelop::VcsRevision & rev, const QString & updateOptions, bool recursive, bool pruneDirs, bool createDirs) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "update"; if (recursive) *job << "-R"; else *job << "-L"; if (pruneDirs) *job << "-P"; if (createDirs) *job << "-d"; if (!updateOptions.isEmpty()) *job << updateOptions; QString revision = convertVcsRevisionToString(rev); if (!revision.isEmpty()) *job << revision; addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::import(const KUrl & directory, const QString & server, const QString & repositoryName, const QString & vendortag, const QString & releasetag, const QString& message) { CvsJob* job = new CvsJob(vcsplugin); if ( prepareJob(job, directory.toLocalFile(), CvsProxy::Import) ) { *job << "cvs"; *job << "-q"; // don't print directory changes *job << "-d"; *job << server; *job << "import"; *job << "-m"; *job << KShell::quoteArg( message ); *job << repositoryName; *job << vendortag; *job << releasetag; return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::checkout(const KUrl & targetDir, const QString & server, const QString & module, const QString & checkoutOptions, const QString & revision, bool recursive, bool pruneDirs) { CvsJob* job = new CvsJob(vcsplugin); ///@todo when doing a checkout we don't have the targetdir yet, /// for now it'll work to just run the command from the root if ( prepareJob(job, "/", CvsProxy::CheckOut) ) { *job << "cvs"; *job << "-q"; // don't print directory changes *job << "-d" << server; *job << "checkout"; if (!checkoutOptions.isEmpty()) *job << checkoutOptions; if (!revision.isEmpty()) { *job << "-r" << revision; } if (pruneDirs) *job << "-P"; if (!recursive) *job << "-l"; *job << "-d" << targetDir.toLocalFile(KUrl::RemoveTrailingSlash); *job << module; return job; } if (job) delete job; return NULL; } CvsJob * CvsProxy::status(const QString & repo, const KUrl::List & files, bool recursive, bool taginfo) { CvsStatusJob* job = new CvsStatusJob(vcsplugin); job->setCommunicationMode( KProcess::MergedChannels ); if ( prepareJob(job, repo) ) { *job << "cvs"; *job << "status"; if (recursive) *job << "-R"; else *job << "-l"; if (taginfo) *job << "-v"; addFileList(job, repo, files); return job; } if (job) delete job; return NULL; } #include "cvsproxy.moc" diff --git a/plugins/cvs/cvsproxy.h b/plugins/cvs/cvsproxy.h index 61722398e9..9a660c5f24 100644 --- a/plugins/cvs/cvsproxy.h +++ b/plugins/cvs/cvsproxy.h @@ -1,106 +1,107 @@ /*************************************************************************** * Copyright 2007 Robert Gruber * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CVSPROXY_H #define CVSPROXY_H #include #include #include class CvsJob; namespace KDevelop { class IPlugin; } /** * This proxy acts as a single point of entry for most of the common cvs commands. * It is very easy to use, as the caller does not have to deal which the CvsJob class directly. * All the command line generation and job handling is done internally. The caller gets a CvsJob * object returned from the proxy and can then call it's start() method. * * Here is and example of how to user the proxy: * @code * CvsJob* job = proxy->editors( repo, urls ); * if ( job ) { * connect(job, SIGNAL( result(KJob*) ), * this, SIGNAL( jobFinished(KJob*) )); * job->start(); * } * @endcode * * @note All actions that take a KUrl::List also need an url to the repository which * must be a common base directory to all files from the KUrl::List. * Actions that just take a single KUrl don't need a repository, the cvs command will be * called directly in the directory of the given file * * @author Robert Gruber */ class CvsProxy : public QObject { Q_OBJECT public: CvsProxy(KDevelop::IPlugin* parent = 0); ~CvsProxy(); bool isValidDirectory(const KUrl &dirPath) const; + bool isVersionControlled(const KUrl& filePath) const; CvsJob* import(const KUrl& directory, const QString & server, const QString& repositoryName, const QString& vendortag, const QString& releasetag, const QString& message); CvsJob* log(const KUrl& file, const KDevelop::VcsRevision& rev); CvsJob* diff(const KUrl& url, const KDevelop::VcsRevision& revA, const KDevelop::VcsRevision& revB, const QString& diffOptions=""); CvsJob* annotate(const KUrl& url, const KDevelop::VcsRevision& rev); CvsJob* edit(const QString& repo, const KUrl::List& files); CvsJob* unedit(const QString& repo, const KUrl::List& files); CvsJob* editors(const QString& repo, const KUrl::List& files); CvsJob* commit(const QString& repo, const KUrl::List& files, const QString& message); CvsJob* add(const QString& repo, const KUrl::List& files, bool recursiv = true, bool binary = false); CvsJob* remove(const QString& repo, const KUrl::List& files); CvsJob* update(const QString& repo, const KUrl::List& files, const KDevelop::VcsRevision& rev, const QString& updateOptions, bool resursive = true, bool pruneDirs = true, bool createDirs = true); CvsJob* checkout(const KUrl& targetDir, const QString & server, const QString& module, const QString& checkoutOptions="", const QString& revision="", bool recursive = true, bool pruneDirs = true); CvsJob* status(const QString & repo, const KUrl::List & files, bool recursive=false, bool taginfo=false); private: bool addFileList(CvsJob* job, const QString& repository, const KUrl::List& urls); QString convertVcsRevisionToString(const KDevelop::VcsRevision& rev); QString convertRevisionToPrevious(const KDevelop::VcsRevision& rev); enum RequestedOperation { NormalOperation, Import, CheckOut }; bool prepareJob(CvsJob* job, const QString& repository, enum RequestedOperation op = CvsProxy::NormalOperation); KDevelop::IPlugin* vcsplugin; }; #endif