[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevelop/lib/plugins/vcs/cvs
From:       Robert Gruber <rgruber () users ! sourceforge ! net>
Date:       2007-04-14 21:37:53
Message-ID: 1176586673.025390.23683.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 654035 by rgruber:

* Some minor changes in CvsProxy to make it independent from CvsPart and
  therefore easier to use in tests.
* Added "cvs import" feature.


 M  +2 -0      CMakeLists.txt  
 M  +25 -4     cvspart.cpp  
 M  +1 -0      cvspart.h  
 M  +42 -7     cvsproxy.cpp  
 M  +13 -4     cvsproxy.h  
 A             importdialog.cpp   [License: GPL (v2+)]
 A             importdialog.h   [License: GPL (v2+)]
 A             importdialog.ui  
 M  +1 -0      kdevcvs.rc  


--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/CMakeLists.txt #654034:654035
@@ -19,6 +19,7 @@
 	logview.cpp
 	commitdialog.cpp
 	updateoptionsdialog.cpp
+	importdialog.cpp
 )
 
 set(kdevcvs_PART_UI
@@ -29,6 +30,7 @@
 	logview.ui
 	commitdialog.ui
 	updateoptionsdialog.ui
+	importdialog.ui
 )
 
 kde4_add_ui_files(kdevcvs_PART_SRCS ${kdevcvs_PART_UI})
--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/cvspart.cpp #654034:654035
@@ -33,6 +33,7 @@
 #include "commitdialog.h"
 #include "updateoptionsdialog.h"
 #include "cvsgenericoutputview.h"
+#include "importdialog.h"
 
 typedef KGenericFactory<CvsPart> KDevCvsFactory;
 K_EXPORT_COMPONENT_FACTORY( kdevcvs,
@@ -124,6 +125,10 @@
     action->setText(i18n("Update Files..."));
     connect(action, SIGNAL(triggered(bool)), this, SLOT(slotUpdate()));
 
+    action = actionCollection()->addAction("cvs_import");
+    action->setText(i18n("Import Directory..."));
+    connect(action, SIGNAL(triggered(bool)), this, SLOT(slotImport()));
+
 }
 
 const KUrl CvsPart::urlFocusedDocument() const
@@ -203,17 +208,34 @@
     editors(urls);
 }
 
+void CvsPart::slotImport()
+{
+    KUrl url = urlFocusedDocument();
 
+    /// @todo just for testing; remove me...
+    // In order to be able the test the ImportDialog and the 
+    // import job I need to get to a directory somehow.
+    // So this is a bit of a hack right now. I take the directory
+    // from the currently opened file are directory to import.
+    // This whole slot will be removed later when createNewProject()
+    // gets called via the IVersionControl interface.
+    QFileInfo info(url.path());
 
+    createNewProject( KUrl(info.absolutePath()) );
+}
 
+
+
+
 ////////////////////////////////////////////////////////////////////////////////
 //  BEGIN of methods derived from IVersionControl
 ////////////////////////////////////////////////////////////////////////////////
 
 void CvsPart::createNewProject(const KUrl & dir)
 {
-    Q_UNUSED(dir)
-    /// @todo implemt me !
+    ImportDialog dlg(this, dir);
+    // the dialog handles the import by itself ...
+    dlg.exec();
 }
 
 void CvsPart::fillContextMenu(const KDevelop::ProjectBaseItem * prjItem, QMenu & ctxMenu)
@@ -232,8 +254,7 @@
 
 bool CvsPart::isValidDirectory(const KUrl & dirPath) const
 {
-    QString path = dirPath.path() + QDir::separator() + "CVS";
-    return QFileInfo(path).exists();
+    return d->m_proxy->isValidDirectory(dirPath);
 }
 
 bool CvsPart::fetchFromRepository()
--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/cvspart.h #654034:654035
@@ -76,6 +76,7 @@
     void slotAdd();
     void slotCommit();
     void slotUpdate();
+    void slotImport();
 
 // Signals inherited from IVersionControl
 Q_SIGNALS:
--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/cvsproxy.cpp #654034:654035
@@ -18,12 +18,10 @@
 #include <KMessageBox>
 #include <K3Process>
 
-#include "cvspart.h"
 #include "cvsjob.h"
 
-
-CvsProxy::CvsProxy(CvsPart* part)
-: QObject(part), m_part(part)
+CvsProxy::CvsProxy(QObject* parent)
+: QObject(parent)
 {
 }
 
@@ -37,9 +35,19 @@
     job->deleteLater();
 }
 
-bool CvsProxy::prepareJob(CvsJob* job, const QString& repository)
+bool CvsProxy::isValidDirectory(const KUrl & dirPath) const
 {
-    if (!m_part->isValidDirectory(repository)) {
+    QString path = dirPath.path() + QDir::separator() + "CVS";
+    return QFileInfo(path).exists();
+}
+
+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() << repository << " is not a valid CVS repository" << endl;
         return false;
     }
@@ -63,7 +71,7 @@
 {
     foreach(KUrl url, urls) {
         //@todo this is ok for now, but what if some of the urls are not
-	//      to the given repository
+        //      to the given repository
         QString file = KUrl::relativeUrl(repository + QDir::separator(), url);
 
         *job << K3Process::quote( file );
@@ -236,5 +244,32 @@
     return NULL;
 }
 
+CvsJob * CvsProxy::import(const KUrl & directory, 
+                          const QString & server, const QString & repositoryName, 
+                          const QString & vendortag, const QString & releasetag,
+                          const QString& message)
+{
+    kDebug() << k_funcinfo << endl;
+
+    CvsJob* job = new CvsJob(this);
+    if ( prepareJob(job, directory.path(), CvsProxy::Import) ) {
+        *job << "cvs";
+        *job << "-d";
+        *job << server;
+        *job << "import";
+
+        *job << "-m";
+        *job << K3Process::quote( message );
+
+        *job << repositoryName;
+        *job << vendortag;
+        *job << releasetag;
+
+        return job;
+    }
+    if (job) delete job;
+    return NULL;
+}
+
 #include "cvsproxy.moc"
 //kate: space-indent on; indent-width 4; replace-tabs on; auto-insert-doxygen on; indent-mode cstyle;
--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/cvsproxy.h #654034:654035
@@ -16,7 +16,6 @@
 #include <KUrl>
 #include <KJob>
 
-class CvsPart;
 class CvsJob;
 
 /**
@@ -50,9 +49,15 @@
 {
     Q_OBJECT
 public:
-    CvsProxy(CvsPart* part);
+    CvsProxy(QObject* parent = 0);
     ~CvsProxy();
 
+    bool isValidDirectory(const KUrl &dirPath) 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);
     CvsJob* diff(const KUrl& url, const QString& diffOptions="", 
               const QString& revA="", const QString& revB="");
@@ -72,9 +77,13 @@
 
 private:
     bool addFileList(CvsJob* job, const QString& repository, const KUrl::List& urls);
-    bool prepareJob(CvsJob* job, const QString& repository);
 
-    CvsPart* m_part;
+    enum RequestedOperation {
+        NormalOperation,
+        Import
+    };
+    bool prepareJob(CvsJob* job, const QString& repository, 
+                    enum RequestedOperation op = CvsProxy::NormalOperation);
 };
 
 #endif
--- trunk/KDE/kdevelop/lib/plugins/vcs/cvs/kdevcvs.rc #654034:654035
@@ -10,6 +10,7 @@
     <Action name="cvs_add" />
     <Action name="cvs_commit" />
     <Action name="cvs_update" />
+    <Action name="cvs_import" />
   </Menu>
 </MenuBar>
 </kpartgui>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic