1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
|
/**************************************************************************
**
** Copyright (c) 2013 Brian McGillion and Hugues Delorme
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "vcsbaseclient.h"
#include "command.h"
#include "vcsbaseclientsettings.h"
#include "vcsbaseeditorparameterwidget.h"
#include <coreplugin/icore.h>
#include <coreplugin/vcsmanager.h>
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseplugin.h>
#include <QStringList>
#include <QDir>
#include <QProcess>
#include <QSignalMapper>
#include <QTextCodec>
#include <QDebug>
#include <QFileInfo>
#include <QByteArray>
#include <QVariant>
#include <QProcessEnvironment>
/*!
\class VcsBase::VcsBaseClient
\brief The VcsBaseClient class is the base class for Mercurial and Bazaar
'clients'.
Provides base functionality for common commands (diff, log, etc).
\sa VcsBase::VcsJobRunner
*/
Q_DECLARE_METATYPE(QVariant)
inline Core::IEditor *locateEditor(const char *property, const QString &entry)
{
foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments())
if (document->property(property).toString() == entry)
return Core::EditorManager::documentModel()->editorsForDocument(document).first();
return 0;
}
namespace {
VcsBase::VcsBaseOutputWindow *vcsOutputWindow()
{
return VcsBase::VcsBaseOutputWindow::instance();
}
}
namespace VcsBase {
class VcsBaseClientPrivate
{
public:
VcsBaseClientPrivate(VcsBaseClient *client, VcsBaseClientSettings *settings);
void statusParser(const QString &text);
void annotateRevision(const QString &workingDirectory, const QString &file,
QString change, int lineNumber);
void saveSettings();
void bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor);
void commandFinishedGotoLine(QWidget *editorObject);
VcsBaseClientSettings *m_clientSettings;
QSignalMapper *m_cmdFinishedMapper;
private:
VcsBaseClient *m_client;
};
VcsBaseClientPrivate::VcsBaseClientPrivate(VcsBaseClient *client, VcsBaseClientSettings *settings) :
m_clientSettings(settings),
m_cmdFinishedMapper(new QSignalMapper(client)),
m_client(client)
{
}
void VcsBaseClientPrivate::statusParser(const QString &text)
{
QList<VcsBaseClient::StatusItem> lineInfoList;
QStringList rawStatusList = text.split(QLatin1Char('\n'));
foreach (const QString &string, rawStatusList) {
const VcsBaseClient::StatusItem lineInfo = m_client->parseStatusLine(string);
if (!lineInfo.flags.isEmpty() && !lineInfo.file.isEmpty())
lineInfoList.append(lineInfo);
}
emit m_client->parsedStatus(lineInfoList);
}
void VcsBaseClientPrivate::annotateRevision(const QString &workingDirectory, const QString &file,
QString change, int lineNumber)
{
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = change.indexOf(QLatin1Char(' '));
if (blankPos != -1)
change.truncate(blankPos);
m_client->annotate(workingDirectory, file, change, lineNumber);
}
void VcsBaseClientPrivate::saveSettings()
{
m_clientSettings->writeSettings(Core::ICore::settings());
}
void VcsBaseClientPrivate::bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor)
{
editor->setCommand(cmd);
QObject::connect(cmd, SIGNAL(finished(bool,int,QVariant)), m_cmdFinishedMapper, SLOT(map()));
m_cmdFinishedMapper->setMapping(cmd, editor);
}
void VcsBaseClientPrivate::commandFinishedGotoLine(QWidget *editorObject)
{
VcsBase::VcsBaseEditorWidget *editor = qobject_cast<VcsBase::VcsBaseEditorWidget *>(editorObject);
Command *cmd = qobject_cast<Command *>(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);
}
m_cmdFinishedMapper->removeMappings(cmd);
}
}
VcsBaseClient::StatusItem::StatusItem(const QString &s, const QString &f) :
flags(s), file(f)
{
}
VcsBaseClient::VcsBaseClient(VcsBaseClientSettings *settings) :
d(new VcsBaseClientPrivate(this, settings))
{
qRegisterMetaType<QVariant>();
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));
connect(d->m_cmdFinishedMapper, SIGNAL(mapped(QWidget*)), this, SLOT(commandFinishedGotoLine(QWidget*)));
}
VcsBaseClient::~VcsBaseClient()
{
delete d;
}
bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(CreateRepositoryCommand));
args << extraOptions;
QByteArray outputData;
if (!vcsFullySynchronousExec(workingDirectory, args, &outputData))
return false;
::vcsOutputWindow()->append(
Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(outputData)));
resetCachedVcsInfo(workingDirectory);
return true;
}
bool VcsBaseClient::synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(CloneCommand)
<< extraOptions << srcLocation << dstLocation;
QByteArray stdOut;
const bool cloneOk = vcsFullySynchronousExec(workingDir, args, &stdOut);
resetCachedVcsInfo(workingDir);
return cloneOk;
}
bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(AddCommand) << extraOptions << filename;
QByteArray stdOut;
return vcsFullySynchronousExec(workingDir, args, &stdOut);
}
bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(RemoveCommand) << extraOptions << filename;
QByteArray stdOut;
return vcsFullySynchronousExec(workingDir, args, &stdOut);
}
bool VcsBaseClient::synchronousMove(const QString &workingDir,
const QString &from, const QString &to,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(MoveCommand) << extraOptions << from << to;
QByteArray stdOut;
return vcsFullySynchronousExec(workingDir, args, &stdOut);
}
bool VcsBaseClient::synchronousPull(const QString &workingDir,
const QString &srcLocation,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags =
VcsBase::VcsBasePlugin::SshPasswordPrompt
| VcsBase::VcsBasePlugin::ShowStdOutInLogWindow
| VcsBase::VcsBasePlugin::ShowSuccessMessage;
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished;
if (ok)
emit changed(QVariant(workingDir));
return ok;
}
bool VcsBaseClient::synchronousPush(const QString &workingDir,
const QString &dstLocation,
const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(PushCommand) << extraOptions << dstLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags =
VcsBase::VcsBasePlugin::SshPasswordPrompt
| VcsBase::VcsBasePlugin::ShowStdOutInLogWindow
| VcsBase::VcsBasePlugin::ShowSuccessMessage;
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
return resp.result == Utils::SynchronousProcessResponse::Finished;
}
bool VcsBaseClient::vcsFullySynchronousExec(const QString &workingDir,
const QStringList &args,
QByteArray *output) const
{
QProcess vcsProcess;
if (!workingDir.isEmpty())
vcsProcess.setWorkingDirectory(workingDir);
vcsProcess.setProcessEnvironment(processEnvironment());
const QString binary = settings()->binaryPath();
::vcsOutputWindow()->appendCommand(workingDir, binary, args);
vcsProcess.start(binary, args);
if (!vcsProcess.waitForStarted()) {
::vcsOutputWindow()->appendError(tr("Unable to start process '%1': %2")
.arg(QDir::toNativeSeparators(binary), vcsProcess.errorString()));
return false;
}
vcsProcess.closeWriteChannel();
QByteArray stdErr;
const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey);
if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, timeoutSec * 1000,
output, &stdErr, true)) {
Utils::SynchronousProcess::stopProcess(vcsProcess);
::vcsOutputWindow()->appendError(tr("Timed out after %1s waiting for the process %2 to finish.")
.arg(timeoutSec).arg(binary));
return false;
}
if (!stdErr.isEmpty())
::vcsOutputWindow()->appendError(QString::fromLocal8Bit(stdErr));
return vcsProcess.exitStatus() == QProcess::NormalExit && vcsProcess.exitCode() == 0;
}
Utils::SynchronousProcessResponse VcsBaseClient::vcsSynchronousExec(
const QString &workingDirectory,
const QStringList &args,
unsigned flags,
QTextCodec *outputCodec)
{
const QString binary = settings()->binaryPath();
const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey);
return VcsBase::VcsBasePlugin::runVcs(workingDirectory, binary, args, timeoutSec * 1000,
flags, outputCodec);
}
void VcsBaseClient::annotate(const QString &workingDir, const QString &file,
const QString revision /* = QString() */,
int lineNumber /* = -1 */,
const QStringList &extraOptions)
{
const QString vcsCmdString = vcsCommandString(AnnotateCommand);
QStringList args;
args << vcsCmdString << revisionSpec(revision) << extraOptions << file;
const Core::Id kind = vcsEditorKind(AnnotateCommand);
const QString id = VcsBase::VcsBaseEditorWidget::getSource(workingDir, QStringList(file));
const QString title = vcsEditorTitle(vcsCmdString, id);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, file);
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true,
vcsCmdString.toLatin1().constData(), id);
Command *cmd = createCommand(workingDir, editor);
cmd->setCookie(lineNumber);
enqueueJob(cmd, args);
}
void VcsBaseClient::diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions)
{
const QString vcsCmdString = vcsCommandString(DiffCommand);
const Core::Id kind = vcsEditorKind(DiffCommand);
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, files);
const QString title = vcsEditorTitle(vcsCmdString, id);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, files);
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true,
vcsCmdString.toLatin1().constData(), id);
editor->setWorkingDirectory(workingDir);
VcsBaseEditorParameterWidget *paramWidget = editor->configurationWidget();
if (!paramWidget && (paramWidget = createDiffEditor(workingDir, files, extraOptions))) {
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editor, SIGNAL(diffChunkReverted(VcsBase::DiffChunk)), paramWidget, SLOT(executeCommand()));
editor->setConfigurationWidget(paramWidget);
}
QStringList args;
const QStringList paramArgs = paramWidget != 0 ? paramWidget->arguments() : QStringList();
args << vcsCmdString << extraOptions << paramArgs << files;
Command *command = createCommand(workingDir, editor);
enqueueJob(command, args, exitCodeInterpreter(DiffCommand, command));
}
void VcsBaseClient::log(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions,
bool enableAnnotationContextMenu)
{
const QString vcsCmdString = vcsCommandString(LogCommand);
const Core::Id kind = vcsEditorKind(LogCommand);
const QString id = VcsBase::VcsBaseEditorWidget::getTitleId(workingDir, files);
const QString title = vcsEditorTitle(vcsCmdString, id);
const QString source = VcsBase::VcsBaseEditorWidget::getSource(workingDir, files);
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true,
vcsCmdString.toLatin1().constData(), id);
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
VcsBaseEditorParameterWidget *paramWidget = editor->configurationWidget();
if (!paramWidget && (paramWidget = createLogEditor(workingDir, files, extraOptions))) {
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
editor->setConfigurationWidget(paramWidget);
}
QStringList args;
const QStringList paramArgs = paramWidget != 0 ? paramWidget->arguments() : QStringList();
args << vcsCmdString << extraOptions << paramArgs << files;
enqueueJob(createCommand(workingDir, editor), args);
}
void VcsBaseClient::revertFile(const QString &workingDir,
const QString &file,
const QString &revision,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(RevertCommand));
args << revisionSpec(revision) << extraOptions << file;
// Indicate repository change or file list
Command *cmd = createCommand(workingDir);
cmd->setCookie(QStringList(workingDir + QLatin1Char('/') + file));
connect(cmd, SIGNAL(success(QVariant)), this, SIGNAL(changed(QVariant)), Qt::QueuedConnection);
enqueueJob(cmd, args);
}
void VcsBaseClient::revertAll(const QString &workingDir, const QString &revision,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(RevertCommand));
args << revisionSpec(revision) << extraOptions;
// Indicate repository change or file list
Command *cmd = createCommand(workingDir);
cmd->setCookie(QStringList(workingDir));
connect(cmd, SIGNAL(success(QVariant)), this, SIGNAL(changed(QVariant)), Qt::QueuedConnection);
enqueueJob(createCommand(workingDir), args);
}
void VcsBaseClient::status(const QString &workingDir, const QString &file,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(StatusCommand));
args << extraOptions << file;
::vcsOutputWindow()->setRepository(workingDir);
Command *cmd = createCommand(workingDir, 0, VcsWindowOutputBind);
connect(cmd, SIGNAL(finished(bool,int,QVariant)), ::vcsOutputWindow(), SLOT(clearRepository()),
Qt::QueuedConnection);
enqueueJob(cmd, args);
}
void VcsBaseClient::emitParsedStatus(const QString &repository, const QStringList &extraOptions)
{
QStringList args(vcsCommandString(StatusCommand));
args << extraOptions;
Command *cmd = createCommand(repository);
connect(cmd, SIGNAL(output(QString)), this, SLOT(statusParser(QString)));
enqueueJob(cmd, args);
}
QString VcsBaseClient::vcsCommandString(VcsCommand cmd) const
{
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");
}
return QString();
}
Utils::ExitCodeInterpreter *VcsBaseClient::exitCodeInterpreter(VcsCommand cmd, QObject *parent) const
{
Q_UNUSED(cmd)
Q_UNUSED(parent)
return 0;
}
void VcsBaseClient::import(const QString &repositoryRoot, const QStringList &files,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(ImportCommand));
args << extraOptions << files;
enqueueJob(createCommand(repositoryRoot), args);
}
void VcsBaseClient::view(const QString &source, const QString &id,
const QStringList &extraOptions)
{
QStringList args;
args << extraOptions << revisionSpec(id);
const Core::Id kind = vcsEditorKind(DiffCommand);
const QString title = vcsEditorTitle(vcsCommandString(LogCommand), id);
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
true, "view", id);
const QFileInfo fi(source);
const QString workingDirPath = fi.isFile() ? fi.absolutePath() : source;
enqueueJob(createCommand(workingDirPath, editor), args);
}
void VcsBaseClient::update(const QString &repositoryRoot, const QString &revision,
const QStringList &extraOptions)
{
QStringList args(vcsCommandString(UpdateCommand));
args << revisionSpec(revision) << extraOptions;
Command *cmd = createCommand(repositoryRoot);
cmd->setCookie(repositoryRoot);
connect(cmd, SIGNAL(success(QVariant)), this, SIGNAL(changed(QVariant)), Qt::QueuedConnection);
enqueueJob(cmd, args);
}
void VcsBaseClient::commit(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
const QStringList &extraOptions)
{
// Handling of commitMessageFile is a bit tricky :
// VcsBaseClient cannot do something with it because it doesn't know which
// option to use (-F ? but sub VCS clients might require a different option
// name like -l for hg ...)
//
// So descendants of VcsBaseClient *must* redefine commit() and extend
// extraOptions with the usage for commitMessageFile (see BazaarClient::commit()
// for example)
Q_UNUSED(commitMessageFile);
QStringList args(vcsCommandString(CommitCommand));
args << extraOptions << files;
enqueueJob(createCommand(repositoryRoot), args);
}
VcsBaseClientSettings *VcsBaseClient::settings() const
{
return d->m_clientSettings;
}
VcsBaseEditorParameterWidget *VcsBaseClient::createDiffEditor(const QString &workingDir,
const QStringList &files,
const QStringList &extraOptions)
{
Q_UNUSED(workingDir);
Q_UNUSED(files);
Q_UNUSED(extraOptions);
return 0;
}
VcsBaseEditorParameterWidget *VcsBaseClient::createLogEditor(const QString &workingDir,
const QStringList &files,
const QStringList &extraOptions)
{
Q_UNUSED(workingDir);
Q_UNUSED(files);
Q_UNUSED(extraOptions);
return 0;
}
QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
{
const QString binary = settings()->binaryPath();
return QFileInfo(binary).baseName() +
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
QFileInfo(sourceId).fileName();
}
VcsBase::VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(Core::Id kind, QString title,
const QString &source, bool setSourceCodec,
const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const
{
VcsBase::VcsBaseEditorWidget *baseEditor = 0;
Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue);
const QString progressMsg = tr("Working...");
if (outputEditor) {
// Exists already
outputEditor->document()->setContents(progressMsg.toUtf8());
baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor);
QTC_ASSERT(baseEditor, return 0);
} else {
outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8());
outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor);
connect(baseEditor, SIGNAL(annotateRevisionRequested(QString,QString,QString,int)),
this, SLOT(annotateRevision(QString,QString,QString,int)));
QTC_ASSERT(baseEditor, return 0);
baseEditor->setSource(source);
if (setSourceCodec)
baseEditor->setCodec(VcsBase::VcsBaseEditorWidget::getCodec(source));
}
baseEditor->setForceReadOnly(true);
Core::EditorManager::activateEditor(outputEditor);
return baseEditor;
}
QProcessEnvironment VcsBaseClient::processEnvironment() const
{
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
VcsBase::VcsBasePlugin::setProcessEnvironment(&environment, false);
return environment;
}
Command *VcsBaseClient::createCommand(const QString &workingDirectory,
VcsBase::VcsBaseEditorWidget *editor,
JobOutputBindMode mode)
{
Command *cmd = new Command(d->m_clientSettings->binaryPath(),
workingDirectory, processEnvironment());
cmd->setDefaultTimeout(d->m_clientSettings->intValue(VcsBaseClientSettings::timeoutKey));
if (editor)
d->bindCommandToEditor(cmd, editor);
if (mode == VcsWindowOutputBind) {
cmd->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
if (editor) // assume that the commands output is the important thing
cmd->addFlags(VcsBasePlugin::SilentOutput);
} else if (editor) {
connect(cmd, SIGNAL(output(QString)), editor, SLOT(setPlainText(QString)));
}
return cmd;
}
void VcsBaseClient::enqueueJob(Command *cmd, const QStringList &args, Utils::ExitCodeInterpreter *interpreter)
{
cmd->addJob(args, interpreter);
cmd->execute();
}
void VcsBaseClient::resetCachedVcsInfo(const QString &workingDir)
{
Core::VcsManager::resetVersionControlForDirectory(workingDir);
}
} // namespace VcsBase
#include "moc_vcsbaseclient.cpp"
|