2011-02-28 13:40:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (c) 2014 Hugues Delorme
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-02-28 13:40:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-28 13:40: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
|
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.
|
2011-02-28 13:40: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
|
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
|
2011-02-28 13:40:06 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2014-07-19 16:04:46 +02:00
|
|
|
|
2011-02-28 13:40:06 +01:00
|
|
|
#include "bazaarplugin.h"
|
|
|
|
#include "constants.h"
|
|
|
|
#include "bazaarclient.h"
|
|
|
|
#include "bazaarcontrol.h"
|
|
|
|
#include "optionspage.h"
|
|
|
|
#include "bazaarcommitwidget.h"
|
|
|
|
#include "bazaareditor.h"
|
|
|
|
#include "pullorpushdialog.h"
|
2013-12-06 14:56:24 +01:00
|
|
|
#include "uncommitdialog.h"
|
2011-02-28 13:40:06 +01:00
|
|
|
#include "commiteditor.h"
|
|
|
|
#include "clonewizard.h"
|
|
|
|
|
|
|
|
#include "ui_revertdialog.h"
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2011-09-05 16:10:37 +02:00
|
|
|
#include <coreplugin/id.h>
|
2011-02-28 13:40:06 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
#include <coreplugin/icore.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2011-02-28 13:40:06 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2014-01-13 16:17:34 +01:00
|
|
|
#include <coreplugin/locator/commandlocator.h>
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
#include <utils/parameteraction.h>
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
#include <vcsbase/basevcseditorfactory.h>
|
|
|
|
#include <vcsbase/basevcssubmiteditorfactory.h>
|
|
|
|
#include <vcsbase/vcsbasesubmiteditor.h>
|
2014-07-28 18:46:34 +02:00
|
|
|
#include <vcsbase/vcsbaseconstants.h>
|
2011-02-28 13:40:06 +01:00
|
|
|
#include <vcsbase/vcsbaseeditor.h>
|
2014-08-26 00:02:47 +02:00
|
|
|
#include <vcsbase/vcsoutputwindow.h>
|
2011-02-28 13:40:06 +01: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 <QDir>
|
|
|
|
#include <QDialog>
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
#include <QTest>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
using namespace Utils;
|
|
|
|
using namespace VcsBase;
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
namespace Bazaar {
|
|
|
|
namespace Internal {
|
|
|
|
|
2014-07-28 17:47:15 +02:00
|
|
|
// Submit editor parameters
|
|
|
|
const char COMMIT_ID[] = "Bazaar Commit Log Editor";
|
|
|
|
const char COMMIT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Commit Log Editor");
|
|
|
|
const char COMMITMIMETYPE[] = "text/vnd.qtcreator.bazaar.commit";
|
|
|
|
|
|
|
|
// Menu items
|
|
|
|
// File menu actions
|
|
|
|
const char ADD[] = "Bazaar.AddSingleFile";
|
|
|
|
const char DELETE[] = "Bazaar.DeleteSingleFile";
|
|
|
|
const char ANNOTATE[] = "Bazaar.Annotate";
|
|
|
|
const char DIFF[] = "Bazaar.DiffSingleFile";
|
|
|
|
const char LOG[] = "Bazaar.LogSingleFile";
|
|
|
|
const char REVERT[] = "Bazaar.RevertSingleFile";
|
|
|
|
const char STATUS[] = "Bazaar.Status";
|
|
|
|
|
|
|
|
// Directory menu Actions
|
|
|
|
const char DIFFMULTI[] = "Bazaar.Action.DiffMulti";
|
|
|
|
const char REVERTMULTI[] = "Bazaar.Action.RevertALL";
|
|
|
|
const char STATUSMULTI[] = "Bazaar.Action.StatusMulti";
|
|
|
|
const char LOGMULTI[] = "Bazaar.Action.Logmulti";
|
|
|
|
|
|
|
|
// Repository menu actions
|
|
|
|
const char PULL[] = "Bazaar.Action.Pull";
|
|
|
|
const char PUSH[] = "Bazaar.Action.Push";
|
|
|
|
const char UPDATE[] = "Bazaar.Action.Update";
|
|
|
|
const char COMMIT[] = "Bazaar.Action.Commit";
|
|
|
|
const char UNCOMMIT[] = "Bazaar.Action.UnCommit";
|
|
|
|
const char CREATE_REPOSITORY[] = "Bazaar.Action.CreateRepository";
|
|
|
|
|
|
|
|
// Submit editor actions
|
|
|
|
const char DIFFEDITOR[] = "Bazaar.Action.Editor.Diff";
|
|
|
|
|
|
|
|
const VcsBaseEditorParameters editorParameters[] = {
|
2014-07-19 16:04:46 +02:00
|
|
|
{ LogOutput, // type
|
2013-05-22 21:03:37 +03:00
|
|
|
Constants::FILELOG_ID, // id
|
|
|
|
Constants::FILELOG_DISPLAY_NAME, // display name
|
|
|
|
Constants::LOGAPP}, // mime type
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
{ AnnotateOutput,
|
2011-02-28 13:40:06 +01:00
|
|
|
Constants::ANNOTATELOG_ID,
|
|
|
|
Constants::ANNOTATELOG_DISPLAY_NAME,
|
2013-05-21 20:54:26 +03:00
|
|
|
Constants::ANNOTATEAPP},
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
{ DiffOutput,
|
2011-02-28 13:40:06 +01:00
|
|
|
Constants::DIFFLOG_ID,
|
|
|
|
Constants::DIFFLOG_DISPLAY_NAME,
|
2013-05-21 20:54:26 +03:00
|
|
|
Constants::DIFFAPP}
|
2011-02-28 13:40:06 +01:00
|
|
|
};
|
|
|
|
|
2014-07-28 17:47:15 +02:00
|
|
|
const VcsBaseSubmitEditorParameters submitEditorParameters = {
|
|
|
|
COMMITMIMETYPE,
|
|
|
|
COMMIT_ID,
|
|
|
|
COMMIT_DISPLAY_NAME,
|
2014-07-19 16:04:46 +02:00
|
|
|
VcsBaseSubmitEditorParameters::DiffFiles
|
2011-02-28 13:40:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
BazaarPlugin *BazaarPlugin::m_instance = 0;
|
|
|
|
|
2011-11-10 16:06:19 +01:00
|
|
|
BazaarPlugin::BazaarPlugin()
|
2014-08-28 22:23:29 +02:00
|
|
|
: m_client(0),
|
2011-11-10 16:06:19 +01:00
|
|
|
m_commandLocator(0),
|
|
|
|
m_addAction(0),
|
|
|
|
m_deleteAction(0),
|
2012-09-26 15:18:44 +02:00
|
|
|
m_menuAction(0),
|
|
|
|
m_submitActionTriggered(false)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
m_instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
BazaarPlugin::~BazaarPlugin()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
delete m_client;
|
|
|
|
m_client = 0;
|
2011-02-28 13:40:06 +01:00
|
|
|
m_instance = 0;
|
|
|
|
}
|
|
|
|
|
2011-03-14 15:37:30 +01:00
|
|
|
bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
2011-03-14 15:37:30 +01:00
|
|
|
Q_UNUSED(arguments);
|
|
|
|
Q_UNUSED(errorMessage);
|
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
Context context(Constants::BAZAAR_CONTEXT);
|
|
|
|
|
2011-06-10 14:02:46 +00:00
|
|
|
m_client = new BazaarClient(&m_bazaarSettings);
|
2014-11-16 12:05:34 +02:00
|
|
|
initializeVcs(new BazaarControl(m_client), context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-08-28 22:23:29 +02:00
|
|
|
addAutoReleasedObject(new OptionsPage);
|
2014-07-19 16:04:46 +02:00
|
|
|
m_bazaarSettings.readSettings(ICore::settings());
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant)));
|
|
|
|
|
|
|
|
static const char *describeSlot = SLOT(view(QString,QString));
|
2014-07-19 16:04:46 +02:00
|
|
|
const int editorCount = sizeof(editorParameters) / sizeof(VcsBaseEditorParameters);
|
2014-08-21 20:43:33 +02:00
|
|
|
const auto widgetCreator = []() { return new BazaarEditorWidget; };
|
2011-02-28 13:40:06 +01:00
|
|
|
for (int i = 0; i < editorCount; i++)
|
2014-08-21 01:24:38 +02:00
|
|
|
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_client, describeSlot));
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-08-28 22:23:29 +02:00
|
|
|
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters,
|
|
|
|
[]() { return new CommitEditor(&submitEditorParameters); }));
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-28 18:46:34 +02:00
|
|
|
auto cloneWizardFactory = new BaseCheckoutWizardFactory;
|
|
|
|
cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR));
|
|
|
|
cloneWizardFactory->setIcon(QIcon(QLatin1String(":/bazaar/images/bazaar.png")));
|
|
|
|
cloneWizardFactory->setDescription(tr("Clones a Bazaar branch and tries to load the contained project."));
|
|
|
|
cloneWizardFactory->setDisplayName(tr("Bazaar Clone (Or Branch)"));
|
|
|
|
cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) {
|
|
|
|
return new CloneWizard(path, parent);
|
|
|
|
});
|
|
|
|
addAutoReleasedObject(cloneWizardFactory);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
const QString prefix = QLatin1String("bzr");
|
2014-07-19 16:04:46 +02:00
|
|
|
m_commandLocator = new CommandLocator("Bazaar", prefix, prefix);
|
2011-02-28 13:40:06 +01:00
|
|
|
addAutoReleasedObject(m_commandLocator);
|
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
createMenu(context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
createSubmitEditorActions();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
BazaarPlugin *BazaarPlugin::instance()
|
|
|
|
{
|
|
|
|
return m_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
BazaarClient *BazaarPlugin::client() const
|
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BazaarSettings &BazaarPlugin::settings() const
|
|
|
|
{
|
|
|
|
return m_bazaarSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::setSettings(const BazaarSettings &settings)
|
|
|
|
{
|
|
|
|
if (settings != m_bazaarSettings) {
|
2011-03-18 09:55:33 +01:00
|
|
|
const bool userIdChanged = !m_bazaarSettings.sameUserId(settings);
|
|
|
|
m_bazaarSettings = settings;
|
|
|
|
if (userIdChanged)
|
|
|
|
client()->synchronousSetUserId();
|
2011-04-15 17:43:44 +02:00
|
|
|
static_cast<BazaarControl *>(versionControl())->emitConfigurationChanged();
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-16 12:05:34 +02:00
|
|
|
void BazaarPlugin::createMenu(const Context &context)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
// Create menu item for Bazaar
|
2014-07-19 16:04:46 +02:00
|
|
|
m_bazaarContainer = ActionManager::createMenu("Bazaar.BazaarMenu");
|
2011-02-28 13:40:06 +01:00
|
|
|
QMenu *menu = m_bazaarContainer->menu();
|
|
|
|
menu->setTitle(tr("Bazaar"));
|
|
|
|
|
|
|
|
createFileActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
m_bazaarContainer->addSeparator(context);
|
2011-02-28 13:40:06 +01:00
|
|
|
createDirectoryActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
m_bazaarContainer->addSeparator(context);
|
2011-02-28 13:40:06 +01:00
|
|
|
createRepositoryActions(context);
|
2012-06-05 14:22:20 +02:00
|
|
|
m_bazaarContainer->addSeparator(context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
// Request the Tools menu and add the Bazaar menu to it
|
2014-07-19 16:04:46 +02:00
|
|
|
ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
2011-02-28 13:40:06 +01:00
|
|
|
toolsMenu->addMenu(m_bazaarContainer);
|
|
|
|
m_menuAction = m_bazaarContainer->menu()->menuAction();
|
|
|
|
}
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
void BazaarPlugin::createFileActions(const Context &context)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
Core::Command *command;
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_annotateFile = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_annotateFile, ANNOTATE, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_diffFile, DIFF, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-07-19 16:04:46 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+D") : tr("ALT+Z,Alt+D")));
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(m_diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_logFile, LOG, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-07-19 16:04:46 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+L") : tr("ALT+Z,Alt+L")));
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(m_logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_statusFile, STATUS, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
2014-07-19 16:04:46 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+S") : tr("ALT+Z,Alt+S")));
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(m_statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2012-06-05 14:22:20 +02:00
|
|
|
m_bazaarContainer->addSeparator(context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_addAction, ADD, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_deleteAction, DELETE, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_revertFile = new ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_revertFile, REVERT, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::addCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
|
|
|
m_client->synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::annotateCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
|
|
|
m_client->annotate(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::diffCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
|
|
|
m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::logCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01: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);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::revertCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
QDialog dialog(ICore::dialogParent());
|
2011-02-28 13:40:06 +01:00
|
|
|
Ui::RevertDialog revertUi;
|
|
|
|
revertUi.setupUi(&dialog);
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
m_client->revertFile(state.currentFileTopLevel(),
|
|
|
|
state.relativeCurrentFile(),
|
|
|
|
revertUi.revisionLineEdit->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::statusCurrentFile()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasFile(), return);
|
|
|
|
m_client->status(state.currentFileTopLevel(), state.relativeCurrentFile());
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
void BazaarPlugin::createDirectoryActions(const Context &context)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
QAction *action;
|
|
|
|
Core::Command *command;
|
|
|
|
|
|
|
|
action = new QAction(tr("Diff"), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, DIFFMULTI, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(diffRepository()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Log"), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, LOGMULTI, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(logRepository()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Revert..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, REVERTMULTI, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(revertAll()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Status"), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, STATUSMULTI, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(statusMulti()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BazaarPlugin::diffRepository()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
m_client->diff(state.topLevel());
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::logRepository()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 15:05:40 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
2011-05-12 16:37:20 +02:00
|
|
|
QStringList extraOptions;
|
2012-01-31 10:57:10 +01:00
|
|
|
extraOptions += QLatin1String("--limit=") + QString::number(settings().intValue(BazaarSettings::logCountKey));
|
2011-05-12 16:37:20 +02:00
|
|
|
m_client->log(state.topLevel(), QStringList(), extraOptions);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::revertAll()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
QDialog dialog(ICore::dialogParent());
|
2011-02-28 13:40:06 +01:00
|
|
|
Ui::RevertDialog revertUi;
|
|
|
|
revertUi.setupUi(&dialog);
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
m_client->revertAll(state.topLevel(), revertUi.revisionLineEdit->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::statusMulti()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
m_client->status(state.topLevel());
|
|
|
|
}
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
void BazaarPlugin::createRepositoryActions(const Context &context)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
QAction *action = 0;
|
|
|
|
Core::Command *command = 0;
|
|
|
|
|
|
|
|
action = new QAction(tr("Pull..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, PULL, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(pull()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Push..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, PUSH, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(push()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Update..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, UPDATE, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(update()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
|
|
|
action = new QAction(tr("Commit..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, COMMIT, context);
|
2014-07-19 16:04:46 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+C") : tr("ALT+Z,Alt+C")));
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(commit()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2013-12-06 14:56:24 +01:00
|
|
|
action = new QAction(tr("Uncommit..."), this);
|
|
|
|
m_repositoryActionList.append(action);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(action, UNCOMMIT, context);
|
2013-12-06 14:56:24 +01:00
|
|
|
connect(action, SIGNAL(triggered()), this, SLOT(uncommit()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
m_commandLocator->appendCommand(command);
|
|
|
|
|
2011-09-21 11:43:58 +02:00
|
|
|
QAction *createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(createRepositoryAction, CREATE_REPOSITORY, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
connect(createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
|
|
|
|
m_bazaarContainer->addAction(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::pull()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
PullOrPushDialog dialog(PullOrPushDialog::PullMode, ICore::dialogParent());
|
2011-02-28 13:40:06 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
2011-05-12 14:48:10 +02:00
|
|
|
QStringList extraOptions;
|
|
|
|
if (dialog.isRememberOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--remember");
|
|
|
|
if (dialog.isOverwriteOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--overwrite");
|
|
|
|
if (dialog.isLocalOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--local");
|
|
|
|
if (!dialog.revision().isEmpty())
|
|
|
|
extraOptions << QLatin1String("-r") << dialog.revision();
|
2011-02-28 13:40:06 +01:00
|
|
|
m_client->synchronousPull(state.topLevel(), dialog.branchLocation(), extraOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::push()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
PullOrPushDialog dialog(PullOrPushDialog::PushMode, ICore::dialogParent());
|
2011-02-28 13:40:06 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
2011-05-12 14:48:10 +02:00
|
|
|
QStringList extraOptions;
|
|
|
|
if (dialog.isRememberOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--remember");
|
|
|
|
if (dialog.isOverwriteOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--overwrite");
|
|
|
|
if (dialog.isUseExistingDirectoryOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--use-existing-dir");
|
|
|
|
if (dialog.isCreatePrefixOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--create-prefix");
|
|
|
|
if (!dialog.revision().isEmpty())
|
|
|
|
extraOptions << QLatin1String("-r") << dialog.revision();
|
2011-02-28 13:40:06 +01:00
|
|
|
m_client->synchronousPush(state.topLevel(), dialog.branchLocation(), extraOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::update()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
QDialog dialog(ICore::dialogParent());
|
2011-02-28 13:40:06 +01:00
|
|
|
Ui::RevertDialog revertUi;
|
|
|
|
revertUi.setupUi(&dialog);
|
|
|
|
dialog.setWindowTitle(tr("Update"));
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
m_client->update(state.topLevel(), revertUi.revisionLineEdit->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::createSubmitEditorActions()
|
|
|
|
{
|
2014-07-28 17:47:15 +02:00
|
|
|
Context context(COMMIT_ID);
|
2011-02-28 13:40:06 +01:00
|
|
|
Core::Command *command;
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_editorCommit = new QAction(VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_editorCommit, COMMIT, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
command->setAttribute(Core::Command::CA_UpdateText);
|
|
|
|
connect(m_editorCommit, SIGNAL(triggered()), this, SLOT(commitFromEditor()));
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
m_editorDiff = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
2014-07-28 17:47:15 +02:00
|
|
|
command = ActionManager::registerAction(m_editorDiff, DIFFEDITOR, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
m_editorUndo = new QAction(tr("&Undo"), this);
|
2014-07-19 16:04:46 +02:00
|
|
|
command = ActionManager::registerAction(m_editorUndo, Core::Constants::UNDO, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
m_editorRedo = new QAction(tr("&Redo"), this);
|
2014-07-19 16:04:46 +02:00
|
|
|
command = ActionManager::registerAction(m_editorRedo, Core::Constants::REDO, context);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::commit()
|
|
|
|
{
|
2013-04-18 12:06:43 +02:00
|
|
|
if (raiseSubmitEditor())
|
2011-02-28 13:40:06 +01:00
|
|
|
return;
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2011-02-28 13:40:06 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
|
|
|
m_submitRepository = state.topLevel();
|
|
|
|
|
2015-01-16 12:57:08 +01:00
|
|
|
QObject::connect(m_client, &VcsBaseClient::parsedStatus,
|
|
|
|
this, &BazaarPlugin::showCommitWidget);
|
2011-08-22 15:33:03 +00:00
|
|
|
// The "--short" option allows to easily parse status output
|
|
|
|
m_client->emitParsedStatus(m_submitRepository, QStringList(QLatin1String("--short")));
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
void BazaarPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &status)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
//Once we receive our data release the connection so it can be reused elsewhere
|
2015-01-16 12:57:08 +01:00
|
|
|
QObject::disconnect(m_client, &VcsBaseClient::parsedStatus,
|
|
|
|
this, &BazaarPlugin::showCommitWidget);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
if (status.isEmpty()) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendError(tr("There are no changes to commit."));
|
2011-02-28 13:40:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-26 15:18:44 +02:00
|
|
|
// Start new temp file
|
2014-07-19 16:04:46 +02:00
|
|
|
TempFileSaver saver;
|
2012-09-26 15:18:44 +02:00
|
|
|
// Keep the file alive, else it removes self and forgets its name
|
|
|
|
saver.setAutoRemove(false);
|
|
|
|
if (!saver.finalize()) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendError(saver.errorString());
|
2011-02-28 13:40:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-28 17:47:15 +02:00
|
|
|
IEditor *editor = EditorManager::openEditor(saver.fileName(), COMMIT_ID);
|
2011-02-28 13:40:06 +01:00
|
|
|
if (!editor) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
2011-02-28 13:40:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(editor);
|
|
|
|
|
|
|
|
if (!commitEditor) {
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::appendError(tr("Unable to create a commit editor."));
|
2011-02-28 13:40:06 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-04-18 12:06:43 +02:00
|
|
|
setSubmitEditor(commitEditor);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2011-11-22 15:11:58 +01:00
|
|
|
commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
|
|
|
|
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
|
|
|
|
this, SLOT(diffFromEditorSelected(QStringList)));
|
|
|
|
commitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
|
|
|
|
|
2011-02-28 13:40:06 +01:00
|
|
|
const QString msg = tr("Commit changes for \"%1\".").
|
|
|
|
arg(QDir::toNativeSeparators(m_submitRepository));
|
2013-07-04 22:25:15 +02:00
|
|
|
commitEditor->document()->setDisplayName(msg);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository);
|
2011-12-05 15:37:19 +01:00
|
|
|
commitEditor->setFields(m_submitRepository, branch,
|
|
|
|
m_bazaarSettings.stringValue(BazaarSettings::userNameKey),
|
2011-09-14 09:13:44 +00:00
|
|
|
m_bazaarSettings.stringValue(BazaarSettings::userEmailKey), status);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::diffFromEditorSelected(const QStringList &files)
|
|
|
|
{
|
|
|
|
m_client->diff(m_submitRepository, files);
|
|
|
|
}
|
|
|
|
|
2013-01-19 23:19:38 +02:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
|
|
|
void BazaarPlugin::testDiffFileResolving_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QByteArray>("header");
|
|
|
|
QTest::addColumn<QByteArray>("fileName");
|
|
|
|
|
|
|
|
QTest::newRow("New") << QByteArray(
|
|
|
|
"=== added file 'src/plugins/bazaar/bazaareditor.cpp'\n"
|
|
|
|
"--- src/plugins/bazaar/bazaareditor.cpp\t1970-01-01 00:00:00 +0000\n"
|
|
|
|
"+++ src/plugins/bazaar/bazaareditor.cpp\t2013-01-20 21:39:47 +0000\n"
|
|
|
|
"@@ -0,0 +1,121 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
|
|
|
|
QTest::newRow("Deleted") << QByteArray(
|
|
|
|
"=== removed file 'src/plugins/bazaar/bazaareditor.cpp'\n"
|
|
|
|
"--- src/plugins/bazaar/bazaareditor.cpp\t2013-01-20 21:39:47 +0000\n"
|
|
|
|
"+++ src/plugins/bazaar/bazaareditor.cpp\t1970-01-01 00:00:00 +0000\n"
|
|
|
|
"@@ -1,121 +0,0 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
|
|
|
|
QTest::newRow("Modified") << QByteArray(
|
|
|
|
"=== modified file 'src/plugins/bazaar/bazaareditor.cpp'\n"
|
|
|
|
"--- src/plugins/bazaar/bazaareditor.cpp\t2010-08-27 14:12:44 +0000\n"
|
|
|
|
"+++ src/plugins/bazaar/bazaareditor.cpp\t2011-02-28 21:24:19 +0000\n"
|
|
|
|
"@@ -727,6 +727,9 @@\n\n")
|
|
|
|
<< QByteArray("src/plugins/bazaar/bazaareditor.cpp");
|
|
|
|
}
|
|
|
|
|
|
|
|
void BazaarPlugin::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 BazaarPlugin::testLogResolving()
|
|
|
|
{
|
|
|
|
QByteArray data(
|
|
|
|
"------------------------------------------------------------\n"
|
|
|
|
"revno: 6572 [merge]\n"
|
|
|
|
"committer: Patch Queue Manager <pqm@pqm.ubuntu.com>\n"
|
|
|
|
"branch nick: +trunk\n"
|
|
|
|
"timestamp: Mon 2012-12-10 10:18:33 +0000\n"
|
|
|
|
"message:\n"
|
|
|
|
" (vila) Fix LC_ALL=C test failures related to utf8 stderr encoding (Vincent\n"
|
|
|
|
" Ladeuil)\n"
|
|
|
|
"------------------------------------------------------------\n"
|
|
|
|
"revno: 6571 [merge]\n"
|
|
|
|
"committer: Patch Queue Manager <pqm@pqm.ubuntu.com>\n"
|
|
|
|
"branch nick: +trunk\n"
|
|
|
|
"timestamp: Thu 2012-10-25 11:13:27 +0000\n"
|
|
|
|
"message:\n"
|
|
|
|
" (gz) Set approved revision and vote \"Approve\" when using lp-propose\n"
|
|
|
|
" --approve (Jonathan Lange)\n"
|
|
|
|
);
|
2014-08-28 13:45:42 +02:00
|
|
|
VcsBaseEditorWidget::testLogResolving(editorParameters[0].id, data, "6572", "6571");
|
2013-01-28 22:02:35 +02:00
|
|
|
}
|
2013-01-19 23:19:38 +02:00
|
|
|
#endif
|
|
|
|
|
2011-02-28 13:40:06 +01:00
|
|
|
void BazaarPlugin::commitFromEditor()
|
|
|
|
{
|
2012-09-26 15:18:44 +02:00
|
|
|
// Close the submit editor
|
|
|
|
m_submitActionTriggered = true;
|
2014-08-19 16:15:57 +02:00
|
|
|
QTC_ASSERT(submitEditor(), return);
|
|
|
|
EditorManager::closeDocument(submitEditor()->document());
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
|
2013-12-06 14:56:24 +01:00
|
|
|
void BazaarPlugin::uncommit()
|
|
|
|
{
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBasePluginState state = currentState();
|
2013-12-06 14:56:24 +01:00
|
|
|
QTC_ASSERT(state.hasTopLevel(), return);
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
UnCommitDialog dialog(ICore::dialogParent());
|
2013-12-06 14:56:24 +01:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
m_client->synchronousUncommit(state.topLevel(), dialog.revision(), dialog.extraOptions());
|
|
|
|
}
|
|
|
|
|
2013-04-18 12:06:43 +02:00
|
|
|
bool BazaarPlugin::submitEditorAboutToClose()
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
2013-04-18 12:06:43 +02:00
|
|
|
CommitEditor *commitEditor = qobject_cast<CommitEditor *>(submitEditor());
|
|
|
|
QTC_ASSERT(commitEditor, return true);
|
2014-07-19 16:04:46 +02:00
|
|
|
IDocument *editorDocument = commitEditor->document();
|
2013-04-18 12:06:43 +02:00
|
|
|
QTC_ASSERT(editorDocument, return true);
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2013-10-11 16:16:48 +03:00
|
|
|
bool dummyPrompt = false;
|
2014-07-19 16:04:46 +02:00
|
|
|
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
2011-02-28 13:40:06 +01:00
|
|
|
commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
|
|
|
|
tr("Message check failed. Do you want to proceed?"),
|
2012-09-26 15:18:44 +02:00
|
|
|
&dummyPrompt, !m_submitActionTriggered);
|
|
|
|
m_submitActionTriggered = false;
|
2011-02-28 13:40:06 +01:00
|
|
|
|
|
|
|
switch (response) {
|
2014-07-19 16:04:46 +02:00
|
|
|
case VcsBaseSubmitEditor::SubmitCanceled:
|
2011-02-28 13:40:06 +01:00
|
|
|
return false;
|
2014-07-19 16:04:46 +02:00
|
|
|
case VcsBaseSubmitEditor::SubmitDiscarded:
|
2011-02-28 13:40:06 +01:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-03-18 09:55:36 +01:00
|
|
|
QStringList files = commitEditor->checkedFiles();
|
2011-02-28 13:40:06 +01:00
|
|
|
if (!files.empty()) {
|
|
|
|
//save the commit message
|
2014-07-28 17:47:15 +02:00
|
|
|
if (!DocumentManager::saveDocument(editorDocument))
|
2011-03-30 12:43:17 +02:00
|
|
|
return false;
|
2011-02-28 13:40:06 +01:00
|
|
|
|
2011-03-18 09:55:36 +01:00
|
|
|
//rewrite entries of the form 'file => newfile' to 'newfile' because
|
|
|
|
//this would mess the commit command
|
|
|
|
for (QStringList::iterator iFile = files.begin(); iFile != files.end(); ++iFile) {
|
2012-01-31 10:57:10 +01:00
|
|
|
const QStringList parts = iFile->split(QLatin1String(" => "), QString::SkipEmptyParts);
|
2011-03-18 09:55:36 +01:00
|
|
|
if (!parts.isEmpty())
|
|
|
|
*iFile = parts.last();
|
|
|
|
}
|
|
|
|
|
2013-04-18 12:06:43 +02:00
|
|
|
BazaarCommitWidget *commitWidget = commitEditor->commitWidget();
|
2011-05-12 14:48:10 +02:00
|
|
|
QStringList extraOptions;
|
|
|
|
// Author
|
|
|
|
if (!commitWidget->committer().isEmpty())
|
|
|
|
extraOptions.append(QLatin1String("--author=") + commitWidget->committer());
|
|
|
|
// Fixed bugs
|
|
|
|
foreach (const QString &fix, commitWidget->fixedBugs()) {
|
|
|
|
if (!fix.isEmpty())
|
|
|
|
extraOptions << QLatin1String("--fixes") << fix;
|
|
|
|
}
|
|
|
|
// Whether local commit or not
|
|
|
|
if (commitWidget->isLocalOptionEnabled())
|
|
|
|
extraOptions += QLatin1String("--local");
|
2014-12-21 21:54:30 +02:00
|
|
|
m_client->commit(m_submitRepository, files, editorDocument->filePath().toString(), extraOptions);
|
2011-02-28 13:40:06 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void BazaarPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
2011-02-28 13:40:06 +01:00
|
|
|
{
|
|
|
|
if (!enableMenuAction(as, m_menuAction)) {
|
|
|
|
m_commandLocator->setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QString filename = currentState().currentFileName();
|
|
|
|
const bool repoEnabled = currentState().hasTopLevel();
|
|
|
|
m_commandLocator->setEnabled(repoEnabled);
|
|
|
|
|
|
|
|
m_annotateFile->setParameter(filename);
|
|
|
|
m_diffFile->setParameter(filename);
|
|
|
|
m_logFile->setParameter(filename);
|
|
|
|
m_addAction->setParameter(filename);
|
|
|
|
m_deleteAction->setParameter(filename);
|
|
|
|
m_revertFile->setParameter(filename);
|
|
|
|
m_statusFile->setParameter(filename);
|
|
|
|
|
|
|
|
foreach (QAction *repoAction, m_repositoryActionList)
|
|
|
|
repoAction->setEnabled(repoEnabled);
|
|
|
|
}
|
|
|
|
|
2014-07-19 16:04:46 +02:00
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Bazaar
|