2009-11-02 18:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (c) 2013 Brian McGillion
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-11-02 18:50:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-11-02 18:50:06 +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
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-11-02 18:50:06 +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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
****************************************************************************/
|
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>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.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>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2009-09-15 13:03:13 +03:00
|
|
|
#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
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QMenu>
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
#include <QFileDialog>
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
using namespace Mercurial::Internal;
|
|
|
|
|
using namespace Mercurial;
|
2012-01-07 14:32:59 +01:00
|
|
|
using namespace VcsBase;
|
|
|
|
|
using namespace Utils;
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
static const VcsBaseEditorParameters editorParameters[] = {
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
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
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
{ 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},
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
{ AnnotateOutput,
|
|
|
|
|
Constants::ANNOTATELOG_ID,
|
|
|
|
|
Constants::ANNOTATELOG_DISPLAY_NAME,
|
|
|
|
|
Constants::ANNOTATELOG,
|
|
|
|
|
Constants::ANNOTATEAPP,
|
|
|
|
|
Constants::ANNOTATEEXT},
|
2009-09-15 13:03:13 +03:00
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
{ 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}
|
|
|
|
|
};
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
static const VcsBaseSubmitEditorParameters submitEditorParameters = {
|
2009-09-15 13:03:13 +03:00
|
|
|
Constants::COMMITMIMETYPE,
|
2010-01-08 09:48:54 +01:00
|
|
|
Constants::COMMIT_ID,
|
|
|
|
|
Constants::COMMIT_DISPLAY_NAME,
|
2013-01-11 10:45:00 +02:00
|
|
|
Constants::COMMIT_ID,
|
|
|
|
|
VcsBase::VcsBaseSubmitEditorParameters::DiffFiles
|
2009-09-15 13:03:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MercurialPlugin *MercurialPlugin::m_instance = 0;
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
MercurialPlugin::MercurialPlugin() :
|
2012-01-07 14:32:59 +01:00
|
|
|
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),
|
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),
|
2012-09-26 15:18:44 +02:00
|
|
|
m_menuAction(0),
|
|
|
|
|
m_submitActionTriggered(false)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-21 13:05:15 +02:00
|
|
|
bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * /*errorMessage */)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
typedef VcsEditorFactory<MercurialEditor> MercurialEditorFactory;
|
2009-09-15 13:03:13 +03:00
|
|
|
|
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
|
|
|
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(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));
|
2012-01-07 14:32:59 +01:00
|
|
|
const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]);
|
2009-09-15 13:03:13 +03:00
|
|
|
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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
addAutoReleasedObject(new VcsSubmitEditorFactory<CommitEditor>(&submitEditorParameters));
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
addAutoReleasedObject(new CloneWizard);
|
|
|
|
|
|
2010-02-12 16:03:08 +01:00
|
|
|
const QString prefix = QLatin1String("hg");
|
2013-01-18 11:35:38 +01:00
|
|
|
m_commandLocator = new Locator::CommandLocator("Mercurial", prefix, prefix);
|
2010-02-12 16:03:08 +01:00
|
|
|
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-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
|
2012-05-24 13:49:06 +02:00
|
|
|
mercurialContainer = Core::ActionManager::createMenu(Core::Id("Mercurial.MercurialMenu"));
|
2009-09-15 13:03:13 +03:00
|
|
|
QMenu *menu = mercurialContainer->menu();
|
|
|
|
|
menu->setTitle(tr("Mercurial"));
|
|
|
|
|
|
|
|
|
|
createFileActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
mercurialContainer->addSeparator(context);
|
2009-09-15 13:03:13 +03:00
|
|
|
createDirectoryActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
mercurialContainer->addSeparator(context);
|
2009-09-15 13:03:13 +03:00
|
|
|
createRepositoryActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
mercurialContainer->addSeparator(context);
|
2009-09-15 13:03:13 +03:00
|
|
|
createRepositoryManagementActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
mercurialContainer->addSeparator(context);
|
2009-09-15 13:03:13 +03:00
|
|
|
createLessUsedActions(context);
|
|
|
|
|
|
|
|
|
|
// Request the Tools menu and add the Mercurial menu to it
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionContainer *toolsMenu = Core::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;
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
annotateFile = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(diffFile, Core::Id(Constants::DIFF), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+D") : 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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(logFile, Core::Id(Constants::LOG), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+L") : 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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(statusFile, Core::Id(Constants::STATUS), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+S") : 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
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
mercurialContainer->addSeparator(context);
|
2010-01-11 15:22:17 +01:00
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
revertFile = new ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::diffRepository()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::Command *command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(action, Core::Id(Constants::COMMIT), context);
|
2012-05-23 13:25:51 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+C") : 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);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
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()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
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;
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
editorCommit = new QAction(VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::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()));
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
editorDiff = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(editorDiff, Core::Id(Constants::DIFFEDITOR), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
editorUndo = new QAction(tr("&Undo"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(editorUndo, Core::Id(Core::Constants::UNDO), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
editorRedo = new QAction(tr("&Redo"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
command = Core::ActionManager::registerAction(editorRedo, Core::Id(Core::Constants::REDO), context);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::commit()
|
|
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
if (VcsBaseSubmitEditor::raiseSubmitEditor())
|
2009-09-15 13:03:13 +03:00
|
|
|
return;
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
const VcsBasePluginState state = currentState();
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
|
|
|
|
m_submitRepository = state.topLevel();
|
|
|
|
|
|
2012-06-07 10:39:35 +02:00
|
|
|
connect(m_client, SIGNAL(parsedStatus(QList<VcsBase::VcsBaseClient::StatusItem>)),
|
|
|
|
|
this, SLOT(showCommitWidget(QList<VcsBase::VcsBaseClient::StatusItem>)));
|
2011-08-22 15:33:03 +00:00
|
|
|
m_client->emitParsedStatus(m_submitRepository);
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
void MercurialPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &status)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2012-01-07 14:32:59 +01:00
|
|
|
VcsBaseOutputWindow *outputWindow = VcsBaseOutputWindow::instance();
|
2009-09-15 13:03:13 +03:00
|
|
|
//Once we receive our data release the connection so it can be reused elsewhere
|
2012-06-07 10:39:35 +02: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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-26 15:18:44 +02:00
|
|
|
// Start new temp file
|
|
|
|
|
Utils::TempFileSaver saver;
|
|
|
|
|
// Keep the file alive, else it removes self and forgets its name
|
|
|
|
|
saver.setAutoRemove(false);
|
|
|
|
|
if (!saver.finalize()) {
|
|
|
|
|
VcsBase::VcsBaseOutputWindow::instance()->append(saver.errorString());
|
2009-09-15 13:03:13 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-26 15:18:44 +02:00
|
|
|
Core::IEditor *editor = Core::EditorManager::openEditor(saver.fileName(),
|
2012-05-08 09:43:14 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(qobject_cast<CommitEditor *>(editor), return);
|
2011-03-11 14:13:36 +01:00
|
|
|
CommitEditor *commitEditor = static_cast<CommitEditor *>(editor);
|
2009-12-08 14:28:00 +01:00
|
|
|
|
2011-11-22 15:11:58 +01:00
|
|
|
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
|
|
|
|
|
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
|
|
|
|
this, SLOT(diffFromEditorSelected(QStringList)));
|
|
|
|
|
commitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
|
|
|
|
|
|
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);
|
2011-09-14 09:13:44 +00:00
|
|
|
commitEditor->setFields(m_submitRepository, branch,
|
|
|
|
|
mercurialSettings.stringValue(MercurialSettings::userNameKey),
|
|
|
|
|
mercurialSettings.stringValue(MercurialSettings::userEmailKey), status);
|
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()
|
|
|
|
|
{
|
2012-09-26 15:18:44 +02:00
|
|
|
// Close the submit editor
|
|
|
|
|
m_submitActionTriggered = true;
|
|
|
|
|
Core::ICore::editorManager()->closeEditor();
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
bool MercurialPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2012-02-14 16:43:51 +01:00
|
|
|
Core::IDocument *editorFile = submitEditor->document();
|
2009-12-08 14:28:00 +01:00
|
|
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor);
|
2009-09-15 13:03:13 +03:00
|
|
|
if (!editorFile || !commitEditor)
|
|
|
|
|
return true;
|
|
|
|
|
|
2011-09-14 09:13:44 +00:00
|
|
|
bool dummyPrompt = mercurialSettings.boolValue(MercurialSettings::promptOnSubmitKey);
|
2012-01-07 14:32:59 +01:00
|
|
|
const 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?"),
|
2012-09-26 15:18:44 +02:00
|
|
|
&dummyPrompt, !m_submitActionTriggered);
|
|
|
|
|
m_submitActionTriggered = false;
|
2009-09-15 13:03:13 +03:00
|
|
|
|
|
|
|
|
switch (response) {
|
2012-01-07 14:32:59 +01:00
|
|
|
case VcsBaseSubmitEditor::SubmitCanceled:
|
2009-09-15 13:03:13 +03:00
|
|
|
return false;
|
2012-01-07 14:32:59 +01:00
|
|
|
case VcsBaseSubmitEditor::SubmitDiscarded:
|
2009-09-15 13:03:13 +03:00
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QStringList files = commitEditor->checkedFiles();
|
|
|
|
|
if (!files.empty()) {
|
|
|
|
|
//save the commit message
|
2012-02-14 16:43:51 +01:00
|
|
|
if (!Core::DocumentManager::saveDocument(editorFile))
|
2011-03-30 12:43:17 +02:00
|
|
|
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
|
|
|
|
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);
|
2012-05-24 13:49:06 +02:00
|
|
|
// Core::Command *command = Core::ActionManager::registerAction(action, Constants::BRANCH, context);
|
2009-09-15 13:03:13 +03:00
|
|
|
// // 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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 14:32:59 +01:00
|
|
|
void MercurialPlugin::updateActions(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
|
|
|
}
|
|
|
|
|
|
2013-01-21 22:56:01 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
#include <QTest>
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::testDiffFileResolving_data()
|
|
|
|
|
{
|
|
|
|
|
QTest::addColumn<QByteArray>("header");
|
|
|
|
|
QTest::addColumn<QByteArray>("fileName");
|
|
|
|
|
|
|
|
|
|
QTest::newRow("New") << QByteArray(
|
|
|
|
|
"diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"new file mode 100644\n"
|
|
|
|
|
"--- /dev/null\n"
|
|
|
|
|
"+++ b/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"@@ -0,0 +1,112 @@\n\n")
|
|
|
|
|
<< QByteArray("src/plugins/mercurial/mercurialeditor.cpp");
|
|
|
|
|
QTest::newRow("Deleted") << QByteArray(
|
|
|
|
|
"diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"deleted file mode 100644\n"
|
|
|
|
|
"--- a/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"+++ /dev/null\n"
|
|
|
|
|
"@@ -1,112 +0,0 @@\n\n")
|
|
|
|
|
<< QByteArray("src/plugins/mercurial/mercurialeditor.cpp");
|
|
|
|
|
QTest::newRow("Normal") << QByteArray(
|
|
|
|
|
"diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"--- a/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"+++ b/src/plugins/mercurial/mercurialeditor.cpp\n"
|
|
|
|
|
"@@ -49,6 +49,8 @@\n\n")
|
|
|
|
|
<< QByteArray("src/plugins/mercurial/mercurialeditor.cpp");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialPlugin::testDiffFileResolving()
|
|
|
|
|
{
|
|
|
|
|
MercurialEditor editor(editorParameters + 3, 0);
|
2013-01-28 20:50:05 +02:00
|
|
|
editor.testDiffFileResolving();
|
2013-01-21 22:56:01 +02:00
|
|
|
}
|
2013-01-28 22:02:35 +02:00
|
|
|
|
|
|
|
|
void MercurialPlugin::testLogResolving()
|
|
|
|
|
{
|
|
|
|
|
QByteArray data(
|
|
|
|
|
"changeset: 18473:692cbda1eb50\n"
|
|
|
|
|
"branch: stable\n"
|
|
|
|
|
"bookmark: @\n"
|
|
|
|
|
"tag: tip\n"
|
|
|
|
|
"user: FUJIWARA Katsunori <foozy@lares.dti.ne.jp>\n"
|
|
|
|
|
"date: Wed Jan 23 22:52:55 2013 +0900\n"
|
|
|
|
|
"summary: revset: evaluate sub expressions correctly (issue3775)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"changeset: 18472:37100f30590f\n"
|
|
|
|
|
"branch: stable\n"
|
|
|
|
|
"user: Pierre-Yves David <pierre-yves.david@ens-lyon.org>\n"
|
|
|
|
|
"date: Sat Jan 19 04:08:16 2013 +0100\n"
|
|
|
|
|
"summary: test-rebase: add another test for rebase with multiple roots\n"
|
|
|
|
|
);
|
|
|
|
|
MercurialEditor editor(editorParameters + 1, 0);
|
|
|
|
|
editor.testLogResolving(data, "18473:692cbda1eb50", "18472:37100f30590f");
|
|
|
|
|
}
|
2013-01-21 22:56:01 +02:00
|
|
|
#endif
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
Q_EXPORT_PLUGIN(MercurialPlugin)
|