2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
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 "settingspage.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"
|
|
|
|
#include "subversioncontrol.h"
|
2009-07-17 17:19:23 +02:00
|
|
|
#include "checkoutwizard.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>
|
2011-03-25 16:39:33 +01:00
|
|
|
#include <vcsbase/vcsbaseeditorparameterwidget.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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>
|
|
|
|
#include <coreplugin/id.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>
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
2010-02-12 16:03:08 +01:00
|
|
|
|
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>
|
2014-07-28 17:47:15 +02:00
|
|
|
#include <utils/synchronousprocess.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 <QtPlugin>
|
|
|
|
#include <QProcessEnvironment>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QXmlStreamReader>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QInputDialog>
|
2014-07-28 17:47:15 +02:00
|
|
|
|
2009-02-09 17:33:31 +01:00
|
|
|
#include <limits.h>
|
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;
|
|
|
|
|
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";
|
|
|
|
|
|
|
|
const char SUBVERSION_SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.svn.submit";
|
|
|
|
const char SUBVERSIONCOMMITEDITOR_ID[] = "Subversion Commit Editor";
|
|
|
|
const char SUBVERSIONCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Subversion Commit Editor");
|
|
|
|
const char SUBMIT_CURRENT[] = "Subversion.SubmitCurrentLog";
|
|
|
|
const char DIFF_SELECTED[] = "Subversion.DiffSelectedFilesInLog";
|
|
|
|
|
|
|
|
const VcsBaseEditorParameters editorParameters[] = {
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
LogOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
"Subversion File Log Editor", // id
|
|
|
|
QT_TRANSLATE_NOOP("VCS", "Subversion File Log Editor"), // display_name
|
2013-05-21 23:37:47 +03:00
|
|
|
"text/vnd.qtcreator.svn.log"},
|
2014-05-18 19:29:56 +02:00
|
|
|
{ AnnotateOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
"Subversion Annotation Editor", // id
|
|
|
|
QT_TRANSLATE_NOOP("VCS", "Subversion Annotation Editor"), // display_name
|
2013-05-21 23:37:47 +03:00
|
|
|
"text/vnd.qtcreator.svn.annotation"},
|
2014-05-18 19:29:56 +02:00
|
|
|
{ DiffOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
"Subversion Diff Editor", // id
|
|
|
|
QT_TRANSLATE_NOOP("VCS", "Subversion Diff Editor"), // display_name
|
2013-05-21 20:54:26 +03:00
|
|
|
"text/x-patch"}
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Utility to find a parameter set by type
|
2014-05-18 19:29:56 +02:00
|
|
|
static const VcsBaseEditorParameters *findType(int ie)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const EditorContentType et = static_cast<EditorContentType>(ie);
|
2014-08-27 17:50:20 +02:00
|
|
|
return VcsBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(editorParameters[0]), et);
|
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
|
|
|
}
|
|
|
|
|
2009-01-12 17:44:04 +01:00
|
|
|
// Parse "svn status" output for added/modified/deleted files
|
|
|
|
// "M<7blanks>file"
|
|
|
|
typedef QList<SubversionSubmitEditor::StatusFilePair> StatusList;
|
|
|
|
|
|
|
|
StatusList parseStatusOutput(const QString &output)
|
|
|
|
{
|
|
|
|
StatusList changeSet;
|
|
|
|
const QString newLine = QString(QLatin1Char('\n'));
|
|
|
|
const QStringList list = output.split(newLine, QString::SkipEmptyParts);
|
|
|
|
foreach (const QString &l, list) {
|
|
|
|
const QString line =l.trimmed();
|
|
|
|
if (line.size() > 8) {
|
|
|
|
const QChar state = line.at(0);
|
|
|
|
if (state == QLatin1Char('A') || state == QLatin1Char('D') || state == QLatin1Char('M')) {
|
2009-04-03 12:17:33 +02:00
|
|
|
const QString fileName = line.mid(7); // Column 8 starting from svn 1.6
|
|
|
|
changeSet.push_back(SubversionSubmitEditor::StatusFilePair(QString(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;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// ------------- SubversionPlugin
|
|
|
|
SubversionPlugin *SubversionPlugin::m_subversionPluginInstance = 0;
|
|
|
|
|
|
|
|
SubversionPlugin::SubversionPlugin() :
|
2009-05-26 12:25:32 +02:00
|
|
|
m_svnDirectories(svnDirectories()),
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_addAction(0),
|
|
|
|
m_deleteAction(0),
|
|
|
|
m_revertAction(0),
|
|
|
|
m_diffProjectAction(0),
|
|
|
|
m_diffCurrentAction(0),
|
2010-01-07 11:33:30 +01:00
|
|
|
m_logProjectAction(0),
|
|
|
|
m_logRepositoryAction(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_commitAllAction(0),
|
2010-01-11 17:17:16 +01:00
|
|
|
m_revertRepositoryAction(0),
|
2010-04-27 12:16:51 +02:00
|
|
|
m_diffRepositoryAction(0),
|
|
|
|
m_statusRepositoryAction(0),
|
|
|
|
m_updateRepositoryAction(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_commitCurrentAction(0),
|
|
|
|
m_filelogCurrentAction(0),
|
|
|
|
m_annotateCurrentAction(0),
|
2009-12-08 16:50:27 +01:00
|
|
|
m_statusProjectAction(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_updateProjectAction(0),
|
2010-04-27 12:16:51 +02:00
|
|
|
m_commitProjectAction(0),
|
2009-02-09 17:33:31 +01:00
|
|
|
m_describeAction(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_submitCurrentLogAction(0),
|
|
|
|
m_submitDiffAction(0),
|
|
|
|
m_submitUndoAction(0),
|
2009-03-20 10:16:18 +01:00
|
|
|
m_submitRedoAction(0),
|
2009-12-08 14:26:41 +01:00
|
|
|
m_menuAction(0),
|
2009-03-20 10:16:18 +01:00
|
|
|
m_submitActionTriggered(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SubversionPlugin::~SubversionPlugin()
|
|
|
|
{
|
2013-09-27 15:39:16 +02:00
|
|
|
delete m_client;
|
2009-09-22 12:23:44 +02:00
|
|
|
cleanCommitMessageFile();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-09-22 12:23:44 +02:00
|
|
|
void SubversionPlugin::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 12:23:44 +02:00
|
|
|
bool SubversionPlugin::isCommitEditorOpen() const
|
|
|
|
{
|
|
|
|
return !m_commitMessageFileName.isEmpty();
|
|
|
|
}
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBaseSubmitEditorParameters submitParameters = {
|
2014-07-28 17:47:15 +02:00
|
|
|
SUBVERSION_SUBMIT_MIMETYPE,
|
|
|
|
SUBVERSIONCOMMITEDITOR_ID,
|
|
|
|
SUBVERSIONCOMMITEDITOR_DISPLAY_NAME,
|
2014-05-18 19:29:56 +02:00
|
|
|
VcsBaseSubmitEditorParameters::DiffFiles
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
2009-12-08 14:26:41 +01:00
|
|
|
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
using namespace Constants;
|
|
|
|
using namespace Core::Constants;
|
|
|
|
|
2011-06-04 21:07:34 +02:00
|
|
|
initializeVcs(new SubversionControl(this));
|
2009-12-08 14:26:41 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
m_subversionPluginInstance = this;
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage))
|
2008-12-02 12:01:29 +01:00
|
|
|
return false;
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_settings.readSettings(ICore::settings());
|
2013-09-27 15:39:16 +02:00
|
|
|
m_client = new SubversionClient(&m_settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-14 17:20:20 +02:00
|
|
|
addAutoReleasedObject(new SettingsPage);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-08-28 22:23:29 +02:00
|
|
|
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters,
|
|
|
|
[]() { return new SubversionSubmitEditor(&submitParameters); }));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
static const char *describeSlot = SLOT(describe(QString,QString));
|
2014-05-18 19:29:56 +02:00
|
|
|
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
|
2014-08-21 20:43:33 +02:00
|
|
|
const auto widgetCreator = []() { return new SubversionEditorWidget; };
|
2009-07-14 17:20:20 +02:00
|
|
|
for (int i = 0; i < editorCount; i++)
|
2014-08-21 01:24:38 +02:00
|
|
|
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-07-28 18:46:34 +02:00
|
|
|
auto checkoutWizardFactory = new BaseCheckoutWizardFactory;
|
|
|
|
checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION));
|
|
|
|
checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/subversion/images/subversion.png")));
|
|
|
|
checkoutWizardFactory->setDescription(tr("Checks out a Subversion repository and tries to load the contained project."));
|
|
|
|
checkoutWizardFactory->setDisplayName(tr("Subversion Checkout"));
|
|
|
|
checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) {
|
|
|
|
return new CheckoutWizard(path, parent);
|
|
|
|
});
|
|
|
|
addAutoReleasedObject(checkoutWizardFactory);
|
2009-07-17 17:19:23 +02:00
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
const QString prefix = QLatin1String("svn");
|
2014-05-18 19:29:56 +02:00
|
|
|
m_commandLocator = new CommandLocator("Subversion", prefix, prefix);
|
2010-02-12 16:03:08 +01:00
|
|
|
addAutoReleasedObject(m_commandLocator);
|
|
|
|
|
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();
|
2014-05-18 19:29:56 +02:00
|
|
|
Context globalcontext(C_GLOBAL);
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::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,
|
2010-01-11 17:17:16 +01:00
|
|
|
CMD_ID_DIFF_CURRENT, globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-05-18 19:29:56 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+D") : tr("Alt+S,Alt+D")));
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(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,
|
2010-01-11 17:17:16 +01:00
|
|
|
CMD_ID_FILELOG_CURRENT, globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(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,
|
2010-01-11 17:17:16 +01:00
|
|
|
CMD_ID_ANNOTATE_CURRENT, globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(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
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
subversionMenu->addSeparator(globalcontext);
|
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,
|
2008-12-02 12:01:29 +01:00
|
|
|
globalcontext);
|
2009-12-08 16:50:27 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-05-18 19:29:56 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+A") : tr("Alt+S,Alt+A")));
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(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,
|
2009-07-14 17:20:20 +02:00
|
|
|
CMD_ID_COMMIT_CURRENT, globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-05-18 19:29:56 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+C") : tr("Alt+S,Alt+C")));
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
|
|
|
|
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,
|
2010-01-11 17:17:16 +01:00
|
|
|
globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(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,
|
2010-01-11 17:17:16 +01:00
|
|
|
globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2010-01-11 17:17:16 +01:00
|
|
|
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(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
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
subversionMenu->addSeparator(globalcontext);
|
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,
|
2010-01-11 17:17:16 +01:00
|
|
|
globalcontext);
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
|
|
|
|
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,
|
2008-12-02 12:01:29 +01:00
|
|
|
globalcontext);
|
2009-12-08 16:50:27 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(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);
|
|
|
|
command = ActionManager::registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
|
2010-01-07 11:33:30 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
|
|
|
|
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);
|
|
|
|
command = ActionManager::registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
|
2009-12-08 16:50:27 +01:00
|
|
|
command->setAttribute(Core::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);
|
|
|
|
command = ActionManager::registerAction(m_commitProjectAction, CMD_ID_COMMIT_PROJECT, globalcontext);
|
2010-04-27 12:16:51 +02:00
|
|
|
connect(m_commitProjectAction, SIGNAL(triggered()), this, SLOT(startCommitProject()));
|
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
subversionMenu->addSeparator(globalcontext);
|
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-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, globalcontext);
|
2010-04-27 12:16:51 +02:00
|
|
|
connect(m_diffRepositoryAction, SIGNAL(triggered()), this, SLOT(diffRepository()));
|
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
m_statusRepositoryAction = new QAction(tr("Repository Status"), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_statusRepositoryAction, CMD_ID_REPOSITORYSTATUS, globalcontext);
|
2010-04-27 12:16:51 +02:00
|
|
|
connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository()));
|
|
|
|
subversionMenu->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
m_logRepositoryAction = new QAction(tr("Log Repository"), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
|
2010-01-07 11:33:30 +01:00
|
|
|
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
|
|
|
|
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-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_updateRepositoryAction, CMD_ID_REPOSITORYUPDATE, globalcontext);
|
2010-04-27 12:16:51 +02:00
|
|
|
connect(m_updateRepositoryAction, SIGNAL(triggered()), this, SLOT(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,
|
2010-01-11 17:17:16 +01:00
|
|
|
globalcontext);
|
|
|
|
connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
|
|
|
|
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-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_describeAction, CMD_ID_DESCRIBE, globalcontext);
|
2010-04-27 12:16:51 +02:00
|
|
|
connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe()));
|
|
|
|
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,
|
2010-01-11 17:17:16 +01:00
|
|
|
globalcontext);
|
|
|
|
connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll()));
|
|
|
|
subversionMenu->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 17:17:16 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Actions of the submit editor
|
2014-09-02 12:25:20 +02:00
|
|
|
Context svncommitcontext(SUBVERSIONCOMMITEDITOR_ID);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_submitCurrentLogAction = new QAction(VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_submitCurrentLogAction, SUBMIT_CURRENT, svncommitcontext);
|
2010-08-19 10:04:21 +02:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog()));
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
m_submitDiffAction = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_submitDiffAction , DIFF_SELECTED, svncommitcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
m_submitUndoAction = new QAction(tr("&Undo"), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_submitUndoAction, Core::Constants::UNDO, svncommitcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
m_submitRedoAction = new QAction(tr("&Redo"), this);
|
2014-05-18 19:29:56 +02:00
|
|
|
command = ActionManager::registerAction(m_submitRedoAction, Core::Constants::REDO, svncommitcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-18 12:06:43 +02:00
|
|
|
bool SubversionPlugin::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;
|
|
|
|
|
2013-04-18 12:06:43 +02:00
|
|
|
SubversionSubmitEditor *editor = qobject_cast<SubversionSubmitEditor *>(submitEditor());
|
|
|
|
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
|
2013-07-04 13:30:26 +02:00
|
|
|
const QFileInfo editorFile(editorDocument->filePath());
|
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).
|
2009-06-19 16:34:38 +02:00
|
|
|
SubversionSettings newSettings = m_settings;
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBaseSubmitEditor::PromptSubmitResult answer =
|
2009-03-19 17:40:01 +01:00
|
|
|
editor->promptSubmit(tr("Closing Subversion Editor"),
|
|
|
|
tr("Do you want to commit the change?"),
|
2009-03-20 10:16:18 +01:00
|
|
|
tr("The commit message check failed. Do you want to commit the change?"),
|
2013-02-27 13:25:21 +01:00
|
|
|
newSettings.boolPointer(SubversionSettings::promptOnSubmitKey),
|
|
|
|
!m_submitActionTriggered);
|
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;
|
|
|
|
}
|
2009-06-19 16:34:38 +02:00
|
|
|
setSettings(newSettings); // in case someone turned prompting off
|
2008-12-02 12:01:29 +01:00
|
|
|
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
|
2014-05-18 19:29:56 +02:00
|
|
|
closeEditor = DocumentManager::saveDocument(editorDocument);
|
2014-05-19 18:40:37 +02:00
|
|
|
if (closeEditor) {
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *commitCmd = m_client->createCommitCmd(m_commitRepository,
|
|
|
|
fileList,
|
|
|
|
m_commitMessageFileName);
|
2014-11-03 14:23:49 +01:00
|
|
|
QObject::connect(commitCmd, &VcsCommand::finished,
|
|
|
|
this, [this]() { cleanCommitMessageFile(); });
|
2014-05-19 18:40:37 +02:00
|
|
|
commitCmd->execute();
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2009-12-08 16:50:27 +01:00
|
|
|
void SubversionPlugin::diffCommitFiles(const QStringList &files)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-27 15:39:16 +02:00
|
|
|
m_client->diff(m_commitRepository, files);
|
2011-03-25 16:39:33 +01:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QString &fileName)
|
|
|
|
{
|
2014-07-28 17:47:15 +02:00
|
|
|
IEditor *editor = EditorManager::openEditor(fileName, SUBVERSIONCOMMITEDITOR_ID);
|
2008-12-02 12:01:29 +01:00
|
|
|
SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
|
2014-05-17 23:14:34 +02:00
|
|
|
QTC_ASSERT(submitEditor, return 0);
|
2013-04-18 12:06:43 +02:00
|
|
|
setSubmitEditor(submitEditor);
|
2009-01-13 14:06:42 +01:00
|
|
|
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
|
2009-12-08 16:50:27 +01:00
|
|
|
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffCommitFiles(QStringList)));
|
2009-12-14 10:56:50 +01:00
|
|
|
submitEditor->setCheckScriptWorkingDirectory(m_commitRepository);
|
2008-12-02 12:01:29 +01:00
|
|
|
return submitEditor;
|
|
|
|
}
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
void SubversionPlugin::updateActions(VcsBasePlugin::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
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::addCurrentFile()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2010-01-11 17:17:16 +01:00
|
|
|
void SubversionPlugin::revertAll()
|
|
|
|
{
|
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;
|
|
|
|
args << QLatin1String("revert") << QLatin1String("--recursive") << state.topLevel();
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse revertResponse =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(state.topLevel(), args, m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow);
|
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
|
2010-01-11 17:17:16 +01:00
|
|
|
subVersionControl()->emitRepositoryChanged(state.topLevel());
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void SubversionPlugin::revertCurrentFile()
|
|
|
|
{
|
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"));
|
2009-12-08 16:50:27 +01:00
|
|
|
args.push_back(state.relativeCurrentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse diffResponse =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMs(), 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
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
FileChangeBlocker fcb(state.currentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// revert
|
|
|
|
args.clear();
|
2009-12-08 16:50:27 +01:00
|
|
|
args << QLatin1String("revert") << state.relativeCurrentFile();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse revertResponse =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow);
|
|
|
|
|
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)
|
2009-12-08 16:50:27 +01:00
|
|
|
subVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::diffProject()
|
|
|
|
{
|
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(),
|
|
|
|
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::diffCurrentFile()
|
|
|
|
{
|
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-09-27 15:39:16 +02:00
|
|
|
m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::startCommitCurrentFile()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::startCommitAll()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2010-04-27 12:16:51 +02:00
|
|
|
void SubversionPlugin::startCommitProject()
|
|
|
|
{
|
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. */
|
2009-12-08 16:50:27 +01:00
|
|
|
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
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"));
|
|
|
|
args += files;
|
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(), 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;
|
|
|
|
}
|
|
|
|
m_commitMessageFileName = saver.fileName();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::filelogCurrentFile()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::logProject()
|
|
|
|
{
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::logRepository()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2010-04-27 12:16:51 +02:00
|
|
|
void SubversionPlugin::diffRepository()
|
|
|
|
{
|
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);
|
2013-09-27 15:39:16 +02:00
|
|
|
m_client->diff(state.topLevel(), QStringList());
|
2010-04-27 12:16:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::statusRepository()
|
|
|
|
{
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::updateRepository()
|
|
|
|
{
|
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());
|
|
|
|
}
|
|
|
|
|
2013-08-06 15:14:54 +03:00
|
|
|
void SubversionPlugin::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"));
|
2013-08-06 15:14:54 +03:00
|
|
|
if (!relativePath.isEmpty())
|
|
|
|
args.append(relativePath);
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::setRepository(workingDir);
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-08-19 16:56:23 +02:00
|
|
|
ShowStdOutInLogWindow|ShowSuccessMessage);
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::clearRepository();
|
2010-04-27 12:16:51 +02:00
|
|
|
}
|
|
|
|
|
2010-01-07 11:33:30 +01:00
|
|
|
void SubversionPlugin::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
|
|
|
{
|
|
|
|
// no need for temp file
|
|
|
|
QStringList args(QLatin1String("log"));
|
2013-02-27 13:25:21 +01:00
|
|
|
if (m_settings.intValue(SubversionSettings::logCountKey) > 0) {
|
|
|
|
args << QLatin1String("-l")
|
|
|
|
<< QString::number(m_settings.intValue(SubversionSettings::logCountKey));
|
|
|
|
}
|
2013-08-06 15:14:54 +03:00
|
|
|
if (!file.isEmpty())
|
2009-12-08 16:50:27 +01:00
|
|
|
args.append(QDir::toNativeSeparators(file));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-03 10:20:49 +01:00
|
|
|
// subversion stores log in UTF-8 and returns it back in user system locale.
|
|
|
|
// So we do not need to encode it.
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-11-03 10:20:49 +01:00
|
|
|
SshPasswordPrompt, 0/*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
|
|
|
|
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString id = VcsBaseEditor::getTitleId(workingDir, QStringList(file));
|
|
|
|
const QString tag = VcsBaseEditor::editorTag(LogOutput, workingDir,
|
2013-08-06 15:14:54 +03:00
|
|
|
QStringList(file));
|
2014-08-27 17:50:20 +02:00
|
|
|
if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) {
|
2013-07-15 15:14:10 +02:00
|
|
|
editor->document()->setContents(response.stdOut.toUtf8());
|
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 log %1").arg(id);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString source = VcsBaseEditor::getSource(workingDir, file);
|
2014-05-18 19:29:56 +02:00
|
|
|
IEditor *newEditor = showOutputInEditor(title, response.stdOut, LogOutput, source, /*codec*/0);
|
2014-08-27 17:50:20 +02:00
|
|
|
VcsBaseEditor::tagEditor(newEditor, tag);
|
2010-01-07 11:33:30 +01:00
|
|
|
if (enableAnnotationContextMenu)
|
2014-08-27 17:50:20 +02:00
|
|
|
VcsBaseEditor::getVcsBaseEditor(newEditor)->setFileLogAnnotateEnabled(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::updateProject()
|
|
|
|
{
|
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
|
|
|
|
2013-08-06 15:14:54 +03:00
|
|
|
void SubversionPlugin::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"));
|
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);
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, 10 * m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow);
|
2009-12-08 16:50:27 +01:00
|
|
|
if (!response.error)
|
2010-04-27 12:16:51 +02:00
|
|
|
subVersionControl()->emitRepositoryChanged(workingDir);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::annotateCurrentFile()
|
|
|
|
{
|
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);
|
2010-03-19 17:22:18 +01:00
|
|
|
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-06 20:47:29 +03:00
|
|
|
void SubversionPlugin::annotateVersion(const QString &workingDirectory,
|
|
|
|
const QString &file,
|
2010-01-06 17:24:40 +01:00
|
|
|
const QString &revision,
|
|
|
|
int lineNr)
|
|
|
|
{
|
2013-10-06 20:47:29 +03:00
|
|
|
vcsAnnotate(workingDirectory, file, revision, lineNr);
|
2010-01-06 17:24:40 +01:00
|
|
|
}
|
|
|
|
|
2010-03-19 17:22:18 +01:00
|
|
|
void SubversionPlugin::vcsAnnotate(const QString &workingDir, const QString &file,
|
2010-01-06 17:24:40 +01:00
|
|
|
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"));
|
2013-02-27 13:25:21 +01:00
|
|
|
if (m_settings.boolValue(SubversionSettings::spaceIgnorantAnnotationKey))
|
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"));
|
|
|
|
args.append(QDir::toNativeSeparators(file));
|
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-11-17 17:20:22 +01:00
|
|
|
SshPasswordPrompt|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);
|
2014-05-18 19:29:56 +02:00
|
|
|
IEditor *newEditor = showOutputInEditor(title, response.stdOut, AnnotateOutput, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::projectStatus()
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::describe(const QString &source, const QString &changeNr)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
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;
|
2009-02-10 08:38:12 +01:00
|
|
|
// Run log to obtain message (local utf8)
|
|
|
|
QString description;
|
|
|
|
QStringList args(QLatin1String("log"));
|
|
|
|
args.push_back(QLatin1String("-r"));
|
|
|
|
args.push_back(changeNr);
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse logResponse =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(topLevel, args, m_settings.timeOutMs(), SshPasswordPrompt);
|
2009-02-10 08:38:12 +01:00
|
|
|
if (logResponse.error)
|
|
|
|
return;
|
|
|
|
description = logResponse.stdOut;
|
|
|
|
|
|
|
|
// Run diff (encoding via source codec)
|
|
|
|
args.clear();
|
|
|
|
args.push_back(QLatin1String("diff"));
|
2008-12-02 12:01:29 +01:00
|
|
|
args.push_back(QLatin1String("-r"));
|
|
|
|
QString diffArg;
|
|
|
|
QTextStream(&diffArg) << (number - 1) << ':' << number;
|
|
|
|
args.push_back(diffArg);
|
|
|
|
|
2014-08-27 17:50:20 +02:00
|
|
|
QTextCodec *codec = VcsBaseEditor::getCodec(source);
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(topLevel, args, m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt, codec);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (response.error)
|
|
|
|
return;
|
2009-02-10 08:38:12 +01:00
|
|
|
description += response.stdOut;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// Re-use an existing view if possible to support
|
|
|
|
// the common usage pattern of continuously changing and diffing a file
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString tag = VcsBaseEditor::editorTag(DiffOutput, source, QStringList(), changeNr);
|
|
|
|
if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) {
|
2013-07-15 15:14:10 +02:00
|
|
|
editor->document()->setContents(description.toUtf8());
|
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 describe %1#%2").arg(fi.fileName(), changeNr);
|
2014-05-18 19:29:56 +02:00
|
|
|
IEditor *newEditor = showOutputInEditor(title, description, DiffOutput, source, codec);
|
2014-08-27 17:50:20 +02:00
|
|
|
VcsBaseEditor::tagEditor(newEditor, tag);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-09 17:33:31 +01:00
|
|
|
void SubversionPlugin::slotDescribe()
|
|
|
|
{
|
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.setWindowFlags(inputDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
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();
|
2009-12-08 16:50:27 +01:00
|
|
|
describe(state.topLevel(), QString::number(revision));
|
2009-02-09 17:33:31 +01:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void SubversionPlugin::submitCurrentLog()
|
|
|
|
{
|
2009-03-20 10:16:18 +01:00
|
|
|
m_submitActionTriggered = true;
|
2014-08-19 16:15:57 +02:00
|
|
|
QTC_ASSERT(submitEditor(), return);
|
|
|
|
EditorManager::closeDocument(submitEditor()->document());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-06-08 10:04:23 +02:00
|
|
|
SubversionResponse
|
|
|
|
SubversionPlugin::runSvn(const QString &workingDir,
|
|
|
|
const QStringList &arguments,
|
|
|
|
int timeOut,
|
|
|
|
unsigned flags,
|
2013-10-02 00:18:39 +03:00
|
|
|
QTextCodec *outputCodec) const
|
2010-06-08 10:04:23 +02:00
|
|
|
{
|
2013-02-27 13:25:21 +01:00
|
|
|
const bool hasAuth = m_settings.hasAuthentication();
|
|
|
|
return runSvn(workingDir,
|
|
|
|
hasAuth ? m_settings.stringValue(SubversionSettings::userKey) : QString(),
|
|
|
|
hasAuth ? m_settings.stringValue(SubversionSettings::passwordKey) : QString(),
|
|
|
|
arguments, timeOut, flags, outputCodec);
|
2010-06-08 10:04:23 +02:00
|
|
|
}
|
|
|
|
|
2009-12-08 16:50:27 +01:00
|
|
|
SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
|
2010-06-08 10:04:23 +02:00
|
|
|
const QString &userName, const QString &password,
|
|
|
|
const QStringList &arguments, int timeOut,
|
2013-10-02 00:18:39 +03:00
|
|
|
unsigned flags, QTextCodec *outputCodec) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-07-15 23:32:11 +03:00
|
|
|
const FileName executable = m_settings.binaryPath();
|
2008-12-02 12:01:29 +01:00
|
|
|
SubversionResponse response;
|
|
|
|
if (executable.isEmpty()) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-09-27 15:39:16 +02:00
|
|
|
const QStringList completeArguments = SubversionClient::addAuthenticationOptions(arguments, userName, password);
|
2014-05-18 19:29:56 +02:00
|
|
|
const SynchronousProcessResponse sp_resp =
|
|
|
|
VcsBasePlugin::runVcs(workingDir, executable, completeArguments, timeOut,
|
2013-08-28 11:32:33 +03:00
|
|
|
flags, outputCodec);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
response.error = sp_resp.result != SynchronousProcessResponse::Finished;
|
2010-05-21 17:46:00 +02:00
|
|
|
if (response.error)
|
2014-07-15 23:32:11 +03:00
|
|
|
response.message = sp_resp.exitMessage(executable.toString(), timeOut);
|
2008-12-02 12:01:29 +01:00
|
|
|
response.stdErr = sp_resp.stdErr;
|
|
|
|
response.stdOut = sp_resp.stdOut;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2014-05-18 19:29:56 +02:00
|
|
|
IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const QString &output,
|
2008-12-02 12:01:29 +01:00
|
|
|
int editorType, const QString &source,
|
|
|
|
QTextCodec *codec)
|
|
|
|
{
|
2014-05-18 19:29:56 +02:00
|
|
|
const VcsBaseEditorParameters *params = findType(editorType);
|
2008-12-09 15:25:01 +01:00
|
|
|
QTC_ASSERT(params, return 0);
|
2014-05-18 19:29:56 +02:00
|
|
|
const Id id = params->id;
|
2008-12-02 12:01:29 +01:00
|
|
|
if (Subversion::Constants::debug)
|
2011-11-10 11:36:51 +01:00
|
|
|
qDebug() << "SubversionPlugin::showOutputInEditor" << title << id.name()
|
|
|
|
<< "Size= " << output.size() << " Type=" << editorType << 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());
|
2013-10-06 20:47:29 +03:00
|
|
|
connect(editor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
|
|
|
|
this, SLOT(annotateVersion(QString,QString,QString,int)));
|
2014-08-21 20:43:33 +02:00
|
|
|
SubversionEditorWidget *e = qobject_cast<SubversionEditorWidget*>(editor->widget());
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!e)
|
|
|
|
return 0;
|
2010-06-07 14:53:28 +02:00
|
|
|
e->setForceReadOnly(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
2014-08-01 23:31:56 +02:00
|
|
|
e->textDocument()->setSuggestedFileName(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
|
|
|
}
|
|
|
|
|
|
|
|
SubversionSettings SubversionPlugin::settings() const
|
|
|
|
{
|
|
|
|
return m_settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::setSettings(const SubversionSettings &s)
|
|
|
|
{
|
|
|
|
if (s != m_settings) {
|
|
|
|
m_settings = s;
|
2014-05-18 19:29:56 +02:00
|
|
|
m_settings.writeSettings(ICore::settings());
|
2011-04-15 17:43:44 +02:00
|
|
|
subVersionControl()->emitConfigurationChanged();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 15:49:06 +02:00
|
|
|
SubversionPlugin *SubversionPlugin::instance()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-12 17:02:55 +01:00
|
|
|
QTC_ASSERT(m_subversionPluginInstance, return m_subversionPluginInstance);
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_subversionPluginInstance;
|
|
|
|
}
|
|
|
|
|
2014-11-04 16:35:14 +01:00
|
|
|
QString SubversionPlugin::monitorFile(const QString &repository) const
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SubversionPlugin::synchronousTopic(const QString &repository) const
|
|
|
|
{
|
|
|
|
return m_client->synchronousTopic(repository);
|
|
|
|
}
|
|
|
|
|
2009-12-08 16:50:27 +01:00
|
|
|
bool SubversionPlugin::vcsAdd(const QString &workingDir, const QString &rawFileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
const QString file = QDir::toNativeSeparators(rawFileName);
|
2010-01-06 10:57:07 +01:00
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("add") << QLatin1String("--parents") << file;
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow);
|
2008-12-02 12:01:29 +01:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2009-12-08 16:50:27 +01:00
|
|
|
bool SubversionPlugin::vcsDelete(const QString &workingDir, const QString &rawFileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
const QString file = QDir::toNativeSeparators(rawFileName);
|
|
|
|
|
2014-11-03 14:01:39 +01:00
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("delete") << QLatin1String("--force") << file;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-05-21 17:46:00 +02:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow);
|
2008-12-02 12:01:29 +01:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2010-05-11 14:13:38 +02:00
|
|
|
bool SubversionPlugin::vcsMove(const QString &workingDir, const QString &from, const QString &to)
|
|
|
|
{
|
|
|
|
QStringList args(QLatin1String("move"));
|
|
|
|
args << QDir::toNativeSeparators(from) << QDir::toNativeSeparators(to);
|
2010-05-21 17:46:00 +02:00
|
|
|
const SubversionResponse response =
|
2013-02-27 13:25:21 +01:00
|
|
|
runSvn(workingDir, args, m_settings.timeOutMs(),
|
2010-11-22 14:53:20 +01:00
|
|
|
SshPasswordPrompt|ShowStdOutInLogWindow|FullySynchronously);
|
2010-05-11 14:13:38 +02:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
|
2010-09-29 12:16:35 +02:00
|
|
|
bool SubversionPlugin::vcsCheckout(const QString &directory, const QByteArray &url)
|
|
|
|
{
|
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
|
|
|
|
2011-09-19 10:02:45 +02:00
|
|
|
if (!username.isEmpty() && !password.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());
|
|
|
|
args << QLatin1String(tempUrl.toEncoded()) << directory;
|
2010-09-29 12:16:37 +02:00
|
|
|
const SubversionResponse response = runSvn(directory, username, password, args,
|
2013-02-27 13:25:21 +01:00
|
|
|
10 * m_settings.timeOutMs(),
|
2014-05-18 19:29:56 +02:00
|
|
|
VcsBasePlugin::SshPasswordPrompt);
|
2010-09-29 12:16:35 +02:00
|
|
|
return !response.error;
|
|
|
|
} else {
|
2012-01-31 10:57:10 +01:00
|
|
|
args << QLatin1String(url) << directory;
|
2013-02-27 13:25:21 +01:00
|
|
|
const SubversionResponse response = runSvn(directory, args, 10 * m_settings.timeOutMs(),
|
2014-05-18 19:29:56 +02:00
|
|
|
VcsBasePlugin::SshPasswordPrompt);
|
2010-09-29 12:16:35 +02:00
|
|
|
return !response.error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString SubversionPlugin::vcsGetRepositoryURL(const QString &directory)
|
|
|
|
{
|
|
|
|
QXmlStreamReader xml;
|
|
|
|
QStringList args = QStringList(QLatin1String("info"));
|
|
|
|
args << QLatin1String("--xml");
|
|
|
|
|
2013-02-27 13:25:21 +01:00
|
|
|
const SubversionResponse response = runSvn(directory, args, 10 * m_settings.timeOutMs(), SuppressCommandLogging);
|
2010-09-29 12:16:35 +02:00
|
|
|
xml.addData(response.stdOut);
|
|
|
|
|
|
|
|
bool repo = false;
|
|
|
|
bool root = false;
|
|
|
|
|
2012-11-28 20:44:03 +02:00
|
|
|
while (!xml.atEnd() && !xml.hasError()) {
|
|
|
|
switch (xml.readNext()) {
|
2010-09-29 12:16:35 +02:00
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
break;
|
|
|
|
case QXmlStreamReader::StartElement:
|
2012-11-28 20:44:03 +02:00
|
|
|
if (xml.name() == QLatin1String("repository"))
|
2010-09-29 12:16:35 +02:00
|
|
|
repo = true;
|
2012-11-28 20:44:03 +02:00
|
|
|
else if (repo && xml.name() == QLatin1String("root"))
|
2010-09-29 12:16:35 +02:00
|
|
|
root = true;
|
|
|
|
break;
|
|
|
|
case QXmlStreamReader::EndElement:
|
2012-11-28 20:44:03 +02:00
|
|
|
if (xml.name() == QLatin1String("repository"))
|
2010-09-29 12:16:35 +02:00
|
|
|
repo = false;
|
2012-11-28 20:44:03 +02:00
|
|
|
else if (repo && xml.name() == QLatin1String("root"))
|
2010-09-29 12:16:35 +02:00
|
|
|
root = false;
|
|
|
|
break;
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
if (repo && root)
|
|
|
|
return xml.text().toString();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2010-05-20 16:24:39 +02:00
|
|
|
bool SubversionPlugin::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
|
|
|
}
|
|
|
|
|
2013-10-02 00:18:39 +03:00
|
|
|
bool SubversionPlugin::managesFile(const QString &workingDirectory, const QString &fileName) const
|
|
|
|
{
|
|
|
|
QStringList args;
|
|
|
|
args << QLatin1String("status") << fileName;
|
|
|
|
SubversionResponse response =
|
|
|
|
runSvn(workingDirectory, args, m_settings.timeOutMs(), 0);
|
|
|
|
return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?');
|
|
|
|
}
|
|
|
|
|
2010-05-20 16:24:39 +02:00
|
|
|
// Check whether SVN management subdirs exist.
|
2014-11-05 17:53:57 +01:00
|
|
|
bool SubversionPlugin::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
|
|
|
}
|
|
|
|
|
2009-12-08 14:26:41 +01:00
|
|
|
SubversionControl *SubversionPlugin::subVersionControl() const
|
|
|
|
{
|
|
|
|
return static_cast<SubversionControl *>(versionControl());
|
|
|
|
}
|
|
|
|
|
2013-01-19 23:19:38 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
void SubversionPlugin::testDiffFileResolving_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QByteArray>("header");
|
|
|
|
QTest::addColumn<QByteArray>("fileName");
|
|
|
|
|
|
|
|
QTest::newRow("New") << QByteArray(
|
|
|
|
"Index: src/plugins/subversion/subversioneditor.cpp\n"
|
|
|
|
"===================================================================\n"
|
|
|
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
|
|
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
|
|
|
"@@ -0,0 +125 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
|
|
|
|
QTest::newRow("Deleted") << QByteArray(
|
|
|
|
"Index: src/plugins/subversion/subversioneditor.cpp\n"
|
|
|
|
"===================================================================\n"
|
|
|
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
|
|
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
|
|
|
"@@ -1,125 +0,0 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
|
|
|
|
QTest::newRow("Normal") << QByteArray(
|
|
|
|
"Index: src/plugins/subversion/subversioneditor.cpp\n"
|
|
|
|
"===================================================================\n"
|
|
|
|
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
|
|
|
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
|
|
|
"@@ -120,7 +120,7 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/subversion/subversioneditor.cpp");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubversionPlugin::testDiffFileResolving()
|
|
|
|
{
|
2014-08-28 13:45:42 +02:00
|
|
|
VcsBaseEditorWidget::testDiffFileResolving(editorParameters[2].id);
|
2013-01-19 23:19:38 +02:00
|
|
|
}
|
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"
|
|
|
|
);
|
2014-08-28 13:45:42 +02:00
|
|
|
VcsBaseEditorWidget::testLogResolving(editorParameters[0].id, data, "r1439551", "r1439540");
|
2013-01-28 22:02:35 +02:00
|
|
|
}
|
2013-01-19 23:19:38 +02:00
|
|
|
#endif
|
|
|
|
|
2011-03-25 16:39:33 +01:00
|
|
|
} // Internal
|
|
|
|
} // Subversion
|
|
|
|
|