summaryrefslogtreecommitdiffstats
path: root/plugins/fossil/fossilclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/fossil/fossilclient.cpp')
-rw-r--r--plugins/fossil/fossilclient.cpp96
1 files changed, 68 insertions, 28 deletions
diff --git a/plugins/fossil/fossilclient.cpp b/plugins/fossil/fossilclient.cpp
index bb8bcee..584fc81 100644
--- a/plugins/fossil/fossilclient.cpp
+++ b/plugins/fossil/fossilclient.cpp
@@ -24,6 +24,7 @@
****************************************************************************/
#include "fossilclient.h"
+#include "fossileditor.h"
#include "constants.h"
#include <coreplugin/id.h>
@@ -93,6 +94,13 @@ public:
mapSetting(addToggleButton("|BLAME|", tr("Show Committers")),
settings.boolPointer(FossilSettings::annotateShowCommittersKey));
}
+
+ // Force listVersions setting to false by default.
+ // This way the annotated line number would not get offset by the version list.
+ settings.setValue(FossilSettings::annotateListVersionsKey, false);
+
+ mapSetting(addToggleButton(QLatin1String("--log"), tr("List Versions")),
+ settings.boolPointer(FossilSettings::annotateListVersionsKey));
}
};
@@ -725,19 +733,34 @@ VcsBase::VcsBaseEditorWidget *FossilClient::annotate(
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
VcsBase::VcsBaseEditor::getCodec(source),
vcsCmdString.toLatin1().constData(), id);
- QStringList effectiveArgs = extraOptions;
- if (!editor->configurationAdded()) {
- if (VcsBase::VcsBaseEditorConfig *editorConfig = createAnnotateEditor(editor)) {
+
+ // We need to be able to re-query the configuration widget for the arguments
+ // each time the Annotate is requested from the main menu. This allows processing of
+ // the effective args controlled via configuration widget.
+ // However VcsBaseEditorWidget no longer stores the configuration widget and thus
+ // does not support configurationWidget() query.
+ // So we re-implement the configurationWidget() in FossilEditorWidget sub-class.
+
+ auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
+ QTC_ASSERT(fossilEditor, return editor);
+
+ if (!fossilEditor->configurationAdded()) {
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = createAnnotateEditor(fossilEditor)) {
+ editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBase::VcsBaseEditorConfig::commandExecutionRequested,
- [=] { return this->annotate(workingDir, file, revision, lineNumber, extraOptions + editorConfig->arguments()); } );
- effectiveArgs += editorConfig->arguments();
- editor->setConfigurationAdded();
+ [=]() {
+ const int line = VcsBase::VcsBaseEditor::lineNumberOfCurrentEditor();
+ return this->annotate(workingDir, file, revision, line, editorConfig->arguments());
+ } );
+ fossilEditor->setConfigurationWidget(editorConfig);
}
}
+ QStringList effectiveArgs = extraOptions;
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = fossilEditor->configurationWidget())
+ effectiveArgs = editorConfig->arguments();
- VcsBase::VcsCommand *cmd = createCommand(workingDir, editor);
- cmd->setCookie(lineNumber);
+ VcsBase::VcsCommand *cmd = createCommand(workingDir, fossilEditor);
// here we introduce a "|BLAME|" meta-option to allow both annotate and blame modes
int pos = effectiveArgs.indexOf("|BLAME|");
@@ -746,10 +769,15 @@ VcsBase::VcsBaseEditorWidget *FossilClient::annotate(
effectiveArgs.removeAt(pos);
}
QStringList args(vcsCmdString);
- args << revisionSpec(revision) << effectiveArgs << "--log" << file;
+ args << revisionSpec(revision) << effectiveArgs << file;
+
+ // When version list requested, ignore the source line.
+ if (args.contains("--log"))
+ lineNumber = -1;
+ cmd->setCookie(lineNumber);
enqueueJob(cmd, args);
- return editor;
+ return fossilEditor;
}
bool FossilClient::isVcsFileOrDirectory(const Utils::FileName &fileName) const
@@ -926,28 +954,34 @@ void FossilClient::log(const QString &workingDir, const QStringList &files,
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
VcsBase::VcsBaseEditor::getCodec(source),
vcsCmdString.toLatin1().constData(), id);
- editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
- QStringList effectiveArgs = extraOptions;
- if (!editor->configurationAdded()) {
- if (VcsBase::VcsBaseEditorConfig *editorConfig = createLogEditor(editor)) {
+ auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
+ QTC_ASSERT(fossilEditor, return);
+
+ fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
+
+ if (!fossilEditor->configurationAdded()) {
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = createLogEditor(fossilEditor)) {
+ editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBase::VcsBaseEditorConfig::commandExecutionRequested,
- [=]() { this->log(workingDir, files, extraOptions + editorConfig->arguments(), enableAnnotationContextMenu); } );
- effectiveArgs += editorConfig->arguments();
- editor->setConfigurationAdded();
+ [=]() { this->log(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu); } );
+ fossilEditor->setConfigurationWidget(editorConfig);
}
}
+ QStringList effectiveArgs = extraOptions;
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = fossilEditor->configurationWidget())
+ effectiveArgs = editorConfig->arguments();
//@TODO: move highlighter and widgets to fossil editor sources.
- new FossilLogHighlighter(editor->document());
+ new FossilLogHighlighter(fossilEditor->document());
QStringList args(vcsCmdString);
args << effectiveArgs;
if (!files.isEmpty())
args << "--path" << files;
- enqueueJob(createCommand(workingDir, editor), args);
+ enqueueJob(createCommand(workingDir, fossilEditor), args);
}
void FossilClient::logCurrentFile(const QString &workingDir, const QStringList &files,
@@ -972,26 +1006,32 @@ void FossilClient::logCurrentFile(const QString &workingDir, const QStringList &
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source,
VcsBase::VcsBaseEditor::getCodec(source),
vcsCmdString.toLatin1().constData(), id);
- editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
- QStringList effectiveArgs = extraOptions;
- if (!editor->configurationAdded()) {
- if (VcsBase::VcsBaseEditorConfig *editorConfig = createLogEditor(editor)) {
+ auto *fossilEditor = qobject_cast<FossilEditorWidget *>(editor);
+ QTC_ASSERT(fossilEditor, return);
+
+ fossilEditor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
+
+ if (!fossilEditor->configurationAdded()) {
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = createLogEditor(fossilEditor)) {
+ editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBase::VcsBaseEditorConfig::commandExecutionRequested,
- [=]() { this->logCurrentFile(workingDir, files, extraOptions + editorConfig->arguments(), enableAnnotationContextMenu); } );
- effectiveArgs += editorConfig->arguments();
- editor->setConfigurationAdded();
+ [=]() { this->logCurrentFile(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu); } );
+ fossilEditor->setConfigurationWidget(editorConfig);
}
}
+ QStringList effectiveArgs = extraOptions;
+ if (VcsBase::VcsBaseEditorConfig *editorConfig = fossilEditor->configurationWidget())
+ effectiveArgs = editorConfig->arguments();
//@TODO: move highlighter and widgets to fossil editor sources.
- new FossilLogHighlighter(editor->document());
+ new FossilLogHighlighter(fossilEditor->document());
QStringList args(vcsCmdString);
args << effectiveArgs << files;
- enqueueJob(createCommand(workingDir, editor), args);
+ enqueueJob(createCommand(workingDir, fossilEditor), args);
}
void FossilClient::revertFile(const QString &workingDir,