2009-11-02 18:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Brian McGillion
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2009-11-02 18:50:06 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-11-02 18:50:06 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2009-11-02 18:50:06 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
#include "mercurialplugin.h"
|
|
|
|
|
#include "optionspage.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
#include "mercurialclient.h"
|
|
|
|
|
#include "mercurialcontrol.h"
|
|
|
|
|
#include "mercurialeditor.h"
|
|
|
|
|
#include "revertdialog.h"
|
|
|
|
|
#include "srcdestdialog.h"
|
|
|
|
|
#include "commiteditor.h"
|
|
|
|
|
#include "clonewizard.h"
|
|
|
|
|
#include "mercurialsettings.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2010-11-02 16:53:56 +01:00
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
2010-01-11 15:22:17 +01:00
|
|
|
#include <coreplugin/vcsmanager.h>
|
2009-09-15 13:03:13 +03:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/filemanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
#include <locator/commandlocator.h>
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
#include <utils/parameteraction.h>
|
2009-12-08 14:28:00 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
#include <vcsbase/basevcseditorfactory.h>
|
|
|
|
|
#include <vcsbase/basevcssubmiteditorfactory.h>
|
|
|
|
|
#include <vcsbase/vcsbaseeditor.h>
|
2009-11-03 14:21:48 +01:00
|
|
|
#include <vcsbase/vcsbaseoutputwindow.h>
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
#include <QtCore/QtPlugin>
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
|
#include <QtCore/QtDebug>
|
|
|
|
|
#include <QtCore/QtGlobal>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtGui/QDialog>
|
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
|
#include <QtCore/QTemporaryFile>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace Mercurial::Internal;
|
|
|
|
|
using namespace Mercurial;
|
|
|
|
|
|
|
|
|
|
static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
|
|
|
|
|
{
|
|
|
|
|
VCSBase::RegularCommandOutput, //type
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::COMMANDLOG_ID, // id
|
|
|
|
|
Constants::COMMANDLOG_DISPLAY_NAME, // display name
|
2009-09-15 13:03:13 +03:00
|
|
|
Constants::COMMANDLOG, // context
|
|
|
|
|
Constants::COMMANDAPP, // mime type
|
|
|
|
|
Constants::COMMANDEXT}, //extension
|
|
|
|
|
|
|
|
|
|
{ VCSBase::LogOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::FILELOG_ID,
|
|
|
|
|
Constants::FILELOG_DISPLAY_NAME,
|
2009-09-15 13:03:13 +03:00
|
|
|
Constants::FILELOG,
|
|
|
|
|
Constants::LOGAPP,
|
|
|
|
|
Constants::LOGEXT},
|
|
|
|
|
|
|
|
|
|
{ VCSBase::AnnotateOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::ANNOTATELOG_ID,
|
|
|
|
|
Constants::ANNOTATELOG_DISPLAY_NAME,
|
2009-09-15 13:03:13 +03:00
|
|
|
Constants::ANNOTATELOG,
|
|
|
|
|
Constants::ANNOTATEAPP,
|
|
|
|
|
Constants::ANNOTATEEXT},
|
|
|
|
|
|
|
|
|
|
{ VCSBase::DiffOutput,
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::DIFFLOG_ID,
|
|
|
|
|
Constants::DIFFLOG_DISPLAY_NAME,
|
2009-09-15 13:03:13 +03:00
|
|
|
Constants::DIFFLOG,
|
|
|
|
|
Constants::DIFFAPP,
|
|
|
|
|
Constants::DIFFEXT}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const VCSBase::VCSBaseSubmitEditorParameters submitEditorParameters = {
|
|
|
|
|
Constants::COMMITMIMETYPE,
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::COMMIT_ID,
|
|
|
|
|
Constants::COMMIT_DISPLAY_NAME,
|
|
|
|
|
Constants::COMMIT_ID
|
2009-09-15 13:03:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Utility to find a parameter set by type
|
|
|
|
|
static inline const VCSBase::VCSBaseEditorParameters *findType(int ie)
|
|
|
|
|
{
|
|
|
|
|
const VCSBase::EditorContentType et = static_cast<VCSBase::EditorContentType>(ie);
|
2011-02-21 16:02:26 +01:00
|
|
|
return VCSBase::VCSBaseEditorWidget::findType(editorParameters,
|
2009-09-15 13:03:13 +03:00
|
|
|
sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters), et);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MercurialPlugin *MercurialPlugin::m_instance = 0;
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
MercurialPlugin::MercurialPlugin() :
|
2010-01-08 09:48:54 +01:00
|
|
|
VCSBase::VCSBasePlugin(QLatin1String(Constants::COMMIT_ID)),
|
2009-09-15 13:03:13 +03:00
|
|
|
optionsPage(0),
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client(0),
|
2010-02-12 16:03:08 +01:00
|
|
|
core(0),
|
|
|
|
|
m_commandLocator(0),
|
2009-12-08 14:28:00 +01:00
|
|
|
changeLog(0),
|
2010-01-11 15:22:17 +01:00
|
|
|
m_addAction(0),
|
|
|
|
|
m_deleteAction(0),
|
2010-01-12 16:45:21 +01:00
|
|
|
m_createRepositoryAction(0),
|
2009-12-08 14:28:00 +01:00
|
|
|
m_menuAction(0)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MercurialPlugin::~MercurialPlugin()
|
|
|
|
|
{
|
2010-01-08 09:44:07 +01:00
|
|
|
if (m_client) {
|
|
|
|
|
delete m_client;
|
|
|
|
|
m_client = 0;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCommitLog();
|
|
|
|
|
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * /*error_message */)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
typedef VCSBase::VCSEditorFactory<MercurialEditor> MercurialEditorFactory;
|
|
|
|
|
|
2011-06-10 14:02:46 +00:00
|
|
|
m_client = new MercurialClient(&mercurialSettings);
|
2011-06-04 21:07:34 +02:00
|
|
|
initializeVcs(new MercurialControl(m_client));
|
2009-12-08 14:28:00 +01:00
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
core = Core::ICore::instance();
|
|
|
|
|
actionManager = core->actionManager();
|
|
|
|
|
|
|
|
|
|
optionsPage = new OptionsPage();
|
|
|
|
|
addAutoReleasedObject(optionsPage);
|
2011-06-23 10:32:37 +02:00
|
|
|
mercurialSettings.readSettings(core->settings());
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-08 09:44:07 +01:00
|
|
|
connect(optionsPage, SIGNAL(settingsChanged()), m_client, SLOT(settingsChanged()));
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-08 09:44:07 +01:00
|
|
|
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
static const char *describeSlot = SLOT(view(QString,QString));
|
|
|
|
|
const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters);
|
|
|
|
|
for (int i = 0; i < editorCount; i++)
|
2010-01-08 09:44:07 +01:00
|
|
|
addAutoReleasedObject(new MercurialEditorFactory(editorParameters + i, m_client, describeSlot));
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
addAutoReleasedObject(new VCSBase::VCSSubmitEditorFactory<CommitEditor>(&submitEditorParameters));
|
|
|
|
|
|
|
|
|
|
addAutoReleasedObject(new CloneWizard);
|
|
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
const QString prefix = QLatin1String("hg");
|
|
|
|
|
m_commandLocator = new Locator::CommandLocator(QLatin1String("Mercurial"), prefix, prefix);
|
|
|
|
|
addAutoReleasedObject(m_commandLocator);
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
createMenu();
|
|
|
|
|
|
|
|
|
|
createSubmitEditorActions();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
const MercurialSettings &MercurialPlugin::settings() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return mercurialSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
void MercurialPlugin::setSettings(const MercurialSettings &settings)
|
|
|
|
|
{
|
|
|
|
|
if (settings != mercurialSettings) {
|
|
|
|
|
mercurialSettings = settings;
|
2011-04-15 17:43:44 +02:00
|
|
|
static_cast<MercurialControl *>(versionControl())->emitConfigurationChanged();
|
2009-11-06 12:32:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
QStringList MercurialPlugin::standardArguments() const
|
|
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
return mercurialSettings.standardArguments();
|
2009-11-05 12:45:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
void MercurialPlugin::createMenu()
|
|
|
|
|
{
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context context(Core::Constants::C_GLOBAL);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
// Create menu item for Mercurial
|
2010-09-10 14:13:19 +02:00
|
|
|
mercurialContainer = actionManager->createMenu(Core::Id("Mercurial.MercurialMenu"));
|
2009-09-15 13:03:13 +03:00
|
|
|
QMenu *menu = mercurialContainer->menu();
|
|
|
|
|
menu->setTitle(tr("Mercurial"));
|
|
|
|
|
|
|
|
|
|
createFileActions(context);
|
2011-02-28 17:28:41 +01:00
|
|
|
createSeparator(context, Core::Id("Mercurial.FileDirSeperator"));
|
2009-09-15 13:03:13 +03:00
|
|
|
createDirectoryActions(context);
|
2011-02-28 17:28:41 +01:00
|
|
|
createSeparator(context, Core::Id("Mercurial.DirRepoSeperator"));
|
2009-09-15 13:03:13 +03:00
|
|
|
createRepositoryActions(context);
|
2011-02-28 17:28:41 +01:00
|
|
|
createSeparator(context, Core::Id("Mercurial.Repository Management"));
|
2009-09-15 13:03:13 +03:00
|
|
|
createRepositoryManagementActions(context);
|
2011-02-28 17:28:41 +01:00
|
|
|
createSeparator(context, Core::Id("Mercurial.LessUsedfunctionality"));
|
2009-09-15 13:03:13 +03:00
|
|
|
createLessUsedActions(context);
|
|
|
|
|
|
|
|
|
|
// Request the Tools menu and add the Mercurial menu to it
|
2010-09-10 14:13:19 +02:00
|
|
|
Core::ActionContainer *toolsMenu = actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
|
2009-09-15 13:03:13 +03:00
|
|
|
toolsMenu->addMenu(mercurialContainer);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_menuAction = mercurialContainer->menu()->menuAction();
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void MercurialPlugin::createFileActions(const Core::Context &context)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
Core::Command *command;
|
|
|
|
|
|
2010-01-11 15:22:17 +01:00
|
|
|
annotateFile = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(annotateFile, Core::Id(Constants::ANNOTATE), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
connect(annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-11 15:22:17 +01:00
|
|
|
diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(diffFile, Core::Id(Constants::DIFF), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2009-11-03 16:38:39 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+D")));
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-11 15:22:17 +01:00
|
|
|
logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(logFile, Core::Id(Constants::LOG), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2009-11-03 16:38:39 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+L")));
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-11 15:22:17 +01:00
|
|
|
statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(statusFile, Core::Id(Constants::STATUS), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2009-11-03 16:38:39 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+S")));
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 15:22:17 +01:00
|
|
|
|
2011-02-28 17:28:41 +01:00
|
|
|
createSeparator(context, Core::Id("Mercurial.FileDirSeperator1"));
|
2010-01-11 15:22:17 +01:00
|
|
|
|
|
|
|
|
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(m_addAction, Core::Id(Constants::ADD), context);
|
2010-01-11 15:22:17 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 15:22:17 +01:00
|
|
|
|
|
|
|
|
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(m_deleteAction, Core::Id(Constants::DELETE), context);
|
2010-01-11 15:22:17 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 15:22:17 +01:00
|
|
|
|
|
|
|
|
revertFile = new Utils::ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(revertFile, Core::Id(Constants::REVERT), context);
|
2010-01-11 15:22:17 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
|
connect(revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-11 15:22:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::addCurrentFile()
|
|
|
|
|
{
|
|
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
2011-02-28 13:40:04 +01:00
|
|
|
m_client->synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::annotateCurrentFile()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->annotate(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::diffCurrentFile()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::logCurrentFile()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
2011-05-03 14:44:38 +02:00
|
|
|
m_client->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
|
2011-05-12 14:48:10 +02:00
|
|
|
QStringList(), true);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::revertCurrentFile()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
RevertDialog reverter;
|
|
|
|
|
if (reverter.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->revertFile(state.currentFileTopLevel(), state.relativeCurrentFile(), reverter.revision());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::statusCurrentFile()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasFile(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->status(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void MercurialPlugin::createDirectoryActions(const Core::Context &context)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
QAction *action;
|
|
|
|
|
Core::Command *command;
|
|
|
|
|
|
|
|
|
|
action = new QAction(tr("Diff"), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::DIFFMULTI), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(diffRepository()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
action = new QAction(tr("Log"), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::LOGMULTI), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(logRepository()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Revert..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::REVERTMULTI), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(revertMulti()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
action = new QAction(tr("Status"), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::STATUSMULTI), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(statusMulti()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
void MercurialPlugin::diffRepository()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->diff(state.topLevel());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::logRepository()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->log(state.topLevel());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::revertMulti()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
RevertDialog reverter;
|
|
|
|
|
if (reverter.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2011-02-28 13:40:04 +01:00
|
|
|
m_client->revertAll(state.topLevel(), reverter.revision());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::statusMulti()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->status(state.topLevel());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void MercurialPlugin::createRepositoryActions(const Core::Context &context)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-05 12:45:02 +01:00
|
|
|
QAction *action = new QAction(tr("Pull..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
Core::Command *command = actionManager->registerAction(action, Core::Id(Constants::PULL), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(pull()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Push..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::PUSH), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(push()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Update..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::UPDATE), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(update()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Import..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::IMPORT), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(import()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Incoming..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::INCOMING), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(incoming()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Outgoing..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::OUTGOING), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(outgoing()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-11-05 12:45:02 +01:00
|
|
|
action = new QAction(tr("Commit..."), this);
|
2009-12-08 14:28:00 +01:00
|
|
|
m_repositoryActionList.append(action);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(action, Core::Id(Constants::COMMIT), context);
|
2009-11-03 16:38:39 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+C")));
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(commit()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2010-02-12 16:03:08 +01:00
|
|
|
m_commandLocator->appendCommand(command);
|
2010-01-12 16:45:21 +01:00
|
|
|
|
|
|
|
|
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(m_createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context);
|
2010-01-12 16:45:21 +01:00
|
|
|
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
|
|
|
|
|
mercurialContainer->addAction(command);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::pull()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
SrcDestDialog dialog;
|
2009-11-03 16:38:39 +01:00
|
|
|
dialog.setWindowTitle(tr("Pull Source"));
|
2009-09-15 13:03:13 +03:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2011-02-28 13:40:04 +01:00
|
|
|
m_client->synchronousPull(state.topLevel(), dialog.getRepositoryString());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::push()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
SrcDestDialog dialog;
|
2009-11-03 16:38:39 +01:00
|
|
|
dialog.setWindowTitle(tr("Push Destination"));
|
2009-09-15 13:03:13 +03:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2011-02-28 13:40:04 +01:00
|
|
|
m_client->synchronousPush(state.topLevel(), dialog.getRepositoryString());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::update()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
RevertDialog updateDialog;
|
2009-11-03 16:38:39 +01:00
|
|
|
updateDialog.setWindowTitle(tr("Update"));
|
2009-09-15 13:03:13 +03:00
|
|
|
if (updateDialog.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->update(state.topLevel(), updateDialog.revision());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::import()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
QFileDialog importDialog;
|
|
|
|
|
importDialog.setFileMode(QFileDialog::ExistingFiles);
|
|
|
|
|
importDialog.setViewMode(QFileDialog::Detail);
|
|
|
|
|
|
|
|
|
|
if (importDialog.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QStringList fileNames = importDialog.selectedFiles();
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->import(state.topLevel(), fileNames);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::incoming()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
SrcDestDialog dialog;
|
2009-11-03 16:38:39 +01:00
|
|
|
dialog.setWindowTitle(tr("Incoming Source"));
|
2009-09-15 13:03:13 +03:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->incoming(state.topLevel(), dialog.getRepositoryString());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::outgoing()
|
|
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->outgoing(state.topLevel());
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::createSubmitEditorActions()
|
|
|
|
|
{
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context context(Constants::COMMIT_ID);
|
2009-09-15 13:03:13 +03:00
|
|
|
Core::Command *command;
|
|
|
|
|
|
|
|
|
|
editorCommit = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Commit"), this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(editorCommit, Core::Id(Constants::COMMIT), context);
|
2010-08-19 10:04:21 +02:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2009-09-15 13:03:13 +03:00
|
|
|
connect(editorCommit, SIGNAL(triggered()), this, SLOT(commitFromEditor()));
|
|
|
|
|
|
2011-05-03 14:58:43 +02:00
|
|
|
editorDiff = new QAction(VCSBase::VCSBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(editorDiff, Core::Id(Constants::DIFFEDITOR), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
editorUndo = new QAction(tr("&Undo"), this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(editorUndo, Core::Id(Core::Constants::UNDO), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
editorRedo = new QAction(tr("&Redo"), this);
|
2010-09-10 14:13:19 +02:00
|
|
|
command = actionManager->registerAction(editorRedo, Core::Id(Core::Constants::REDO), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::commit()
|
|
|
|
|
{
|
|
|
|
|
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
|
|
|
|
|
return;
|
|
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
const VCSBase::VCSBasePluginState state = currentState();
|
|
|
|
|
QTC_ASSERT(state.hasTopLevel(), return)
|
|
|
|
|
|
|
|
|
|
m_submitRepository = state.topLevel();
|
|
|
|
|
|
2011-08-22 15:33:03 +00:00
|
|
|
connect(m_client, SIGNAL(parsedStatus(QList<VCSBase::VCSBaseClient::StatusItem>)),
|
|
|
|
|
this, SLOT(showCommitWidget(QList<VCSBase::VCSBaseClient::StatusItem>)));
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->statusWithSignal(m_submitRepository);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2011-08-22 15:33:03 +00:00
|
|
|
void MercurialPlugin::showCommitWidget(const QList<VCSBase::VCSBaseClient::StatusItem> &status)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-03 14:21:48 +01:00
|
|
|
|
|
|
|
|
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
|
2009-09-15 13:03:13 +03:00
|
|
|
//Once we receive our data release the connection so it can be reused elsewhere
|
2011-08-22 15:33:03 +00:00
|
|
|
disconnect(m_client, SIGNAL(parsedStatus(QList<VCSBase::VCSBaseClient::StatusItem>)),
|
|
|
|
|
this, SLOT(showCommitWidget(QList<VCSBase::VCSBaseClient::StatusItem>)));
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
if (status.isEmpty()) {
|
2009-11-03 14:21:48 +01:00
|
|
|
outputWindow->appendError(tr("There are no changes to commit."));
|
2009-09-15 13:03:13 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteCommitLog();
|
|
|
|
|
|
2010-08-19 16:26:47 +02:00
|
|
|
// Open commit log
|
|
|
|
|
QString changeLogPattern = QDir::tempPath();
|
|
|
|
|
if (!changeLogPattern.endsWith(QLatin1Char('/')))
|
|
|
|
|
changeLogPattern += QLatin1Char('/');
|
|
|
|
|
changeLogPattern += QLatin1String("qtcreator-hg-XXXXXX.msg");
|
|
|
|
|
changeLog = new QTemporaryFile(changeLogPattern, this);
|
2009-09-15 13:03:13 +03:00
|
|
|
if (!changeLog->open()) {
|
2009-11-03 14:21:48 +01:00
|
|
|
outputWindow->appendError(tr("Unable to generate a temporary file for the commit editor."));
|
2009-09-15 13:03:13 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::IEditor *editor = core->editorManager()->openEditor(changeLog->fileName(),
|
2010-09-14 15:15:57 +02:00
|
|
|
QLatin1String(Constants::COMMIT_ID),
|
|
|
|
|
Core::EditorManager::ModeSwitch);
|
2009-09-15 13:03:13 +03:00
|
|
|
if (!editor) {
|
2009-11-03 14:21:48 +01:00
|
|
|
outputWindow->appendError(tr("Unable to create an editor for the commit."));
|
2009-09-15 13:03:13 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-11 14:13:36 +01:00
|
|
|
QTC_ASSERT(qobject_cast<CommitEditor *>(editor), return)
|
|
|
|
|
CommitEditor *commitEditor = static_cast<CommitEditor *>(editor);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
2010-07-05 09:52:32 +02:00
|
|
|
const QString msg = tr("Commit changes for \"%1\".").
|
|
|
|
|
arg(QDir::toNativeSeparators(m_submitRepository));
|
2009-11-03 14:21:48 +01:00
|
|
|
commitEditor->setDisplayName(msg);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2010-01-08 09:44:07 +01:00
|
|
|
QString branch = m_client->branchQuerySync(m_submitRepository);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
commitEditor->setFields(m_submitRepository, branch, mercurialSettings.userName(),
|
2009-11-06 12:32:38 +01:00
|
|
|
mercurialSettings.email(), status);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
|
2009-12-08 14:28:00 +01:00
|
|
|
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
|
|
|
|
this, SLOT(diffFromEditorSelected(QStringList)));
|
2009-12-14 10:56:50 +01:00
|
|
|
commitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::diffFromEditorSelected(const QStringList &files)
|
|
|
|
|
{
|
2010-01-08 09:44:07 +01:00
|
|
|
m_client->diff(m_submitRepository, files);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::commitFromEditor()
|
|
|
|
|
{
|
|
|
|
|
if (!changeLog)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//use the same functionality than if the user closes the file without completing the commit
|
|
|
|
|
core->editorManager()->closeEditors(core->editorManager()->editorsForFileName(changeLog->fileName()));
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
bool MercurialPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-12-08 14:28:00 +01:00
|
|
|
if (!changeLog)
|
2009-09-15 13:03:13 +03:00
|
|
|
return true;
|
2009-12-08 14:28:00 +01:00
|
|
|
Core::IFile *editorFile = submitEditor->file();
|
|
|
|
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor);
|
2009-09-15 13:03:13 +03:00
|
|
|
if (!editorFile || !commitEditor)
|
|
|
|
|
return true;
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
bool dummyPrompt = mercurialSettings.prompt();
|
2009-09-15 13:03:13 +03:00
|
|
|
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult response =
|
2010-09-21 17:17:54 +02:00
|
|
|
commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
|
2009-09-15 13:03:13 +03:00
|
|
|
tr("Message check failed. Do you want to proceed?"),
|
2009-11-06 12:32:38 +01:00
|
|
|
&dummyPrompt, mercurialSettings.prompt());
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
switch (response) {
|
|
|
|
|
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
|
|
|
|
return false;
|
|
|
|
|
case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded:
|
|
|
|
|
deleteCommitLog();
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QStringList files = commitEditor->checkedFiles();
|
|
|
|
|
if (!files.empty()) {
|
|
|
|
|
//save the commit message
|
2011-03-30 12:43:17 +02:00
|
|
|
if (!core->fileManager()->saveFile(editorFile))
|
|
|
|
|
return false;
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2011-05-12 14:48:10 +02:00
|
|
|
QStringList extraOptions;
|
|
|
|
|
if (!commitEditor->committerInfo().isEmpty())
|
|
|
|
|
extraOptions << QLatin1String("-u") << commitEditor->committerInfo();
|
2011-02-28 13:40:04 +01:00
|
|
|
m_client->commit(m_submitRepository, files, editorFile->fileName(),
|
|
|
|
|
extraOptions);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
void MercurialPlugin::deleteCommitLog()
|
|
|
|
|
{
|
|
|
|
|
if (changeLog) {
|
|
|
|
|
delete changeLog;
|
|
|
|
|
changeLog = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void MercurialPlugin::createRepositoryManagementActions(const Core::Context &context)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//TODO create menu for these options
|
|
|
|
|
Q_UNUSED(context);
|
|
|
|
|
return;
|
|
|
|
|
// QAction *action = new QAction(tr("Branch"), this);
|
|
|
|
|
// actionList.append(action);
|
|
|
|
|
// Core::Command *command = actionManager->registerAction(action, Constants::BRANCH, context);
|
|
|
|
|
// // connect(action, SIGNAL(triggered()), this, SLOT(branch()));
|
|
|
|
|
// mercurialContainer->addAction(command);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
void MercurialPlugin::createLessUsedActions(const Core::Context &context)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//TODO create menue for these options
|
|
|
|
|
Q_UNUSED(context);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-10 14:13:19 +02:00
|
|
|
void MercurialPlugin::createSeparator(const Core::Context &context, const Core::Id &id)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
QAction *action = new QAction(this);
|
|
|
|
|
action->setSeparator(true);
|
|
|
|
|
mercurialContainer->addAction(actionManager->registerAction(action, id, context));
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
void MercurialPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2010-02-15 13:55:11 +01:00
|
|
|
if (!enableMenuAction(as, m_menuAction)) {
|
|
|
|
|
m_commandLocator->setEnabled(false);
|
2009-12-08 14:28:00 +01:00
|
|
|
return;
|
2010-02-15 13:55:11 +01:00
|
|
|
}
|
2009-12-08 14:28:00 +01:00
|
|
|
const QString filename = currentState().currentFileName();
|
|
|
|
|
const bool repoEnabled = currentState().hasTopLevel();
|
2010-02-15 13:55:11 +01:00
|
|
|
m_commandLocator->setEnabled(repoEnabled);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
annotateFile->setParameter(filename);
|
|
|
|
|
diffFile->setParameter(filename);
|
|
|
|
|
logFile->setParameter(filename);
|
2010-01-11 15:22:17 +01:00
|
|
|
m_addAction->setParameter(filename);
|
|
|
|
|
m_deleteAction->setParameter(filename);
|
2009-09-15 13:03:13 +03:00
|
|
|
revertFile->setParameter(filename);
|
|
|
|
|
statusFile->setParameter(filename);
|
|
|
|
|
|
2009-12-08 14:28:00 +01:00
|
|
|
foreach (QAction *repoAction, m_repositoryActionList)
|
|
|
|
|
repoAction->setEnabled(repoEnabled);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(MercurialPlugin)
|