2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "subversionplugin.h"
|
|
|
|
|
|
|
|
#include "subversioneditor.h"
|
|
|
|
|
|
|
|
#include "subversionsubmiteditor.h"
|
2013-09-27 15:39:16 +02:00
|
|
|
#include "subversionclient.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "subversionconstants.h"
|
2020-01-30 17:02:30 +01:00
|
|
|
#include "subversionsettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
#include <vcsbase/basevcseditorfactory.h>
|
2014-08-27 18:55:41 +02:00
|
|
|
#include <vcsbase/vcscommand.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <vcsbase/vcsbaseeditor.h>
|
|
|
|
#include <vcsbase/basevcssubmiteditorfactory.h>
|
2014-07-28 18:46:34 +02:00
|
|
|
#include <vcsbase/vcsbaseconstants.h>
|
2014-08-26 00:02:47 +02:00
|
|
|
#include <vcsbase/vcsoutputwindow.h>
|
2020-01-30 17:02:30 +01:00
|
|
|
#include <vcsbase/vcsbaseplugin.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <texteditor/textdocument.h>
|
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
#include <coreplugin/documentmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2014-01-13 16:17:34 +01:00
|
|
|
#include <coreplugin/locator/commandlocator.h>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2010-02-12 16:03:08 +01:00
|
|
|
|
2016-10-20 13:06:11 +02:00
|
|
|
#include <utils/algorithm.h>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
#include <utils/parameteraction.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2021-05-05 18:21:22 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2020-06-17 06:35:31 +02:00
|
|
|
#include <utils/stringutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QProcessEnvironment>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QXmlStreamReader>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QInputDialog>
|
2014-07-28 17:47:15 +02:00
|
|
|
|
2018-11-24 21:14:08 +01:00
|
|
|
#include <climits>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-01-19 23:19:38 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
#include <QTest>
|
|
|
|
#endif
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
using namespace Core;
|
|
|
|
using namespace Utils;
|
|
|
|
using namespace VcsBase;
|
2020-02-07 07:51:20 +01:00
|
|
|
using namespace std::placeholders;
|
2014-05-18 19:29:56 +02:00
|
|
|
|
2011-03-25 16:39:33 +01:00
|
|
|
namespace Subversion {
|
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-07-28 17:47:15 +02:00
|
|
|
const char CMD_ID_SUBVERSION_MENU[] = "Subversion.Menu";
|
|
|
|
const char CMD_ID_ADD[] = "Subversion.Add";
|
|
|
|
const char CMD_ID_DELETE_FILE[] = "Subversion.Delete";
|
|
|
|
const char CMD_ID_REVERT[] = "Subversion.Revert";
|
|
|
|
const char CMD_ID_DIFF_PROJECT[] = "Subversion.DiffAll";
|
|
|
|
const char CMD_ID_DIFF_CURRENT[] = "Subversion.DiffCurrent";
|
|
|
|
const char CMD_ID_COMMIT_ALL[] = "Subversion.CommitAll";
|
|
|
|
const char CMD_ID_REVERT_ALL[] = "Subversion.RevertAll";
|
|
|
|
const char CMD_ID_COMMIT_CURRENT[] = "Subversion.CommitCurrent";
|
|
|
|
const char CMD_ID_FILELOG_CURRENT[] = "Subversion.FilelogCurrent";
|
|
|
|
const char CMD_ID_ANNOTATE_CURRENT[] = "Subversion.AnnotateCurrent";
|
|
|
|
const char CMD_ID_STATUS[] = "Subversion.Status";
|
|
|
|
const char CMD_ID_PROJECTLOG[] = "Subversion.ProjectLog";
|
|
|
|
const char CMD_ID_REPOSITORYLOG[] = "Subversion.RepositoryLog";
|
|
|
|
const char CMD_ID_REPOSITORYUPDATE[] = "Subversion.RepositoryUpdate";
|
|
|
|
const char CMD_ID_REPOSITORYDIFF[] = "Subversion.RepositoryDiff";
|
|
|
|
const char CMD_ID_REPOSITORYSTATUS[] = "Subversion.RepositoryStatus";
|
|
|
|
const char CMD_ID_UPDATE[] = "Subversion.Update";
|
|
|
|
const char CMD_ID_COMMIT_PROJECT[] = "Subversion.CommitProject";
|
|
|
|
const char CMD_ID_DESCRIBE[] = "Subversion.Describe";
|
|
|
|
|
2020-01-30 17:02:30 +01:00
|
|
|
struct SubversionResponse
|
|
|
|
{
|
|
|
|
bool error = false;
|
|
|
|
QString stdOut;
|
|
|
|
QString stdErr;
|
|
|
|
QString message;
|
|
|
|
};
|
|
|
|
|
2020-02-07 07:51:20 +01:00
|
|
|
const VcsBaseSubmitEditorParameters submitParameters {
|
|
|
|
Constants::SUBVERSION_SUBMIT_MIMETYPE,
|
|
|
|
Constants::SUBVERSION_COMMIT_EDITOR_ID,
|
|
|
|
Constants::SUBVERSION_COMMIT_EDITOR_DISPLAY_NAME,
|
|
|
|
VcsBaseSubmitEditorParameters::DiffFiles
|
|
|
|
};
|
|
|
|
|
|
|
|
const VcsBaseEditorParameters logEditorParameters {
|
2014-05-18 19:29:56 +02:00
|
|
|
LogOutput,
|
2015-01-22 16:17:36 +01:00
|
|
|
Constants::SUBVERSION_LOG_EDITOR_ID,
|
|
|
|
Constants::SUBVERSION_LOG_EDITOR_DISPLAY_NAME,
|
2020-02-07 07:51:20 +01:00
|
|
|
Constants::SUBVERSION_LOG_MIMETYPE
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
2020-02-07 07:51:20 +01:00
|
|
|
const VcsBaseEditorParameters blameEditorParameters {
|
|
|
|
AnnotateOutput,
|
|
|
|
Constants::SUBVERSION_BLAME_EDITOR_ID,
|
|
|
|
Constants::SUBVERSION_BLAME_EDITOR_DISPLAY_NAME,
|
|
|
|
Constants::SUBVERSION_BLAME_MIMETYPE
|
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
static inline QString debugCodec(const QTextCodec *c)
|
|
|
|
{
|
2012-09-21 13:54:38 +02:00
|
|
|
return c ? QString::fromLatin1(c->name()) : QString::fromLatin1("Null codec");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2016-05-20 19:20:49 +02:00
|
|
|
// Parse "svn status" output for added/conflicted/deleted/modified files
|
2009-01-12 17:44:04 +01:00
|
|
|
// "M<7blanks>file"
|
2018-11-24 21:14:08 +01:00
|
|
|
using StatusList = QList<SubversionSubmitEditor::StatusFilePair>;
|
2009-01-12 17:44:04 +01:00
|
|
|
|
|
|
|
StatusList parseStatusOutput(const QString &output)
|
|
|
|
{
|
|
|
|
StatusList changeSet;
|
|
|
|
const QString newLine = QString(QLatin1Char('\n'));
|
2020-07-21 10:19:36 +02:00
|
|
|
const QStringList list = output.split(newLine, Qt::SkipEmptyParts);
|
2009-01-12 17:44:04 +01:00
|
|
|
foreach (const QString &l, list) {
|
|
|
|
const QString line =l.trimmed();
|
|
|
|
if (line.size() > 8) {
|
2016-05-26 14:50:52 +02:00
|
|
|
const QByteArray state = line.left(1).toLatin1();
|
2016-05-20 19:20:49 +02:00
|
|
|
if (state == FileAddedC || state == FileConflictedC
|
|
|
|
|| state == FileDeletedC || state == FileModifiedC) {
|
2009-04-03 12:17:33 +02:00
|
|
|
const QString fileName = line.mid(7); // Column 8 starting from svn 1.6
|
2016-05-26 14:50:52 +02:00
|
|
|
changeSet.push_back(SubversionSubmitEditor::StatusFilePair(QLatin1String(state),
|
|
|
|
fileName.trimmed()));
|
2009-01-12 17:44:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return changeSet;
|
|
|
|
}
|
|
|
|
|
2009-05-26 12:25:32 +02:00
|
|
|
// Return a list of names for the internal svn directories
|
|
|
|
static inline QStringList svnDirectories()
|
|
|
|
{
|
|
|
|
QStringList rc(QLatin1String(".svn"));
|
2014-05-18 19:29:56 +02:00
|
|
|
if (HostOsInfo::isWindowsHost())
|
2012-08-23 15:53:58 +02:00
|
|
|
// Option on Windows systems to avoid hassle with some IDEs
|
|
|
|
rc.push_back(QLatin1String("_svn"));
|
2009-05-26 12:25:32 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-01-30 17:02:30 +01:00
|
|
|
class SubversionPluginPrivate;
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
class SubversionTopicCache : public Core::IVersionControl::TopicCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SubversionTopicCache(SubversionPluginPrivate *plugin) :
|
|
|
|
m_plugin(plugin)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
protected:
|
2020-01-30 17:02:30 +01:00
|
|
|
QString trackFile(const QString &repository) override;
|
2020-01-30 12:31:47 +01:00
|
|
|
|
2020-01-30 17:02:30 +01:00
|
|
|
QString refreshTopic(const QString &repository) override;
|
2020-01-30 12:31:47 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
SubversionPluginPrivate *m_plugin;
|
|
|
|
};
|
|
|
|
|
2020-01-30 17:02:30 +01:00
|
|
|
class SubversionPluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
|
|
|
{
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Subversion::Internal::SubversionPlugin)
|
|
|
|
|
|
|
|
public:
|
|
|
|
SubversionPluginPrivate();
|
|
|
|
~SubversionPluginPrivate() final;
|
|
|
|
|
|
|
|
// IVersionControl
|
|
|
|
QString displayName() const final;
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id id() const final;
|
2020-01-30 17:02:30 +01:00
|
|
|
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
|
|
|
|
|
|
|
|
bool managesDirectory(const QString &directory, QString *topLevel) const final;
|
|
|
|
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
|
|
|
|
|
|
|
|
bool isConfigured() const final;
|
|
|
|
bool supportsOperation(Operation operation) const final;
|
|
|
|
bool vcsOpen(const QString &fileName) final;
|
|
|
|
bool vcsAdd(const QString &fileName) final;
|
|
|
|
bool vcsDelete(const QString &filename) final;
|
|
|
|
bool vcsMove(const QString &from, const QString &to) final;
|
|
|
|
bool vcsCreateRepository(const QString &directory) final;
|
|
|
|
|
2020-06-17 23:34:16 +03:00
|
|
|
void vcsAnnotate(const QString &file, int line) final;
|
2020-06-17 23:50:30 +03:00
|
|
|
void vcsDescribe(const QString &source, const QString &changeNr) final;
|
2020-01-30 17:02:30 +01:00
|
|
|
|
|
|
|
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
|
|
|
|
const Utils::FilePath &baseDirectory,
|
|
|
|
const QString &localName,
|
|
|
|
const QStringList &extraArgs) final;
|
|
|
|
|
|
|
|
bool isVcsDirectory(const Utils::FilePath &fileName) const;
|
|
|
|
|
|
|
|
///
|
|
|
|
SubversionClient *client();
|
|
|
|
|
|
|
|
SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);
|
|
|
|
|
|
|
|
// IVersionControl
|
|
|
|
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
|
|
|
bool vcsDelete(const QString &workingDir, const QString &fileName);
|
|
|
|
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
|
|
|
bool vcsCheckout(const QString &directory, const QByteArray &url);
|
|
|
|
|
|
|
|
static SubversionPluginPrivate *instance();
|
|
|
|
|
|
|
|
QString monitorFile(const QString &repository) const;
|
|
|
|
QString synchronousTopic(const QString &repository) const;
|
|
|
|
SubversionResponse runSvn(const QString &workingDir,
|
|
|
|
const QStringList &arguments, int timeOutS,
|
|
|
|
unsigned flags, QTextCodec *outputCodec = nullptr) const;
|
|
|
|
void vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
|
|
|
const QString &revision = QString(), int lineNumber = -1);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
|
|
|
bool submitEditorAboutToClose() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void addCurrentFile();
|
|
|
|
void revertCurrentFile();
|
|
|
|
void diffProject();
|
|
|
|
void diffCurrentFile();
|
|
|
|
void cleanCommitMessageFile();
|
|
|
|
void startCommitAll();
|
|
|
|
void startCommitProject();
|
|
|
|
void startCommitCurrentFile();
|
|
|
|
void revertAll();
|
|
|
|
void filelogCurrentFile();
|
|
|
|
void annotateCurrentFile();
|
|
|
|
void projectStatus();
|
|
|
|
void slotDescribe();
|
|
|
|
void updateProject();
|
|
|
|
void commitFromEditor() override;
|
|
|
|
void diffCommitFiles(const QStringList &);
|
|
|
|
void logProject();
|
|
|
|
void logRepository();
|
|
|
|
void diffRepository();
|
|
|
|
void statusRepository();
|
|
|
|
void updateRepository();
|
|
|
|
|
|
|
|
inline bool isCommitEditorOpen() const;
|
|
|
|
Core::IEditor *showOutputInEditor(const QString &title, const QString &output,
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id id, const QString &source,
|
2020-01-30 17:02:30 +01:00
|
|
|
QTextCodec *codec);
|
|
|
|
|
|
|
|
void filelog(const QString &workingDir,
|
|
|
|
const QString &file = QString(),
|
|
|
|
bool enableAnnotationContextMenu = false);
|
|
|
|
void svnStatus(const QString &workingDir, const QString &relativePath = QString());
|
|
|
|
void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
|
|
|
|
bool checkSVNSubDir(const QDir &directory) const;
|
|
|
|
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
|
|
|
|
|
|
|
|
const QStringList m_svnDirectories;
|
|
|
|
|
|
|
|
SubversionSettings m_settings;
|
|
|
|
SubversionClient *m_client = nullptr;
|
|
|
|
QString m_commitMessageFileName;
|
|
|
|
QString m_commitRepository;
|
|
|
|
|
|
|
|
Core::CommandLocator *m_commandLocator = nullptr;
|
|
|
|
Utils::ParameterAction *m_addAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_deleteAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_revertAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_diffProjectAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_diffCurrentAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_logProjectAction = nullptr;
|
|
|
|
QAction *m_logRepositoryAction = nullptr;
|
|
|
|
QAction *m_commitAllAction = nullptr;
|
|
|
|
QAction *m_revertRepositoryAction = nullptr;
|
|
|
|
QAction *m_diffRepositoryAction = nullptr;
|
|
|
|
QAction *m_statusRepositoryAction = nullptr;
|
|
|
|
QAction *m_updateRepositoryAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_commitCurrentAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_filelogCurrentAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_annotateCurrentAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_statusProjectAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_updateProjectAction = nullptr;
|
|
|
|
Utils::ParameterAction *m_commitProjectAction = nullptr;
|
|
|
|
QAction *m_describeAction = nullptr;
|
|
|
|
|
|
|
|
QAction *m_menuAction = nullptr;
|
|
|
|
bool m_submitActionTriggered = false;
|
2020-01-31 13:57:41 +01:00
|
|
|
|
2021-03-31 17:15:52 +02:00
|
|
|
SubversionSettingsPage m_settingsPage{&m_settings};
|
2020-02-07 07:51:20 +01:00
|
|
|
|
2020-02-12 11:51:45 +01:00
|
|
|
public:
|
2020-02-07 07:51:20 +01:00
|
|
|
VcsSubmitEditorFactory submitEditorFactory {
|
|
|
|
submitParameters,
|
|
|
|
[] { return new SubversionSubmitEditor; },
|
|
|
|
this
|
|
|
|
};
|
|
|
|
|
|
|
|
VcsEditorFactory logEditorFactory {
|
|
|
|
&logEditorParameters,
|
|
|
|
[] { return new SubversionEditorWidget; },
|
2020-06-17 23:50:30 +03:00
|
|
|
std::bind(&SubversionPluginPrivate::vcsDescribe, this, _1, _2)
|
2020-02-07 07:51:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
VcsEditorFactory blameEditorFactory {
|
|
|
|
&blameEditorParameters,
|
|
|
|
[] { return new SubversionEditorWidget; },
|
2020-06-17 23:50:30 +03:00
|
|
|
std::bind(&SubversionPluginPrivate::vcsDescribe, this, _1, _2)
|
2020-02-07 07:51:20 +01:00
|
|
|
};
|
2020-01-30 17:02:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// ------------- SubversionPlugin
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
static SubversionPluginPrivate *dd = nullptr;
|
|
|
|
|
|
|
|
SubversionPlugin::~SubversionPlugin()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2020-01-23 17:22:05 +01:00
|
|
|
delete dd;
|
|
|
|
dd = nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
SubversionPluginPrivate::~SubversionPluginPrivate()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-22 12:23:44 +02:00
|
|
|
cleanCommitMessageFile();
|
2020-01-30 12:31:47 +01:00
|
|
|
delete m_client;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::cleanCommitMessageFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-22 12:23:44 +02:00
|
|
|
if (!m_commitMessageFileName.isEmpty()) {
|
|
|
|
QFile::remove(m_commitMessageFileName);
|
|
|
|
m_commitMessageFileName.clear();
|
2009-12-08 16:50:27 +01:00
|
|
|
m_commitRepository.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::isCommitEditorOpen() const
|
2009-09-22 12:23:44 +02:00
|
|
|
{
|
|
|
|
return !m_commitMessageFileName.isEmpty();
|
|
|
|
}
|
|
|
|
|
2009-12-08 14:26:41 +01:00
|
|
|
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2020-01-23 17:22:05 +01:00
|
|
|
dd = new SubversionPluginPrivate;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::extensionsInitialized()
|
|
|
|
{
|
|
|
|
dd->extensionsInitialized();
|
|
|
|
}
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
SubversionPluginPrivate::SubversionPluginPrivate()
|
|
|
|
: VcsBasePluginPrivate(Context(Constants::SUBVERSION_CONTEXT)),
|
|
|
|
m_svnDirectories(svnDirectories())
|
2020-01-23 17:22:05 +01:00
|
|
|
{
|
|
|
|
dd = this;
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
m_client = new SubversionClient(&m_settings);
|
|
|
|
|
|
|
|
setTopicCache(new SubversionTopicCache(this));
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Constants;
|
|
|
|
using namespace Core::Constants;
|
2014-11-16 12:05:34 +02:00
|
|
|
Context context(SUBVERSION_CONTEXT);
|
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
const QString prefix = QLatin1String("svn");
|
2018-02-02 10:08:21 +01:00
|
|
|
m_commandLocator = new CommandLocator("Subversion", prefix, prefix, this);
|
2021-03-19 09:43:41 +01:00
|
|
|
m_commandLocator->setDescription(tr("Triggers a Subversion version control operation."));
|
2010-02-12 16:03:08 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
// Register actions
|
|
|
|
ActionContainer *toolsContainer = ActionManager::actionContainer(M_TOOLS);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
ActionContainer *subversionMenu = ActionManager::createMenu(Id(CMD_ID_SUBVERSION_MENU));
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->menu()->setTitle(tr("&Subversion"));
|
|
|
|
toolsContainer->addMenu(subversionMenu);
|
2009-12-08 14:26:41 +01:00
|
|
|
m_menuAction = subversionMenu->menu()->menuAction();
|
2015-02-03 23:52:10 +02:00
|
|
|
Command *command;
|
2010-01-11 17:17:16 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_diffCurrentAction = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_diffCurrentAction,
|
2014-11-16 12:05:34 +02:00
|
|
|
CMD_ID_DIFF_CURRENT, context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-02 13:39:18 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+S,Meta+D") : tr("Alt+S,Alt+D")));
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_diffCurrentAction, &QAction::triggered, this, &SubversionPluginPrivate::diffCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_filelogCurrentAction = new ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_filelogCurrentAction,
|
2014-11-16 12:05:34 +02:00
|
|
|
CMD_ID_FILELOG_CURRENT, context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_filelogCurrentAction, &QAction::triggered, this, &SubversionPluginPrivate::filelogCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_annotateCurrentAction = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_annotateCurrentAction,
|
2014-11-16 12:05:34 +02:00
|
|
|
CMD_ID_ANNOTATE_CURRENT, context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_annotateCurrentAction, &QAction::triggered, this, &SubversionPluginPrivate::annotateCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
subversionMenu->addSeparator(context);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_addAction, CMD_ID_ADD,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-02 13:39:18 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+S,Meta+A") : tr("Alt+S,Alt+A")));
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_addAction, &QAction::triggered, this, &SubversionPluginPrivate::addCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_commitCurrentAction = new ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_commitCurrentAction,
|
2014-11-16 12:05:34 +02:00
|
|
|
CMD_ID_COMMIT_CURRENT, context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2018-02-02 13:39:18 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+S,Meta+C") : tr("Alt+S,Alt+C")));
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_commitCurrentAction, &QAction::triggered, this, &SubversionPluginPrivate::startCommitCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_deleteAction, &QAction::triggered, this, &SubversionPluginPrivate::promptToDeleteCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_revertAction = new ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_revertAction, CMD_ID_REVERT,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_revertAction, &QAction::triggered, this, &SubversionPluginPrivate::revertCurrentFile);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
subversionMenu->addSeparator(context);
|
2009-02-09 17:33:31 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_diffProjectAction = new ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_diffProjectAction, &QAction::triggered, this, &SubversionPluginPrivate::diffProject);
|
2010-01-11 17:17:16 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_statusProjectAction = new ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), ParameterAction::EnabledWithParameter, this);
|
|
|
|
command = ActionManager::registerAction(m_statusProjectAction, CMD_ID_STATUS,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_statusProjectAction, &QAction::triggered, this, &SubversionPluginPrivate::projectStatus);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_logProjectAction = new ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, context);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_logProjectAction, &QAction::triggered, this, &SubversionPluginPrivate::logProject);
|
2010-01-07 11:33:30 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-07 11:33:30 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_updateProjectAction = new ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_updateProjectAction, CMD_ID_UPDATE, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_updateProjectAction, &QAction::triggered, this, &SubversionPluginPrivate::updateProject);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2008-12-02 12:01:29 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_commitProjectAction = new ParameterAction(tr("Commit Project"), tr("Commit Project \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_commitProjectAction, CMD_ID_COMMIT_PROJECT, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_commitProjectAction, &QAction::triggered, this, &SubversionPluginPrivate::startCommitProject);
|
2015-02-03 23:52:10 +02:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2010-04-27 12:16:51 +02:00
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
subversionMenu->addSeparator(context);
|
2010-01-11 17:17:16 +01:00
|
|
|
|
2010-04-27 12:16:51 +02:00
|
|
|
m_diffRepositoryAction = new QAction(tr("Diff Repository"), this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_diffRepositoryAction, &QAction::triggered, this, &SubversionPluginPrivate::diffRepository);
|
2010-04-27 12:16:51 +02:00
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
m_statusRepositoryAction = new QAction(tr("Repository Status"), this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_statusRepositoryAction, CMD_ID_REPOSITORYSTATUS, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_statusRepositoryAction, &QAction::triggered, this, &SubversionPluginPrivate::statusRepository);
|
2010-04-27 12:16:51 +02:00
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
m_logRepositoryAction = new QAction(tr("Log Repository"), this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_logRepositoryAction, &QAction::triggered, this, &SubversionPluginPrivate::logRepository);
|
2010-01-07 11:33:30 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-07 11:33:30 +01:00
|
|
|
|
2010-04-27 12:16:51 +02:00
|
|
|
m_updateRepositoryAction = new QAction(tr("Update Repository"), this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_updateRepositoryAction, CMD_ID_REPOSITORYUPDATE, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_updateRepositoryAction, &QAction::triggered, this, &SubversionPluginPrivate::updateRepository);
|
2010-01-11 17:17:16 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-04-27 12:16:51 +02:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 17:17:16 +01:00
|
|
|
|
|
|
|
m_commitAllAction = new QAction(tr("Commit All Files"), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_commitAllAction, &QAction::triggered, this, &SubversionPluginPrivate::startCommitAll);
|
2010-01-11 17:17:16 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 17:17:16 +01:00
|
|
|
|
2010-04-27 12:16:51 +02:00
|
|
|
m_describeAction = new QAction(tr("Describe..."), this);
|
2014-11-16 12:05:34 +02:00
|
|
|
command = ActionManager::registerAction(m_describeAction, CMD_ID_DESCRIBE, context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_describeAction, &QAction::triggered, this, &SubversionPluginPrivate::slotDescribe);
|
2010-04-27 12:16:51 +02:00
|
|
|
subversionMenu->addAction(command);
|
|
|
|
|
2010-01-11 17:17:16 +01:00
|
|
|
m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL,
|
2014-11-16 12:05:34 +02:00
|
|
|
context);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_revertRepositoryAction, &QAction::triggered, this, &SubversionPluginPrivate::revertAll);
|
2010-01-11 17:17:16 +01:00
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2021-03-31 17:15:52 +02:00
|
|
|
|
|
|
|
connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName) const
|
2016-10-20 13:06:11 +02:00
|
|
|
{
|
|
|
|
const QString baseName = fileName.fileName();
|
2019-05-28 16:55:43 +02:00
|
|
|
return fileName.isDir() && contains(m_svnDirectories, [baseName](const QString &s) {
|
2016-10-22 21:10:00 +03:00
|
|
|
return !baseName.compare(s, HostOsInfo::fileNameCaseSensitivity());
|
2016-10-20 13:06:11 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
SubversionClient *SubversionPluginPrivate::client()
|
2015-03-26 12:22:29 +01:00
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::submitEditorAboutToClose()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-12-08 14:26:41 +01:00
|
|
|
if (!isCommitEditorOpen())
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
2018-09-20 00:57:48 +03:00
|
|
|
auto editor = qobject_cast<SubversionSubmitEditor *>(submitEditor());
|
2013-04-18 12:06:43 +02:00
|
|
|
QTC_ASSERT(editor, return true);
|
2014-05-18 19:29:56 +02:00
|
|
|
IDocument *editorDocument = editor->document();
|
2013-04-18 12:06:43 +02:00
|
|
|
QTC_ASSERT(editorDocument, return true);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// Submit editor closing. Make it write out the commit message
|
|
|
|
// and retrieve files
|
2014-12-21 21:54:30 +02:00
|
|
|
const QFileInfo editorFile = editorDocument->filePath().toFileInfo();
|
2009-09-22 12:23:44 +02:00
|
|
|
const QFileInfo changeFile(m_commitMessageFileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
|
|
|
return true; // Oops?!
|
|
|
|
|
2009-03-20 10:16:18 +01:00
|
|
|
// Prompt user. Force a prompt unless submit was actually invoked (that
|
|
|
|
// is, the editor was closed or shutdown).
|
2018-11-09 09:59:40 +02:00
|
|
|
const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit(
|
2021-03-18 18:23:21 +01:00
|
|
|
this, nullptr, !m_submitActionTriggered, true, &m_settings.promptOnSubmit);
|
2009-03-20 10:16:18 +01:00
|
|
|
m_submitActionTriggered = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
switch (answer) {
|
2014-05-18 19:29:56 +02:00
|
|
|
case VcsBaseSubmitEditor::SubmitCanceled:
|
2008-12-02 12:01:29 +01:00
|
|
|
return false; // Keep editing and change file
|
2014-05-18 19:29:56 +02:00
|
|
|
case VcsBaseSubmitEditor::SubmitDiscarded:
|
2009-09-22 12:23:44 +02:00
|
|
|
cleanCommitMessageFile();
|
2008-12-02 12:01:29 +01:00
|
|
|
return true; // Cancel all
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const QStringList fileList = editor->checkedFiles();
|
2009-03-20 16:52:22 +01:00
|
|
|
bool closeEditor = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!fileList.empty()) {
|
|
|
|
// get message & commit
|
2019-01-16 23:45:22 +02:00
|
|
|
closeEditor = DocumentManager::saveDocument(editorDocument)
|
|
|
|
&& m_client->doCommit(m_commitRepository, fileList, m_commitMessageFileName);
|
|
|
|
if (closeEditor)
|
|
|
|
cleanCommitMessageFile();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-03-20 16:52:22 +01:00
|
|
|
return closeEditor;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::diffCommitFiles(const QStringList &files)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-01-06 15:46:58 +01:00
|
|
|
m_client->diff(m_commitRepository, files, QStringList());
|
2011-03-25 16:39:33 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
SubversionSubmitEditor *SubversionPluginPrivate::openSubversionSubmitEditor(const QString &fileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-01-22 16:17:36 +01:00
|
|
|
IEditor *editor = EditorManager::openEditor(fileName, Constants::SUBVERSION_COMMIT_EDITOR_ID);
|
2018-09-20 00:57:48 +03:00
|
|
|
auto submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
|
|
|
|
QTC_ASSERT(submitEditor, return nullptr);
|
2013-04-18 12:06:43 +02:00
|
|
|
setSubmitEditor(submitEditor);
|
2015-03-04 14:56:56 +01:00
|
|
|
connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles,
|
2020-01-23 17:22:05 +01:00
|
|
|
this, &SubversionPluginPrivate::diffCommitFiles);
|
2009-12-14 10:56:50 +01:00
|
|
|
submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
|
2008-12-02 12:01:29 +01:00
|
|
|
return submitEditor;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-12 16:03:08 +01:00
|
|
|
if (!enableMenuAction(as, m_menuAction)) {
|
|
|
|
m_commandLocator->setEnabled(false);
|
2009-12-08 14:26:41 +01:00
|
|
|
return;
|
2010-02-12 16:03:08 +01:00
|
|
|
}
|
|
|
|
const bool hasTopLevel = currentState().hasTopLevel();
|
|
|
|
m_commandLocator->setEnabled(hasTopLevel);
|
|
|
|
m_logRepositoryAction->setEnabled(hasTopLevel);
|
2010-01-07 11:33:30 +01:00
|
|
|
|
2009-12-08 16:50:27 +01:00
|
|
|
const QString projectName = currentState().currentProjectName();
|
|
|
|
m_diffProjectAction->setParameter(projectName);
|
|
|
|
m_statusProjectAction->setParameter(projectName);
|
|
|
|
m_updateProjectAction->setParameter(projectName);
|
2010-01-07 11:33:30 +01:00
|
|
|
m_logProjectAction->setParameter(projectName);
|
2010-04-27 12:16:51 +02:00
|
|
|
m_commitProjectAction->setParameter(projectName);
|
2009-12-08 16:50:27 +01:00
|
|
|
|
|
|
|
const bool repoEnabled = currentState().hasTopLevel();
|
|
|
|
m_commitAllAction->setEnabled(repoEnabled);
|
|
|
|
m_describeAction->setEnabled(repoEnabled);
|
2010-01-11 17:17:16 +01:00
|
|
|
m_revertRepositoryAction->setEnabled(repoEnabled);
|
2010-04-27 12:16:51 +02:00
|
|
|
m_diffRepositoryAction->setEnabled(repoEnabled);
|
|
|
|
m_statusRepositoryAction->setEnabled(repoEnabled);
|
|
|
|
m_updateRepositoryAction->setEnabled(repoEnabled);
|
2009-12-08 16:50:27 +01:00
|
|
|
|
|
|
|
const QString fileName = currentState().currentFileName();
|
|
|
|
|
|
|
|
m_addAction->setParameter(fileName);
|
|
|
|
m_deleteAction->setParameter(fileName);
|
|
|
|
m_revertAction->setParameter(fileName);
|
|
|
|
m_diffCurrentAction->setParameter(fileName);
|
|
|
|
m_commitCurrentAction->setParameter(fileName);
|
|
|
|
m_filelogCurrentAction->setParameter(fileName);
|
|
|
|
m_annotateCurrentAction->setParameter(fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::addCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2009-12-08 16:50:27 +01:00
|
|
|
vcsAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::revertAll()
|
2010-01-11 17:17:16 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2010-01-11 17:17:16 +01:00
|
|
|
const QString title = tr("Revert repository");
|
2014-05-18 19:29:56 +02:00
|
|
|
if (QMessageBox::warning(ICore::dialogParent(), title,
|
2014-03-11 18:09:23 +01:00
|
|
|
tr("Revert all pending changes to the repository?"),
|
2010-01-11 17:17:16 +01:00
|
|
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
|
|
|
return;
|
|
|
|
// NoteL: Svn "revert ." doesn not work.
|
|
|
|
QStringList args;
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("revert");
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("--recursive") << state.topLevel();
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse revertResponse
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(state.topLevel(), args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (revertResponse.error)
|
2014-05-18 19:29:56 +02:00
|
|
|
QMessageBox::warning(ICore::dialogParent(), title,
|
2014-03-11 18:09:23 +01:00
|
|
|
tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2020-01-30 12:31:47 +01:00
|
|
|
emit repositoryChanged(state.topLevel());
|
2010-01-11 17:17:16 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::revertCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
QStringList args(QLatin1String("diff"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2016-11-07 09:12:42 +01:00
|
|
|
args.push_back(SubversionClient::escapeFile(state.relativeCurrentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse diffResponse
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(), 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (diffResponse.error)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (diffResponse.stdOut.isEmpty())
|
|
|
|
return;
|
2014-05-18 19:29:56 +02:00
|
|
|
if (QMessageBox::warning(ICore::dialogParent(), QLatin1String("svn revert"),
|
2014-03-11 18:09:23 +01:00
|
|
|
tr("The file has been changed. Do you want to revert it?"),
|
2008-12-02 12:01:29 +01:00
|
|
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
|
|
|
return;
|
|
|
|
|
2009-06-18 14:30:04 +02:00
|
|
|
|
2021-06-09 09:59:37 +02:00
|
|
|
FileChangeBlocker fcb(FilePath::fromString(state.currentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// revert
|
|
|
|
args.clear();
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("revert");
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2016-11-07 09:12:42 +01:00
|
|
|
args << SubversionClient::escapeFile(state.relativeCurrentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse revertResponse
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(state.currentFileTopLevel(), args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
2010-05-21 17:46:00 +02:00
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!revertResponse.error)
|
2020-01-30 12:31:47 +01:00
|
|
|
emit filesChanged(QStringList(state.currentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::diffProject()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasProject(), return);
|
2013-09-27 15:39:16 +02:00
|
|
|
const QString relativeProject = state.relativeCurrentProject();
|
|
|
|
m_client->diff(state.currentProjectTopLevel(),
|
2015-01-06 15:46:58 +01:00
|
|
|
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject),
|
|
|
|
QStringList());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::diffCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2015-01-06 15:46:58 +01:00
|
|
|
m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
|
|
|
|
QStringList());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::startCommitCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2009-12-08 16:50:27 +01:00
|
|
|
startCommit(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::startCommitAll()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2009-12-08 16:50:27 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
startCommit(state.topLevel());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::startCommitProject()
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2010-04-27 12:16:51 +02:00
|
|
|
QTC_ASSERT(state.hasProject(), return);
|
|
|
|
startCommit(state.currentProjectPath());
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
/* Start commit of files of a single repository by displaying
|
|
|
|
* template and files in a submit editor. On closing, the real
|
|
|
|
* commit will start. */
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::startCommit(const QString &workingDir, const QStringList &files)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-09-08 12:52:35 +02:00
|
|
|
if (!promptBeforeCommit())
|
|
|
|
return;
|
|
|
|
|
2013-04-18 12:06:43 +02:00
|
|
|
if (raiseSubmitEditor())
|
2009-05-27 16:17:24 +02:00
|
|
|
return;
|
2009-09-22 12:23:44 +02:00
|
|
|
if (isCommitEditorOpen()) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendWarning(tr("Another commit is currently being executed."));
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList args(QLatin1String("status"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2016-11-07 09:12:42 +01:00
|
|
|
args += SubversionClient::escapeFiles(files);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, m_settings.timeout.value(), 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (response.error)
|
|
|
|
return;
|
2009-12-08 16:50:27 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Get list of added/modified/deleted files
|
2009-01-12 17:44:04 +01:00
|
|
|
const StatusList statusOutput = parseStatusOutput(response.stdOut);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (statusOutput.empty()) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendWarning(tr("There are no modified files."));
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
}
|
2009-12-08 16:50:27 +01:00
|
|
|
m_commitRepository = workingDir;
|
2008-12-02 12:01:29 +01:00
|
|
|
// Create a new submit change file containing the submit template
|
2014-05-18 19:29:56 +02:00
|
|
|
TempFileSaver saver;
|
2011-03-30 15:15:15 +02:00
|
|
|
saver.setAutoRemove(false);
|
|
|
|
// TODO: Retrieve submit template from
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString submitTemplate;
|
|
|
|
// Create a submit
|
2011-03-30 15:15:15 +02:00
|
|
|
saver.write(submitTemplate.toUtf8());
|
|
|
|
if (!saver.finalize()) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendError(saver.errorString());
|
2011-03-30 15:15:15 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-05-18 09:47:07 +02:00
|
|
|
m_commitMessageFileName = saver.filePath().toString();
|
2008-12-02 12:01:29 +01:00
|
|
|
// Create a submit editor and set file list
|
2009-09-22 12:23:44 +02:00
|
|
|
SubversionSubmitEditor *editor = openSubversionSubmitEditor(m_commitMessageFileName);
|
2014-05-17 23:14:34 +02:00
|
|
|
QTC_ASSERT(editor, return);
|
2009-01-12 17:44:04 +01:00
|
|
|
editor->setStatusList(statusOutput);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::filelogCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2013-08-06 15:14:54 +03:00
|
|
|
filelog(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
|
2010-01-07 11:33:30 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::logProject()
|
2010-01-07 11:33:30 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasProject(), return);
|
2010-01-07 11:33:30 +01:00
|
|
|
filelog(state.currentProjectTopLevel(), state.relativeCurrentProject());
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::logRepository()
|
2010-01-07 11:33:30 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2010-01-07 11:33:30 +01:00
|
|
|
filelog(state.topLevel());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::diffRepository()
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2015-01-06 15:46:58 +01:00
|
|
|
m_client->diff(state.topLevel(), QStringList(), QStringList());
|
2010-04-27 12:16:51 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::statusRepository()
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2010-04-27 12:16:51 +02:00
|
|
|
svnStatus(state.topLevel());
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::updateRepository()
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2010-04-27 12:16:51 +02:00
|
|
|
svnUpdate(state.topLevel());
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::svnStatus(const QString &workingDir, const QString &relativePath)
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2010-04-27 12:16:51 +02:00
|
|
|
QStringList args(QLatin1String("status"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2013-08-06 15:14:54 +03:00
|
|
|
if (!relativePath.isEmpty())
|
2016-11-07 09:12:42 +01:00
|
|
|
args.append(SubversionClient::escapeFile(relativePath));
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::setRepository(workingDir);
|
2021-03-18 18:23:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::clearRepository();
|
2010-04-27 12:16:51 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::filelog(const QString &workingDir,
|
2013-08-06 15:14:54 +03:00
|
|
|
const QString &file,
|
2010-01-07 11:33:30 +01:00
|
|
|
bool enableAnnotationContextMenu)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-01-26 15:29:09 +01:00
|
|
|
m_client->log(workingDir, QStringList(file), QStringList(), enableAnnotationContextMenu);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::updateProject()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2009-12-08 16:50:27 +01:00
|
|
|
QTC_ASSERT(state.hasProject(), return);
|
2010-04-27 12:16:51 +02:00
|
|
|
svnUpdate(state.currentProjectTopLevel(), state.relativeCurrentProject());
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::svnUpdate(const QString &workingDir, const QString &relativePath)
|
2010-04-27 12:16:51 +02:00
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList args(QLatin1String("update"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2014-07-28 17:47:15 +02:00
|
|
|
args.push_back(QLatin1String(Constants::NON_INTERACTIVE_OPTION));
|
2013-08-06 15:14:54 +03:00
|
|
|
if (!relativePath.isEmpty())
|
|
|
|
args.append(relativePath);
|
2016-05-12 22:04:38 +03:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, 10 * m_settings.timeout.value(),
|
2016-05-12 22:04:38 +03:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
2009-12-08 16:50:27 +01:00
|
|
|
if (!response.error)
|
2020-01-30 12:31:47 +01:00
|
|
|
emit repositoryChanged(workingDir);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::annotateCurrentFile()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2009-12-08 16:50:27 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2020-01-30 12:31:47 +01:00
|
|
|
vcsAnnotateHelper(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
|
|
|
const QString &revision /* = QString() */,
|
|
|
|
int lineNumber /* = -1 */)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString source = VcsBaseEditor::getSource(workingDir, file);
|
|
|
|
QTextCodec *codec = VcsBaseEditor::getCodec(source);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
QStringList args(QLatin1String("annotate"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2021-03-18 18:23:21 +01:00
|
|
|
if (m_settings.spaceIgnorantAnnotation.value())
|
2010-01-05 15:45:41 +01:00
|
|
|
args << QLatin1String("-x") << QLatin1String("-uw");
|
2010-01-06 17:24:40 +01:00
|
|
|
if (!revision.isEmpty())
|
|
|
|
args << QLatin1String("-r") << revision;
|
2008-12-02 12:01:29 +01:00
|
|
|
args.push_back(QLatin1String("-v"));
|
2016-11-07 09:12:42 +01:00
|
|
|
args.append(QDir::toNativeSeparators(SubversionClient::escapeFile(file)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, codec);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (response.error)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Re-use an existing view if possible to support
|
|
|
|
// the common usage pattern of continuously changing and diffing a file
|
2010-01-06 17:24:40 +01:00
|
|
|
if (lineNumber <= 0)
|
2014-08-27 17:50:20 +02:00
|
|
|
lineNumber = VcsBaseEditor::lineNumberOfCurrentEditor(source);
|
2010-01-06 17:24:40 +01:00
|
|
|
// Determine id
|
2011-03-31 10:57:33 +02:00
|
|
|
const QStringList files = QStringList(file);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString id = VcsBaseEditor::getTitleId(workingDir, files, revision);
|
|
|
|
const QString tag = VcsBaseEditor::editorTag(AnnotateOutput, workingDir, files);
|
|
|
|
if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) {
|
2013-07-15 15:14:10 +02:00
|
|
|
editor->document()->setContents(response.stdOut.toUtf8());
|
2014-08-27 17:50:20 +02:00
|
|
|
VcsBaseEditor::gotoLineOfEditor(editor, lineNumber);
|
2014-05-18 19:29:56 +02:00
|
|
|
EditorManager::activateEditor(editor);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2009-12-08 16:50:27 +01:00
|
|
|
const QString title = QString::fromLatin1("svn annotate %1").arg(id);
|
2020-02-07 07:51:20 +01:00
|
|
|
IEditor *newEditor = showOutputInEditor(title, response.stdOut, blameEditorParameters.id, source, codec);
|
2014-08-27 17:50:20 +02:00
|
|
|
VcsBaseEditor::tagEditor(newEditor, tag);
|
|
|
|
VcsBaseEditor::gotoLineOfEditor(newEditor, lineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::projectStatus()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2009-12-08 16:50:27 +01:00
|
|
|
QTC_ASSERT(state.hasProject(), return);
|
2012-05-15 19:54:12 +10:00
|
|
|
svnStatus(state.currentProjectTopLevel(), state.relativeCurrentProject());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-06-17 23:50:30 +03:00
|
|
|
void SubversionPluginPrivate::vcsDescribe(const QString &source, const QString &changeNr)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
// To describe a complete change, find the top level and then do
|
|
|
|
//svn diff -r 472958:472959 <top level>
|
|
|
|
const QFileInfo fi(source);
|
2010-05-20 16:24:39 +02:00
|
|
|
QString topLevel;
|
|
|
|
const bool manages = managesDirectory(fi.isDir() ? source : fi.absolutePath(), &topLevel);
|
|
|
|
if (!manages || topLevel.isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
if (Subversion::Constants::debug)
|
|
|
|
qDebug() << Q_FUNC_INFO << source << topLevel << changeNr;
|
2014-11-04 15:42:39 +01:00
|
|
|
// Number must be >= 1
|
2008-12-02 12:01:29 +01:00
|
|
|
bool ok;
|
2014-11-06 13:23:40 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
const int number = changeNr.toInt(&ok);
|
2014-11-04 15:42:39 +01:00
|
|
|
if (!ok || number < 1)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
2014-11-06 13:23:40 +01:00
|
|
|
const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-06 13:23:40 +01:00
|
|
|
m_client->describe(topLevel, number, title);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::slotDescribe()
|
2009-02-09 17:33:31 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2009-12-08 16:50:27 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-02-09 17:33:31 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
QInputDialog inputDialog(ICore::dialogParent());
|
2009-02-09 17:33:31 +01:00
|
|
|
inputDialog.setInputMode(QInputDialog::IntInput);
|
2014-11-04 15:42:39 +01:00
|
|
|
inputDialog.setIntRange(1, INT_MAX);
|
2009-02-09 17:33:31 +01:00
|
|
|
inputDialog.setWindowTitle(tr("Describe"));
|
|
|
|
inputDialog.setLabelText(tr("Revision number:"));
|
|
|
|
if (inputDialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const int revision = inputDialog.intValue();
|
2020-06-17 23:50:30 +03:00
|
|
|
vcsDescribe(state.topLevel(), QString::number(revision));
|
2009-02-09 17:33:31 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
void SubversionPluginPrivate::commitFromEditor()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-03-20 10:16:18 +01:00
|
|
|
m_submitActionTriggered = true;
|
2014-08-19 16:15:57 +02:00
|
|
|
QTC_ASSERT(submitEditor(), return);
|
2020-09-29 10:24:48 +02:00
|
|
|
EditorManager::closeDocuments({submitEditor()->document()});
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
SubversionResponse SubversionPluginPrivate::runSvn(const QString &workingDir,
|
2015-04-10 14:44:17 +02:00
|
|
|
const QStringList &arguments,
|
|
|
|
int timeOutS, unsigned flags,
|
|
|
|
QTextCodec *outputCodec) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
SubversionResponse response;
|
2021-03-18 18:23:21 +01:00
|
|
|
if (m_settings.binaryPath.value().isEmpty()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
response.error = true;
|
2014-08-22 13:26:36 +02:00
|
|
|
response.message =tr("No subversion executable specified.");
|
2008-12-02 12:01:29 +01:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2021-05-12 14:25:50 +02:00
|
|
|
SynchronousProcess proc;
|
|
|
|
m_client->vcsFullySynchronousExec(proc, workingDir, arguments, flags, timeOutS, outputCodec);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2021-05-28 13:19:38 +02:00
|
|
|
response.error = proc.result() != QtcProcess::FinishedWithSuccess;
|
2010-05-21 17:46:00 +02:00
|
|
|
if (response.error)
|
2021-05-14 13:12:46 +02:00
|
|
|
response.message = proc.exitMessage();
|
2021-05-12 14:25:50 +02:00
|
|
|
response.stdErr = proc.stdErr();
|
|
|
|
response.stdOut = proc.stdOut();
|
2008-12-02 12:01:29 +01:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
IEditor *SubversionPluginPrivate::showOutputInEditor(const QString &title, const QString &output,
|
2020-02-07 07:51:20 +01:00
|
|
|
Id id, const QString &source,
|
2008-12-02 12:01:29 +01:00
|
|
|
QTextCodec *codec)
|
|
|
|
{
|
|
|
|
if (Subversion::Constants::debug)
|
2020-02-07 07:51:20 +01:00
|
|
|
qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.toString()
|
|
|
|
<< "Size= " << output.size() << " Type=" << id << debugCodec(codec);
|
2008-12-02 12:01:29 +01:00
|
|
|
QString s = title;
|
2014-06-17 14:41:59 +02:00
|
|
|
IEditor *editor = EditorManager::openEditorWithContents(id, &s, output.toUtf8());
|
2018-09-20 00:57:48 +03:00
|
|
|
auto e = qobject_cast<SubversionEditorWidget*>(editor->widget());
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!e)
|
2018-09-20 00:57:48 +03:00
|
|
|
return nullptr;
|
2020-01-30 12:31:47 +01:00
|
|
|
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested,
|
|
|
|
this, &SubversionPluginPrivate::vcsAnnotateHelper);
|
2010-06-07 14:53:28 +02:00
|
|
|
e->setForceReadOnly(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
2016-01-14 14:45:01 +01:00
|
|
|
e->textDocument()->setFallbackSaveAsFileName(s);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!source.isEmpty())
|
|
|
|
e->setSource(source);
|
|
|
|
if (codec)
|
|
|
|
e->setCodec(codec);
|
2013-12-19 10:22:02 +01:00
|
|
|
return editor;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
SubversionPluginPrivate *SubversionPluginPrivate::instance()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2020-01-23 17:22:05 +01:00
|
|
|
QTC_ASSERT(dd, return dd);
|
|
|
|
return dd;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
QString SubversionPluginPrivate::monitorFile(const QString &repository) const
|
2014-11-04 16:35:14 +01:00
|
|
|
{
|
|
|
|
QTC_ASSERT(!repository.isEmpty(), return QString());
|
|
|
|
QDir repoDir(repository);
|
|
|
|
foreach (const QString &svnDir, m_svnDirectories) {
|
|
|
|
if (repoDir.exists(svnDir)) {
|
|
|
|
QFileInfo fi(repoDir.absoluteFilePath(svnDir + QLatin1String("/wc.db")));
|
|
|
|
if (fi.exists() && fi.isFile())
|
|
|
|
return fi.absoluteFilePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
QString SubversionPluginPrivate::synchronousTopic(const QString &repository) const
|
2014-11-04 16:35:14 +01:00
|
|
|
{
|
|
|
|
return m_client->synchronousTopic(repository);
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::vcsAdd(const QString &workingDir, const QString &rawFileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-11-07 09:12:42 +01:00
|
|
|
const QString file = QDir::toNativeSeparators(SubversionClient::escapeFile(rawFileName));
|
2010-01-06 10:57:07 +01:00
|
|
|
QStringList args;
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("add")
|
2020-01-24 14:36:56 +01:00
|
|
|
<< SubversionClient::addAuthenticationOptions(m_settings)
|
2014-11-04 17:23:16 +01:00
|
|
|
<< QLatin1String("--parents") << file;
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
2008-12-02 12:01:29 +01:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::vcsDelete(const QString &workingDir, const QString &rawFileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-11-07 09:12:42 +01:00
|
|
|
const QString file = QDir::toNativeSeparators(SubversionClient::escapeFile(rawFileName));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-03 14:01:39 +01:00
|
|
|
QStringList args;
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("delete");
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings)
|
2015-03-26 12:22:29 +01:00
|
|
|
<< QLatin1String("--force") << file;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
2008-12-02 12:01:29 +01:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::vcsMove(const QString &workingDir, const QString &from, const QString &to)
|
2010-05-11 14:13:38 +02:00
|
|
|
{
|
|
|
|
QStringList args(QLatin1String("move"));
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
2016-11-07 09:12:42 +01:00
|
|
|
args << QDir::toNativeSeparators(SubversionClient::escapeFile(from))
|
|
|
|
<< QDir::toNativeSeparators(SubversionClient::escapeFile(to));
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDir, args, m_settings.timeout.value(),
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut
|
|
|
|
| VcsCommand::FullySynchronously);
|
2010-05-11 14:13:38 +02:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::vcsCheckout(const QString &directory, const QByteArray &url)
|
2010-09-29 12:16:35 +02:00
|
|
|
{
|
2013-02-27 17:30:19 +08:00
|
|
|
QUrl tempUrl = QUrl::fromEncoded(url);
|
2010-09-29 12:16:35 +02:00
|
|
|
QString username = tempUrl.userName();
|
|
|
|
QString password = tempUrl.password();
|
|
|
|
QStringList args = QStringList(QLatin1String("checkout"));
|
2014-07-28 17:47:15 +02:00
|
|
|
args << QLatin1String(Constants::NON_INTERACTIVE_OPTION) ;
|
2010-09-29 12:16:35 +02:00
|
|
|
|
2014-11-04 17:23:16 +01:00
|
|
|
if (!username.isEmpty()) {
|
2010-09-29 12:16:35 +02:00
|
|
|
// If url contains username and password we have to use separate username and password
|
|
|
|
// arguments instead of passing those in the url. Otherwise the subversion 'non-interactive'
|
|
|
|
// authentication will always fail (if the username and password data are not stored locally),
|
|
|
|
// if for example we are logging into a new host for the first time using svn. There seems to
|
|
|
|
// be a bug in subversion, so this might get fixed in the future.
|
2012-01-31 10:57:10 +01:00
|
|
|
tempUrl.setUserInfo(QString());
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("--username") << username;
|
|
|
|
if (!password.isEmpty())
|
|
|
|
args << QLatin1String("--password") << password;
|
2010-09-29 12:16:35 +02:00
|
|
|
}
|
2014-11-04 17:23:16 +01:00
|
|
|
|
|
|
|
args << QLatin1String(tempUrl.toEncoded()) << directory;
|
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
const SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(directory, args, 10 * m_settings.timeout.value(), VcsCommand::SshPasswordPrompt);
|
2014-11-04 17:23:16 +01:00
|
|
|
return !response.error;
|
|
|
|
|
2010-09-29 12:16:35 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
const QDir dir(directory);
|
2010-05-20 16:24:39 +02:00
|
|
|
if (topLevel)
|
|
|
|
topLevel->clear();
|
2011-10-19 14:07:26 +00:00
|
|
|
|
|
|
|
/* Subversion >= 1.7 has ".svn" directory in the root of the working copy. Check for
|
|
|
|
* furthest parent containing ".svn/wc.db". Need to check for furthest parent as closer
|
|
|
|
* parents may be svn:externals. */
|
|
|
|
QDir parentDir = dir;
|
2014-11-03 15:35:00 +01:00
|
|
|
while (!parentDir.isRoot()) {
|
2014-11-05 17:53:57 +01:00
|
|
|
if (checkSVNSubDir(parentDir)) {
|
2011-10-19 14:07:26 +00:00
|
|
|
if (topLevel)
|
|
|
|
*topLevel = parentDir.absolutePath();
|
|
|
|
return true;
|
2011-10-19 14:06:40 +00:00
|
|
|
}
|
2014-11-05 07:57:55 +01:00
|
|
|
if (!parentDir.cdUp())
|
|
|
|
break;
|
2011-10-19 14:06:40 +00:00
|
|
|
}
|
2011-10-19 14:07:26 +00:00
|
|
|
|
2014-11-05 17:53:57 +01:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
|
2013-10-02 00:18:39 +03:00
|
|
|
{
|
|
|
|
QStringList args;
|
2014-11-04 17:23:16 +01:00
|
|
|
args << QLatin1String("status");
|
2020-01-24 14:36:56 +01:00
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings)
|
2016-11-07 09:12:42 +01:00
|
|
|
<< QDir::toNativeSeparators(SubversionClient::escapeFile(fileName));
|
2015-03-25 12:30:07 +01:00
|
|
|
SubversionResponse response
|
2021-03-18 18:23:21 +01:00
|
|
|
= runSvn(workingDirectory, args, m_settings.timeout.value(), 0);
|
2013-10-02 00:18:39 +03:00
|
|
|
return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?');
|
|
|
|
}
|
|
|
|
|
2010-05-20 16:24:39 +02:00
|
|
|
// Check whether SVN management subdirs exist.
|
2020-01-23 17:22:05 +01:00
|
|
|
bool SubversionPluginPrivate::checkSVNSubDir(const QDir &directory) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-05-26 12:25:32 +02:00
|
|
|
const int dirCount = m_svnDirectories.size();
|
|
|
|
for (int i = 0; i < dirCount; i++) {
|
2014-11-03 15:35:00 +01:00
|
|
|
const QDir svnDir(directory.absoluteFilePath(m_svnDirectories.at(i)));
|
|
|
|
if (!svnDir.exists())
|
2011-10-19 14:06:40 +00:00
|
|
|
continue;
|
2014-11-05 17:53:57 +01:00
|
|
|
if (!svnDir.exists(QLatin1String("wc.db")))
|
2011-10-19 14:06:40 +00:00
|
|
|
continue;
|
|
|
|
return true;
|
2009-05-26 12:25:32 +02:00
|
|
|
}
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-30 12:31:47 +01:00
|
|
|
QString SubversionPluginPrivate::displayName() const
|
2009-12-08 14:26:41 +01:00
|
|
|
{
|
2020-01-30 12:31:47 +01:00
|
|
|
return QLatin1String("subversion");
|
|
|
|
}
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id SubversionPluginPrivate::id() const
|
2020-01-30 12:31:47 +01:00
|
|
|
{
|
2020-06-26 13:59:38 +02:00
|
|
|
return Utils::Id(VcsBase::Constants::VCS_ID_SUBVERSION);
|
2020-01-30 12:31:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
|
|
|
|
{
|
|
|
|
return isVcsDirectory(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::isConfigured() const
|
|
|
|
{
|
2021-03-18 18:23:21 +01:00
|
|
|
const FilePath binary = m_settings.binaryPath.filePath();
|
2020-01-30 12:31:47 +01:00
|
|
|
if (binary.isEmpty())
|
|
|
|
return false;
|
|
|
|
QFileInfo fi = binary.toFileInfo();
|
|
|
|
return fi.exists() && fi.isFile() && fi.isExecutable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::supportsOperation(Operation operation) const
|
|
|
|
{
|
|
|
|
bool rc = isConfigured();
|
|
|
|
switch (operation) {
|
|
|
|
case AddOperation:
|
|
|
|
case DeleteOperation:
|
|
|
|
case MoveOperation:
|
|
|
|
case AnnotateOperation:
|
|
|
|
case InitialCheckoutOperation:
|
|
|
|
break;
|
|
|
|
case CreateRepositoryOperation:
|
|
|
|
case SnapshotOperations:
|
|
|
|
rc = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::vcsOpen(const QString & /* fileName */)
|
|
|
|
{
|
|
|
|
// Open for edit: N/A
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::vcsAdd(const QString &fileName)
|
|
|
|
{
|
|
|
|
const QFileInfo fi(fileName);
|
|
|
|
return vcsAdd(fi.absolutePath(), fi.fileName());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::vcsDelete(const QString &fileName)
|
|
|
|
{
|
|
|
|
const QFileInfo fi(fileName);
|
|
|
|
return vcsDelete(fi.absolutePath(), fi.fileName());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::vcsMove(const QString &from, const QString &to)
|
|
|
|
{
|
|
|
|
const QFileInfo fromInfo(from);
|
|
|
|
const QFileInfo toInfo(to);
|
|
|
|
return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SubversionPluginPrivate::vcsCreateRepository(const QString &)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-17 23:34:16 +03:00
|
|
|
void SubversionPluginPrivate::vcsAnnotate(const QString &file, int line)
|
2020-01-30 12:31:47 +01:00
|
|
|
{
|
|
|
|
const QFileInfo fi(file);
|
|
|
|
vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line);
|
|
|
|
}
|
|
|
|
|
|
|
|
Core::ShellCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
|
|
|
const Utils::FilePath &baseDirectory,
|
|
|
|
const QString &localName,
|
|
|
|
const QStringList &extraArgs)
|
|
|
|
{
|
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("checkout");
|
|
|
|
args << SubversionClient::addAuthenticationOptions(m_settings);
|
|
|
|
args << QLatin1String(Subversion::Constants::NON_INTERACTIVE_OPTION);
|
|
|
|
args << extraArgs << url << localName;
|
|
|
|
|
|
|
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
|
2021-03-18 18:23:21 +01:00
|
|
|
command->addJob({m_settings.binaryPath.filePath(), args}, -1);
|
2020-01-30 12:31:47 +01:00
|
|
|
return command;
|
2009-12-08 14:26:41 +01:00
|
|
|
}
|
|
|
|
|
2020-01-30 17:02:30 +01:00
|
|
|
QString SubversionTopicCache::trackFile(const QString &repository)
|
|
|
|
{
|
|
|
|
return m_plugin->monitorFile(repository);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SubversionTopicCache::refreshTopic(const QString &repository)
|
|
|
|
{
|
|
|
|
return m_plugin->synchronousTopic(repository);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-19 23:19:38 +02:00
|
|
|
#ifdef WITH_TESTS
|
2013-01-28 22:02:35 +02:00
|
|
|
void SubversionPlugin::testLogResolving()
|
|
|
|
{
|
|
|
|
QByteArray data(
|
|
|
|
"------------------------------------------------------------------------\n"
|
|
|
|
"r1439551 | philip | 2013-01-28 20:19:55 +0200 (Mon, 28 Jan 2013) | 4 lines\n"
|
|
|
|
"\n"
|
|
|
|
"* subversion/tests/cmdline/update_tests.py\n"
|
|
|
|
" (update_moved_dir_file_move): Resolve conflict, adjust expectations,\n"
|
|
|
|
" remove XFail.\n"
|
|
|
|
"\n"
|
|
|
|
"------------------------------------------------------------------------\n"
|
|
|
|
"r1439540 | philip | 2013-01-28 20:06:36 +0200 (Mon, 28 Jan 2013) | 4 lines\n"
|
|
|
|
"\n"
|
|
|
|
"* subversion/tests/cmdline/update_tests.py\n"
|
|
|
|
" (update_moved_dir_edited_leaf_del): Do non-recursive resolution, adjust\n"
|
|
|
|
" expectations, remove XFail.\n"
|
|
|
|
"\n"
|
|
|
|
);
|
2020-02-12 11:51:45 +01:00
|
|
|
VcsBaseEditorWidget::testLogResolving(dd->logEditorFactory, data, "r1439551", "r1439540");
|
2013-01-28 22:02:35 +02:00
|
|
|
}
|
2020-01-30 17:02:30 +01:00
|
|
|
|
2013-01-19 23:19:38 +02:00
|
|
|
#endif
|
|
|
|
|
2011-03-25 16:39:33 +01:00
|
|
|
} // Internal
|
|
|
|
} // Subversion
|