2011-02-28 13:40:04 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 Brian McGillion and Hugues Delorme
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-02-28 13:40:04 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-28 13:40:04 +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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-02-28 13:40:04 +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
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-02-28 13:40:04 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
#include "vcsbaseclient.h"
|
2014-08-27 18:55:41 +02:00
|
|
|
#include "vcscommand.h"
|
2011-02-28 13:40:04 +01:00
|
|
|
#include "vcsbaseclientsettings.h"
|
2011-06-10 15:27:57 +00:00
|
|
|
#include "vcsbaseeditorparameterwidget.h"
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-09-13 15:05:50 +00:00
|
|
|
#include <coreplugin/vcsmanager.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <coreplugin/editormanager/documentmodel.h>
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
#include <coreplugin/idocument.h>
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
#include <utils/synchronousprocess.h>
|
|
|
|
#include <vcsbase/vcsbaseeditor.h>
|
2014-08-26 00:02:47 +02:00
|
|
|
#include <vcsbase/vcsoutputwindow.h>
|
2011-02-28 13:40:04 +01:00
|
|
|
#include <vcsbase/vcsbaseplugin.h>
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QSignalMapper>
|
|
|
|
#include <QTextCodec>
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QByteArray>
|
2013-03-25 11:36:51 +01:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QProcessEnvironment>
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2011-03-28 14:19:17 +02:00
|
|
|
/*!
|
2012-01-07 12:31:48 +01:00
|
|
|
\class VcsBase::VcsBaseClient
|
2011-03-28 14:19:17 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The VcsBaseClient class is the base class for Mercurial and Bazaar
|
|
|
|
'clients'.
|
2011-03-28 14:19:17 +02:00
|
|
|
|
|
|
|
Provides base functionality for common commands (diff, log, etc).
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
\sa VcsBase::VcsJobRunner
|
2011-03-28 14:19:17 +02:00
|
|
|
*/
|
|
|
|
|
2014-08-26 00:02:47 +02:00
|
|
|
static Core::IEditor *locateEditor(const char *property, const QString &entry)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
|
2013-07-17 09:42:44 +02:00
|
|
|
if (document->property(property).toString() == entry)
|
2014-05-07 16:25:04 +02:00
|
|
|
return Core::DocumentModel::editorsForDocument(document).first();
|
2011-02-28 13:40:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2015-03-26 12:22:29 +01:00
|
|
|
class VcsBaseClientImplPrivate
|
|
|
|
{
|
|
|
|
public:
|
2015-03-27 15:24:45 +01:00
|
|
|
VcsBaseClientImplPrivate(VcsBaseClientImpl *client, VcsBaseClientSettings *settings);
|
2015-03-26 12:22:29 +01:00
|
|
|
~VcsBaseClientImplPrivate();
|
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
void bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWidget *editor);
|
|
|
|
|
2015-03-26 12:22:29 +01:00
|
|
|
VcsBaseClientSettings *m_clientSettings;
|
2015-03-27 15:24:45 +01:00
|
|
|
QSignalMapper *m_cmdFinishedMapper;
|
2015-03-26 12:22:29 +01:00
|
|
|
};
|
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
void VcsBaseClientImplPrivate::bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWidget *editor)
|
|
|
|
{
|
|
|
|
editor->setCommand(cmd);
|
|
|
|
QObject::connect(cmd, &VcsCommand::finished,
|
|
|
|
m_cmdFinishedMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
|
|
|
m_cmdFinishedMapper->setMapping(cmd, editor);
|
|
|
|
}
|
2015-03-26 12:22:29 +01:00
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
VcsBaseClientImplPrivate::VcsBaseClientImplPrivate(VcsBaseClientImpl *client,
|
|
|
|
VcsBaseClientSettings *settings) :
|
|
|
|
m_clientSettings(settings),
|
|
|
|
m_cmdFinishedMapper(new QSignalMapper(client))
|
2015-03-26 12:22:29 +01:00
|
|
|
{
|
|
|
|
m_clientSettings->readSettings(Core::ICore::settings());
|
|
|
|
}
|
|
|
|
|
|
|
|
VcsBaseClientImplPrivate::~VcsBaseClientImplPrivate()
|
|
|
|
{
|
|
|
|
delete m_clientSettings;
|
|
|
|
}
|
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
VcsBaseClientImpl::VcsBaseClientImpl(VcsBaseClientImpl *client, VcsBaseClientSettings *settings) :
|
|
|
|
d(new VcsBaseClientImplPrivate(client, settings))
|
2015-03-26 12:22:29 +01:00
|
|
|
{
|
|
|
|
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
|
|
|
this, &VcsBaseClientImpl::saveSettings);
|
2015-03-27 15:24:45 +01:00
|
|
|
|
|
|
|
connect(d->m_cmdFinishedMapper, static_cast<void (QSignalMapper::*)(QWidget*)>(&QSignalMapper::mapped),
|
|
|
|
this, &VcsBaseClientImpl::commandFinishedGotoLine);
|
2015-03-26 12:22:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VcsBaseClientImpl::~VcsBaseClientImpl()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
VcsBaseClientSettings &VcsBaseClientImpl::settings() const
|
|
|
|
{
|
|
|
|
return *d->m_clientSettings;
|
|
|
|
}
|
|
|
|
|
2015-03-27 14:24:47 +01:00
|
|
|
Utils::FileName VcsBaseClientImpl::vcsBinary() const
|
|
|
|
{
|
|
|
|
return settings().binaryPath();
|
|
|
|
}
|
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory,
|
2015-04-10 15:10:20 +02:00
|
|
|
VcsBaseEditorWidget *editor,
|
|
|
|
JobOutputBindMode mode) const
|
2015-03-27 15:24:45 +01:00
|
|
|
{
|
2015-04-15 16:09:56 +02:00
|
|
|
auto cmd = new VcsCommand(workingDirectory, processEnvironment());
|
2015-04-10 14:44:17 +02:00
|
|
|
cmd->setDefaultTimeoutS(vcsTimeoutS());
|
2015-03-27 15:24:45 +01:00
|
|
|
if (editor)
|
|
|
|
d->bindCommandToEditor(cmd, editor);
|
|
|
|
if (mode == VcsWindowOutputBind) {
|
2015-04-27 15:03:07 +02:00
|
|
|
cmd->addFlags(VcsCommand::ShowStdOut);
|
2015-03-27 15:24:45 +01:00
|
|
|
if (editor) // assume that the commands output is the important thing
|
2015-04-27 15:03:07 +02:00
|
|
|
cmd->addFlags(VcsCommand::SilentOutput);
|
2015-03-27 15:24:45 +01:00
|
|
|
} else if (editor) {
|
2015-04-29 12:50:12 +02:00
|
|
|
connect(cmd, &VcsCommand::stdOutText, editor, &VcsBaseEditorWidget::setPlainText);
|
2015-03-27 15:24:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
2015-06-08 15:04:04 +02:00
|
|
|
const QString &workingDirectory,
|
2015-03-27 15:24:45 +01:00
|
|
|
Utils::ExitCodeInterpreter *interpreter)
|
|
|
|
{
|
2015-06-08 15:04:04 +02:00
|
|
|
cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter);
|
2015-03-27 15:24:45 +01:00
|
|
|
cmd->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
QProcessEnvironment VcsBaseClientImpl::processEnvironment() const
|
|
|
|
{
|
|
|
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
|
|
VcsBasePlugin::setProcessEnvironment(&environment, false);
|
|
|
|
return environment;
|
|
|
|
}
|
|
|
|
|
2015-04-10 15:23:20 +02:00
|
|
|
QString VcsBaseClientImpl::commandOutputFromLocal8Bit(const QByteArray &a)
|
|
|
|
{
|
|
|
|
return Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a));
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList VcsBaseClientImpl::commandOutputLinesFromLocal8Bit(const QByteArray &a)
|
|
|
|
{
|
|
|
|
QString output = commandOutputFromLocal8Bit(a);
|
|
|
|
const QChar newLine = QLatin1Char('\n');
|
|
|
|
if (output.endsWith(newLine))
|
|
|
|
output.truncate(output.size() - 1);
|
|
|
|
if (output.isEmpty())
|
|
|
|
return QStringList();
|
|
|
|
return output.split(newLine);
|
|
|
|
}
|
|
|
|
|
2015-03-27 15:33:38 +01:00
|
|
|
void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
|
|
|
|
{
|
|
|
|
Core::VcsManager::resetVersionControlForDirectory(workingDir);
|
|
|
|
}
|
|
|
|
|
2015-04-13 11:38:44 +02:00
|
|
|
void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirectory,
|
|
|
|
const QString &file, const QString &change,
|
|
|
|
int line)
|
|
|
|
{
|
|
|
|
QString changeCopy = change;
|
|
|
|
// This might be invoked with a verbose revision description
|
|
|
|
// "SHA1 author subject" from the annotation context menu. Strip the rest.
|
|
|
|
const int blankPos = changeCopy.indexOf(QLatin1Char(' '));
|
|
|
|
if (blankPos != -1)
|
|
|
|
changeCopy.truncate(blankPos);
|
|
|
|
annotate(workingDirectory, file, changeCopy, line);
|
|
|
|
}
|
|
|
|
|
2015-04-13 16:45:54 +02:00
|
|
|
bool VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
|
|
|
QByteArray *outputData, QByteArray *errorData,
|
|
|
|
unsigned flags) const
|
|
|
|
{
|
|
|
|
QByteArray internalErrorData;
|
|
|
|
QScopedPointer<VcsCommand> command(createCommand(workingDir));
|
|
|
|
command->addFlags(flags);
|
2015-04-15 16:09:56 +02:00
|
|
|
bool result = command->runFullySynchronous(vcsBinary(), args, vcsTimeoutS(), outputData,
|
2015-04-13 16:45:54 +02:00
|
|
|
errorData ? errorData : &internalErrorData);
|
2015-04-27 15:03:07 +02:00
|
|
|
if (!internalErrorData.isEmpty() && !(flags & VcsCommand::SuppressStdErr))
|
2015-04-13 16:45:54 +02:00
|
|
|
VcsOutputWindow::appendError(commandOutputFromLocal8Bit(internalErrorData));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-04-14 15:26:15 +02:00
|
|
|
VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments,
|
|
|
|
VcsBaseEditorWidget *editor, bool useOutputToWindow,
|
|
|
|
unsigned additionalFlags, const QVariant &cookie)
|
|
|
|
{
|
|
|
|
VcsCommand *command = createCommand(workingDirectory, editor,
|
|
|
|
useOutputToWindow ? VcsWindowOutputBind : NoOutputBind);
|
|
|
|
command->setCookie(cookie);
|
|
|
|
command->addFlags(additionalFlags);
|
|
|
|
enqueueJob(command, arguments);
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
2015-04-13 16:53:41 +02:00
|
|
|
Utils::SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &workingDir,
|
|
|
|
const QStringList &args,
|
|
|
|
unsigned flags,
|
|
|
|
QTextCodec *outputCodec) const
|
|
|
|
{
|
|
|
|
return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags,
|
|
|
|
outputCodec, processEnvironment());
|
|
|
|
}
|
|
|
|
|
2015-04-10 14:44:17 +02:00
|
|
|
int VcsBaseClientImpl::vcsTimeoutS() const
|
2015-03-27 14:24:47 +01:00
|
|
|
{
|
|
|
|
return settings().intValue(VcsBaseClientSettings::timeoutKey);
|
|
|
|
}
|
|
|
|
|
2015-03-27 16:08:52 +01:00
|
|
|
VcsBaseEditorWidget *VcsBaseClientImpl::createVcsEditor(Core::Id kind, QString title,
|
|
|
|
const QString &source, QTextCodec *codec,
|
|
|
|
const char *registerDynamicProperty,
|
|
|
|
const QString &dynamicPropertyValue) const
|
|
|
|
{
|
|
|
|
VcsBaseEditorWidget *baseEditor = 0;
|
|
|
|
Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue);
|
|
|
|
const QString progressMsg = tr("Working...");
|
|
|
|
if (outputEditor) {
|
|
|
|
// Exists already
|
|
|
|
outputEditor->document()->setContents(progressMsg.toUtf8());
|
|
|
|
baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor);
|
|
|
|
QTC_ASSERT(baseEditor, return 0);
|
|
|
|
Core::EditorManager::activateEditor(outputEditor);
|
|
|
|
} else {
|
|
|
|
outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8());
|
|
|
|
outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
|
|
|
|
baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor);
|
2015-04-14 22:52:56 +03:00
|
|
|
QTC_ASSERT(baseEditor, return 0);
|
2015-03-27 16:08:52 +01:00
|
|
|
connect(baseEditor, &VcsBaseEditorWidget::annotateRevisionRequested,
|
|
|
|
this, &VcsBaseClientImpl::annotateRevisionRequested);
|
|
|
|
baseEditor->setSource(source);
|
|
|
|
if (codec)
|
|
|
|
baseEditor->setCodec(codec);
|
|
|
|
}
|
|
|
|
|
|
|
|
baseEditor->setForceReadOnly(true);
|
|
|
|
return baseEditor;
|
|
|
|
}
|
|
|
|
|
2015-03-26 12:22:29 +01:00
|
|
|
void VcsBaseClientImpl::saveSettings()
|
|
|
|
{
|
|
|
|
settings().writeSettings(Core::ICore::settings());
|
|
|
|
}
|
|
|
|
|
2015-03-27 15:24:45 +01:00
|
|
|
void VcsBaseClientImpl::commandFinishedGotoLine(QWidget *editorObject)
|
|
|
|
{
|
|
|
|
VcsBaseEditorWidget *editor = qobject_cast<VcsBaseEditorWidget *>(editorObject);
|
|
|
|
VcsCommand *cmd = qobject_cast<VcsCommand *>(d->m_cmdFinishedMapper->mapping(editor));
|
|
|
|
if (editor && cmd) {
|
|
|
|
if (!cmd->lastExecutionSuccess()) {
|
|
|
|
editor->reportCommandFinished(false, cmd->lastExecutionExitCode(), cmd->cookie());
|
|
|
|
} else if (cmd->cookie().type() == QVariant::Int) {
|
|
|
|
const int line = cmd->cookie().toInt();
|
|
|
|
if (line >= 0)
|
|
|
|
editor->gotoLine(line);
|
|
|
|
}
|
|
|
|
d->m_cmdFinishedMapper->removeMappings(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
class VcsBaseClientPrivate
|
2011-03-02 12:49:55 +01:00
|
|
|
{
|
|
|
|
public:
|
2015-01-20 17:42:16 +01:00
|
|
|
VcsBaseEditorParameterWidget *createDiffEditor();
|
|
|
|
VcsBaseEditorParameterWidget *createLogEditor();
|
|
|
|
|
|
|
|
VcsBaseClient::ParameterWidgetCreator m_diffParamWidgetCreator;
|
|
|
|
VcsBaseClient::ParameterWidgetCreator m_logParamWidgetCreator;
|
2011-03-02 12:49:55 +01:00
|
|
|
};
|
|
|
|
|
2015-01-20 17:42:16 +01:00
|
|
|
VcsBaseEditorParameterWidget *VcsBaseClientPrivate::createDiffEditor()
|
|
|
|
{
|
|
|
|
return m_diffParamWidgetCreator ? m_diffParamWidgetCreator() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
VcsBaseEditorParameterWidget *VcsBaseClientPrivate::createLogEditor()
|
|
|
|
{
|
|
|
|
return m_logParamWidgetCreator ? m_logParamWidgetCreator() : 0;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsBaseClient::StatusItem::StatusItem(const QString &s, const QString &f) :
|
2011-08-22 15:33:03 +00:00
|
|
|
flags(s), file(f)
|
2015-01-22 15:38:42 +01:00
|
|
|
{ }
|
2011-08-22 15:33:03 +00:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsBaseClient::VcsBaseClient(VcsBaseClientSettings *settings) :
|
2015-03-27 15:24:45 +01:00
|
|
|
VcsBaseClientImpl(this, settings),
|
|
|
|
d(new VcsBaseClientPrivate)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
qRegisterMetaType<QVariant>();
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsBaseClient::~VcsBaseClient()
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2011-08-23 10:38:44 +00:00
|
|
|
QStringList args(vcsCommandString(CreateRepositoryCommand));
|
|
|
|
args << extraOptions;
|
2011-02-28 13:40:04 +01:00
|
|
|
QByteArray outputData;
|
|
|
|
if (!vcsFullySynchronousExec(workingDirectory, args, &outputData))
|
|
|
|
return false;
|
2015-04-10 15:23:20 +02:00
|
|
|
VcsOutputWindow::append(commandOutputFromLocal8Bit(outputData));
|
2011-09-13 15:05:50 +00:00
|
|
|
|
|
|
|
resetCachedVcsInfo(workingDirectory);
|
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousClone(const QString &workingDir,
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString &srcLocation,
|
|
|
|
const QString &dstLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
|
|
|
args << vcsCommandString(CloneCommand)
|
2011-08-23 10:38:44 +00:00
|
|
|
<< extraOptions << srcLocation << dstLocation;
|
2011-02-28 13:40:04 +01:00
|
|
|
QByteArray stdOut;
|
2011-09-13 15:05:50 +00:00
|
|
|
const bool cloneOk = vcsFullySynchronousExec(workingDir, args, &stdOut);
|
|
|
|
resetCachedVcsInfo(workingDir);
|
|
|
|
return cloneOk;
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCommandString(AddCommand) << extraOptions << filename;
|
2011-02-28 13:40:04 +01:00
|
|
|
QByteArray stdOut;
|
|
|
|
return vcsFullySynchronousExec(workingDir, args, &stdOut);
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCommandString(RemoveCommand) << extraOptions << filename;
|
2011-02-28 13:40:04 +01:00
|
|
|
QByteArray stdOut;
|
|
|
|
return vcsFullySynchronousExec(workingDir, args, &stdOut);
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousMove(const QString &workingDir,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QString &from, const QString &to,
|
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCommandString(MoveCommand) << extraOptions << from << to;
|
2011-02-28 13:40:04 +01:00
|
|
|
QByteArray stdOut;
|
|
|
|
return vcsFullySynchronousExec(workingDir, args, &stdOut);
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousPull(const QString &workingDir,
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString &srcLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
|
2011-02-28 13:40:04 +01:00
|
|
|
// Disable UNIX terminals to suppress SSH prompting
|
|
|
|
const unsigned flags =
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt
|
|
|
|
| VcsCommand::ShowStdOut
|
|
|
|
| VcsCommand::ShowSuccessMessage;
|
2011-02-28 13:40:04 +01:00
|
|
|
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
|
|
|
|
const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished;
|
|
|
|
if (ok)
|
|
|
|
emit changed(QVariant(workingDir));
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsBaseClient::synchronousPush(const QString &workingDir,
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString &dstLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCommandString(PushCommand) << extraOptions << dstLocation;
|
2011-02-28 13:40:04 +01:00
|
|
|
// Disable UNIX terminals to suppress SSH prompting
|
|
|
|
const unsigned flags =
|
2015-04-27 15:03:07 +02:00
|
|
|
VcsCommand::SshPasswordPrompt
|
|
|
|
| VcsCommand::ShowStdOut
|
|
|
|
| VcsCommand::ShowSuccessMessage;
|
2011-02-28 13:40:04 +01:00
|
|
|
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
|
|
|
|
return resp.result == Utils::SynchronousProcessResponse::Finished;
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::annotate(const QString &workingDir, const QString &file,
|
2014-05-05 16:59:56 +03:00
|
|
|
const QString &revision /* = QString() */,
|
2011-08-23 10:38:44 +00:00
|
|
|
int lineNumber /* = -1 */,
|
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
const QString vcsCmdString = vcsCommandString(AnnotateCommand);
|
|
|
|
QStringList args;
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCmdString << revisionSpec(revision) << extraOptions << file;
|
2013-03-19 15:23:04 +01:00
|
|
|
const Core::Id kind = vcsEditorKind(AnnotateCommand);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString id = VcsBaseEditor::getSource(workingDir, QStringList(file));
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString title = vcsEditorTitle(vcsCmdString, id);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString source = VcsBaseEditor::getSource(workingDir, file);
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2015-03-27 16:08:52 +01:00
|
|
|
VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
|
|
|
|
VcsBaseEditor::getCodec(source),
|
2014-08-27 18:55:41 +02:00
|
|
|
vcsCmdString.toLatin1().constData(), id);
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(workingDir, editor);
|
2011-10-05 15:32:16 +00:00
|
|
|
cmd->setCookie(lineNumber);
|
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::diff(const QString &workingDir, const QStringList &files,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
const QString vcsCmdString = vcsCommandString(DiffCommand);
|
2013-03-19 15:23:04 +01:00
|
|
|
const Core::Id kind = vcsEditorKind(DiffCommand);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString id = VcsBaseEditor::getTitleId(workingDir, files);
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString title = vcsEditorTitle(vcsCmdString, id);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString source = VcsBaseEditor::getSource(workingDir, files);
|
2015-03-27 16:08:52 +01:00
|
|
|
VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
|
|
|
|
VcsBaseEditor::getCodec(source),
|
2014-08-27 18:55:41 +02:00
|
|
|
vcsCmdString.toLatin1().constData(), id);
|
2013-10-06 20:52:09 +03:00
|
|
|
editor->setWorkingDirectory(workingDir);
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2013-10-11 15:40:29 +02:00
|
|
|
VcsBaseEditorParameterWidget *paramWidget = editor->configurationWidget();
|
2015-01-20 17:42:16 +01:00
|
|
|
if (!paramWidget && (paramWidget = d->createDiffEditor())) {
|
2013-10-11 15:40:29 +02:00
|
|
|
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
|
2014-09-02 15:33:49 +02:00
|
|
|
connect(editor, &VcsBaseEditorWidget::diffChunkReverted,
|
|
|
|
paramWidget, &VcsBaseEditorParameterWidget::executeCommand);
|
2015-01-20 17:42:16 +01:00
|
|
|
connect(paramWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested,
|
|
|
|
[=] { diff(workingDir, files, extraOptions); } );
|
2011-06-10 15:27:57 +00:00
|
|
|
editor->setConfigurationWidget(paramWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList args;
|
|
|
|
const QStringList paramArgs = paramWidget != 0 ? paramWidget->arguments() : QStringList();
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCmdString << extraOptions << paramArgs << files;
|
2014-08-27 17:50:20 +02:00
|
|
|
QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VcsBaseEditor::getCodec(source);
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *command = createCommand(workingDir, editor);
|
2013-09-27 15:39:16 +02:00
|
|
|
command->setCodec(codec);
|
2015-06-08 15:04:04 +02:00
|
|
|
enqueueJob(command, args, workingDir, exitCodeInterpreter(DiffCommand, command));
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::log(const QString &workingDir, const QStringList &files,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions,
|
2011-02-28 13:40:04 +01:00
|
|
|
bool enableAnnotationContextMenu)
|
|
|
|
{
|
|
|
|
const QString vcsCmdString = vcsCommandString(LogCommand);
|
2013-03-19 15:23:04 +01:00
|
|
|
const Core::Id kind = vcsEditorKind(LogCommand);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString id = VcsBaseEditor::getTitleId(workingDir, files);
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString title = vcsEditorTitle(vcsCmdString, id);
|
2014-08-27 17:50:20 +02:00
|
|
|
const QString source = VcsBaseEditor::getSource(workingDir, files);
|
2015-03-27 16:08:52 +01:00
|
|
|
VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
|
|
|
|
VcsBaseEditor::getCodec(source),
|
2014-08-27 18:55:41 +02:00
|
|
|
vcsCmdString.toLatin1().constData(), id);
|
2011-02-28 13:40:04 +01:00
|
|
|
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
|
|
|
|
|
2013-10-11 15:40:29 +02:00
|
|
|
VcsBaseEditorParameterWidget *paramWidget = editor->configurationWidget();
|
2015-01-20 17:42:16 +01:00
|
|
|
if (!paramWidget && (paramWidget = d->createLogEditor())) {
|
2013-10-11 15:40:29 +02:00
|
|
|
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
|
2015-01-20 17:42:16 +01:00
|
|
|
connect(paramWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested,
|
2015-01-22 16:02:32 +01:00
|
|
|
[=]() { this->log(workingDir, files, extraOptions, enableAnnotationContextMenu); } );
|
2011-07-28 10:22:11 +00:00
|
|
|
editor->setConfigurationWidget(paramWidget);
|
2013-10-11 15:40:29 +02:00
|
|
|
}
|
2011-07-28 10:22:11 +00:00
|
|
|
|
|
|
|
QStringList args;
|
|
|
|
const QStringList paramArgs = paramWidget != 0 ? paramWidget->arguments() : QStringList();
|
2011-08-23 10:38:44 +00:00
|
|
|
args << vcsCmdString << extraOptions << paramArgs << files;
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(createCommand(workingDir, editor), args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::revertFile(const QString &workingDir,
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString &file,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QString &revision,
|
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(RevertCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << revisionSpec(revision) << extraOptions << file;
|
2011-02-28 13:40:04 +01:00
|
|
|
// Indicate repository change or file list
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(workingDir);
|
2011-10-05 15:32:16 +00:00
|
|
|
cmd->setCookie(QStringList(workingDir + QLatin1Char('/') + file));
|
2015-01-21 10:16:17 +01:00
|
|
|
connect(cmd, &VcsCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::revertAll(const QString &workingDir, const QString &revision,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(RevertCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << revisionSpec(revision) << extraOptions;
|
2011-02-28 13:40:04 +01:00
|
|
|
// Indicate repository change or file list
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(workingDir);
|
2011-10-05 15:32:16 +00:00
|
|
|
cmd->setCookie(QStringList(workingDir));
|
2015-01-21 10:16:17 +01:00
|
|
|
connect(cmd, &VcsCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(createCommand(workingDir), args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::status(const QString &workingDir, const QString &file,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(StatusCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << extraOptions << file;
|
2014-08-26 00:02:47 +02:00
|
|
|
VcsOutputWindow::setRepository(workingDir);
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(workingDir, 0, VcsWindowOutputBind);
|
2015-01-21 10:16:17 +01:00
|
|
|
connect(cmd, &VcsCommand::finished,
|
|
|
|
VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
|
2011-10-05 15:32:16 +00:00
|
|
|
Qt::QueuedConnection);
|
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::emitParsedStatus(const QString &repository, const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(StatusCommand));
|
2011-08-22 15:33:03 +00:00
|
|
|
args << extraOptions;
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(repository);
|
2015-04-29 12:50:12 +02:00
|
|
|
connect(cmd, &VcsCommand::stdOutText, this, &VcsBaseClient::statusParser);
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2014-08-27 18:55:41 +02:00
|
|
|
QString VcsBaseClient::vcsCommandString(VcsCommandTag cmd) const
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2011-02-28 15:05:40 +01:00
|
|
|
switch (cmd) {
|
|
|
|
case CreateRepositoryCommand: return QLatin1String("init");
|
|
|
|
case CloneCommand: return QLatin1String("clone");
|
|
|
|
case AddCommand: return QLatin1String("add");
|
|
|
|
case RemoveCommand: return QLatin1String("remove");
|
|
|
|
case MoveCommand: return QLatin1String("rename");
|
|
|
|
case PullCommand: return QLatin1String("pull");
|
|
|
|
case PushCommand: return QLatin1String("push");
|
|
|
|
case CommitCommand: return QLatin1String("commit");
|
|
|
|
case ImportCommand: return QLatin1String("import");
|
|
|
|
case UpdateCommand: return QLatin1String("update");
|
|
|
|
case RevertCommand: return QLatin1String("revert");
|
|
|
|
case AnnotateCommand: return QLatin1String("annotate");
|
|
|
|
case DiffCommand: return QLatin1String("diff");
|
|
|
|
case LogCommand: return QLatin1String("log");
|
|
|
|
case StatusCommand: return QLatin1String("status");
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
2011-02-28 15:05:40 +01:00
|
|
|
return QString();
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2014-08-27 18:55:41 +02:00
|
|
|
Utils::ExitCodeInterpreter *VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const
|
2013-09-24 16:40:10 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(cmd)
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-20 17:42:16 +01:00
|
|
|
void VcsBaseClient::setDiffParameterWidgetCreator(ParameterWidgetCreator creator)
|
|
|
|
{
|
|
|
|
d->m_diffParamWidgetCreator = std::move(creator);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VcsBaseClient::setLogParameterWidgetCreator(ParameterWidgetCreator creator)
|
|
|
|
{
|
|
|
|
d->m_logParamWidgetCreator = std::move(creator);
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::import(const QString &repositoryRoot, const QStringList &files,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(ImportCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << extraOptions << files;
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(createCommand(repositoryRoot), args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::view(const QString &source, const QString &id,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2011-08-23 10:38:44 +00:00
|
|
|
QStringList args;
|
|
|
|
args << extraOptions << revisionSpec(id);
|
2013-03-19 15:23:04 +01:00
|
|
|
const Core::Id kind = vcsEditorKind(DiffCommand);
|
2011-02-28 13:40:04 +01:00
|
|
|
const QString title = vcsEditorTitle(vcsCommandString(LogCommand), id);
|
|
|
|
|
2015-03-27 16:08:52 +01:00
|
|
|
VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
|
|
|
|
VcsBaseEditor::getCodec(source), "view", id);
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2011-03-25 10:12:51 +01:00
|
|
|
const QFileInfo fi(source);
|
|
|
|
const QString workingDirPath = fi.isFile() ? fi.absolutePath() : source;
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(createCommand(workingDirPath, editor), args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::update(const QString &repositoryRoot, const QString &revision,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
QStringList args(vcsCommandString(UpdateCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << revisionSpec(revision) << extraOptions;
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsCommand *cmd = createCommand(repositoryRoot);
|
2011-10-05 15:32:16 +00:00
|
|
|
cmd->setCookie(repositoryRoot);
|
2015-01-21 10:16:17 +01:00
|
|
|
connect(cmd, &VcsCommand::success, this, &VcsBaseClient::changed, Qt::QueuedConnection);
|
2011-10-05 15:32:16 +00:00
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsBaseClient::commit(const QString &repositoryRoot,
|
2011-02-28 13:40:04 +01:00
|
|
|
const QStringList &files,
|
|
|
|
const QString &commitMessageFile,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions)
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2011-08-23 10:38:44 +00:00
|
|
|
// Handling of commitMessageFile is a bit tricky :
|
2012-01-07 12:31:48 +01:00
|
|
|
// VcsBaseClient cannot do something with it because it doesn't know which
|
2011-08-23 10:38:44 +00:00
|
|
|
// option to use (-F ? but sub VCS clients might require a different option
|
|
|
|
// name like -l for hg ...)
|
|
|
|
//
|
2012-01-07 12:31:48 +01:00
|
|
|
// So descendants of VcsBaseClient *must* redefine commit() and extend
|
2011-08-23 10:38:44 +00:00
|
|
|
// extraOptions with the usage for commitMessageFile (see BazaarClient::commit()
|
|
|
|
// for example)
|
2011-02-28 13:40:04 +01:00
|
|
|
QStringList args(vcsCommandString(CommitCommand));
|
2011-08-23 10:38:44 +00:00
|
|
|
args << extraOptions << files;
|
2015-01-19 10:41:31 +01:00
|
|
|
VcsCommand *cmd = createCommand(repositoryRoot, 0, VcsWindowOutputBind);
|
|
|
|
if (!commitMessageFile.isEmpty())
|
|
|
|
connect(cmd, &VcsCommand::finished, [commitMessageFile]() { QFile(commitMessageFile).remove(); });
|
|
|
|
enqueueJob(cmd, args);
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
2015-03-25 12:30:07 +01:00
|
|
|
return vcsBinary().toFileInfo().baseName() +
|
2011-03-14 11:18:49 +01:00
|
|
|
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
|
2015-01-10 23:40:32 +02:00
|
|
|
Utils::FileName::fromString(sourceId).fileName();
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
2015-01-21 10:16:17 +01:00
|
|
|
void VcsBaseClient::statusParser(const QString &text)
|
|
|
|
{
|
|
|
|
QList<VcsBaseClient::StatusItem> lineInfoList;
|
|
|
|
|
|
|
|
QStringList rawStatusList = text.split(QLatin1Char('\n'));
|
|
|
|
|
|
|
|
foreach (const QString &string, rawStatusList) {
|
|
|
|
const VcsBaseClient::StatusItem lineInfo = parseStatusLine(string);
|
|
|
|
if (!lineInfo.flags.isEmpty() && !lineInfo.file.isEmpty())
|
|
|
|
lineInfoList.append(lineInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
emit parsedStatus(lineInfoList);
|
|
|
|
}
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|
2011-08-22 15:33:02 +00:00
|
|
|
|
|
|
|
#include "moc_vcsbaseclient.cpp"
|