forked from qt-creator/qt-creator
Vcs: Move static functions out of VcsPlugin "namespace"
Plan is to split VcsPlugin in the pure IPlugin and a new class the remaining non-IPlugin bits of VcsPlugin, call it VcsPluginPrivate and use that d-ptr for VcsPlugin. VcsPlugin-derived classes can then use VcsPluginPrivate derived private, later pointer members of the *Privates can be made proper members, moving towards the otherwise predominant plugin setup pattern. Change-Id: I62db9269e8ca50633c24b6d1d735d59c8fa8e5a5 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -189,10 +189,8 @@ QString BazaarClient::findTopLevelForFile(const QFileInfo &file) const
|
|||||||
const QString repositoryCheckFile =
|
const QString repositoryCheckFile =
|
||||||
QLatin1String(Constants::BAZAARREPO) + QLatin1String("/branch-format");
|
QLatin1String(Constants::BAZAARREPO) + QLatin1String("/branch-format");
|
||||||
return file.isDir() ?
|
return file.isDir() ?
|
||||||
VcsBasePlugin::findRepositoryForDirectory(file.absoluteFilePath(),
|
VcsBase::findRepositoryForDirectory(file.absoluteFilePath(), repositoryCheckFile) :
|
||||||
repositoryCheckFile) :
|
VcsBase::findRepositoryForDirectory(file.absolutePath(), repositoryCheckFile);
|
||||||
VcsBasePlugin::findRepositoryForDirectory(file.absolutePath(),
|
|
||||||
repositoryCheckFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BazaarClient::managesFile(const QString &workingDirectory, const QString &fileName) const
|
bool BazaarClient::managesFile(const QString &workingDirectory, const QString &fileName) const
|
||||||
|
@@ -1453,7 +1453,7 @@ ClearCasePlugin::runCleartool(const QString &workingDir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SynchronousProcessResponse sp_resp =
|
const SynchronousProcessResponse sp_resp =
|
||||||
VcsBasePlugin::runVcs(workingDir,
|
VcsBase::runVcs(workingDir,
|
||||||
{executable, arguments},
|
{executable, arguments},
|
||||||
timeOutS,
|
timeOutS,
|
||||||
flags, outputCodec);
|
flags, outputCodec);
|
||||||
|
@@ -534,7 +534,7 @@ void ShowController::reload()
|
|||||||
m_state = GettingDescription;
|
m_state = GettingDescription;
|
||||||
const QStringList args = {"show", "-s", noColorOption, showFormatC, m_id};
|
const QStringList args = {"show", "-s", noColorOption, showFormatC, m_id};
|
||||||
runCommand(QList<QStringList>() << args, GitPlugin::client()->encoding(workingDirectory(), "i18n.commitEncoding"));
|
runCommand(QList<QStringList>() << args, GitPlugin::client()->encoding(workingDirectory(), "i18n.commitEncoding"));
|
||||||
setStartupFile(VcsBasePlugin::source(document()));
|
setStartupFile(VcsBase::source(document()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowController::processCommandOutput(const QString &output)
|
void ShowController::processCommandOutput(const QString &output)
|
||||||
@@ -955,7 +955,7 @@ void GitClient::requestReload(const QString &documentId, const QString &source,
|
|||||||
connect(controller, &DiffEditorController::chunkActionsRequested,
|
connect(controller, &DiffEditorController::chunkActionsRequested,
|
||||||
this, &GitClient::chunkActionsRequested, Qt::DirectConnection);
|
this, &GitClient::chunkActionsRequested, Qt::DirectConnection);
|
||||||
|
|
||||||
VcsBasePlugin::setSource(document, sourceCopy);
|
VcsBase::setSource(document, sourceCopy);
|
||||||
EditorManager::activateEditorForDocument(document);
|
EditorManager::activateEditorForDocument(document);
|
||||||
controller->requestReload();
|
controller->requestReload();
|
||||||
}
|
}
|
||||||
|
@@ -1025,7 +1025,7 @@ IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &
|
|||||||
}
|
}
|
||||||
IDocument *document = submitEditor->document();
|
IDocument *document = submitEditor->document();
|
||||||
document->setPreferredDisplayName(title);
|
document->setPreferredDisplayName(title);
|
||||||
VcsBasePlugin::setSource(document, m_submitRepository);
|
VcsBase::setSource(document, m_submitRepository);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -231,7 +231,7 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
|
|||||||
// cause mercurial doesn`t understand LANG
|
// cause mercurial doesn`t understand LANG
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
|
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
|
||||||
const SynchronousProcessResponse resp = VcsBasePlugin::runVcs(
|
const SynchronousProcessResponse resp = VcsBase::runVcs(
|
||||||
workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, nullptr, env);
|
workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, nullptr, env);
|
||||||
const bool ok = resp.result == SynchronousProcessResponse::Finished;
|
const bool ok = resp.result == SynchronousProcessResponse::Finished;
|
||||||
|
|
||||||
@@ -459,8 +459,8 @@ QString MercurialClient::findTopLevelForFile(const QFileInfo &file) const
|
|||||||
{
|
{
|
||||||
const QString repositoryCheckFile = QLatin1String(Constants::MERCURIALREPO) + QLatin1String("/requires");
|
const QString repositoryCheckFile = QLatin1String(Constants::MERCURIALREPO) + QLatin1String("/requires");
|
||||||
return file.isDir() ?
|
return file.isDir() ?
|
||||||
VcsBasePlugin::findRepositoryForDirectory(file.absoluteFilePath(), repositoryCheckFile) :
|
VcsBase::findRepositoryForDirectory(file.absoluteFilePath(), repositoryCheckFile) :
|
||||||
VcsBasePlugin::findRepositoryForDirectory(file.absolutePath(), repositoryCheckFile);
|
VcsBase::findRepositoryForDirectory(file.absolutePath(), repositoryCheckFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Id MercurialClient::vcsEditorKind(VcsCommandTag cmd) const
|
Core::Id MercurialClient::vcsEditorKind(VcsCommandTag cmd) const
|
||||||
@@ -521,7 +521,7 @@ void MercurialClient::requestReload(const QString &documentId, const QString &so
|
|||||||
DiffEditorController *controller = factory(document);
|
DiffEditorController *controller = factory(document);
|
||||||
QTC_ASSERT(controller, return);
|
QTC_ASSERT(controller, return);
|
||||||
|
|
||||||
VcsBasePlugin::setSource(document, sourceCopy);
|
VcsBase::setSource(document, sourceCopy);
|
||||||
EditorManager::activateEditorForDocument(document);
|
EditorManager::activateEditorForDocument(document);
|
||||||
controller->requestReload();
|
controller->requestReload();
|
||||||
}
|
}
|
||||||
|
@@ -278,7 +278,7 @@ SubversionDiffEditorController *SubversionClient::findOrCreateDiffEditor(const Q
|
|||||||
DiffEditorController::controller(document));
|
DiffEditorController::controller(document));
|
||||||
if (!controller)
|
if (!controller)
|
||||||
controller = new SubversionDiffEditorController(document, workingDirectory);
|
controller = new SubversionDiffEditorController(document, workingDirectory);
|
||||||
VcsBasePlugin::setSource(document, source);
|
VcsBase::setSource(document, source);
|
||||||
EditorManager::activateEditorForDocument(document);
|
EditorManager::activateEditorForDocument(document);
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
@@ -145,7 +145,7 @@ void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
|||||||
QProcessEnvironment VcsBaseClientImpl::processEnvironment() const
|
QProcessEnvironment VcsBaseClientImpl::processEnvironment() const
|
||||||
{
|
{
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
VcsBasePlugin::setProcessEnvironment(&environment, false);
|
VcsBase::setProcessEnvironment(&environment, false);
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,8 +232,8 @@ SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &
|
|||||||
unsigned flags,
|
unsigned flags,
|
||||||
QTextCodec *outputCodec) const
|
QTextCodec *outputCodec) const
|
||||||
{
|
{
|
||||||
return VcsBasePlugin::runVcs(workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags,
|
return VcsBase::runVcs(workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags,
|
||||||
outputCodec, processEnvironment());
|
outputCodec, processEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
int VcsBaseClientImpl::vcsTimeoutS() const
|
int VcsBaseClientImpl::vcsTimeoutS() const
|
||||||
|
@@ -769,12 +769,12 @@ void VcsBaseEditorWidget::setForceReadOnly(bool b)
|
|||||||
|
|
||||||
QString VcsBaseEditorWidget::source() const
|
QString VcsBaseEditorWidget::source() const
|
||||||
{
|
{
|
||||||
return VcsBasePlugin::source(textDocument());
|
return VcsBase::source(textDocument());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBaseEditorWidget::setSource(const QString &source)
|
void VcsBaseEditorWidget::setSource(const QString &source)
|
||||||
{
|
{
|
||||||
VcsBasePlugin::setSource(textDocument(), source);
|
VcsBase::setSource(textDocument(), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
|
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
|
||||||
|
@@ -263,7 +263,7 @@ void StateListener::slotStateChanged()
|
|||||||
if (currentDocument) {
|
if (currentDocument) {
|
||||||
state.currentFile = currentDocument->filePath().toString();
|
state.currentFile = currentDocument->filePath().toString();
|
||||||
if (state.currentFile.isEmpty() || currentDocument->isTemporary())
|
if (state.currentFile.isEmpty() || currentDocument->isTemporary())
|
||||||
state.currentFile = VcsBasePlugin::source(currentDocument);
|
state.currentFile = VcsBase::source(currentDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the file and its control. Do not use the file unless we find one
|
// Get the file and its control. Do not use the file unless we find one
|
||||||
@@ -728,8 +728,7 @@ bool VcsBasePlugin::raiseSubmitEditor() const
|
|||||||
// AutoFS is used (due its automatically creating mountpoints when querying
|
// AutoFS is used (due its automatically creating mountpoints when querying
|
||||||
// a directory). In addition, bail out when reaching the home directory
|
// a directory). In addition, bail out when reaching the home directory
|
||||||
// of the user or root (generally avoid '/', where mountpoints are created).
|
// of the user or root (generally avoid '/', where mountpoints are created).
|
||||||
QString VcsBasePlugin::findRepositoryForDirectory(const QString &dirS,
|
QString findRepositoryForDirectory(const QString &dirS, const QString &checkFile)
|
||||||
const QString &checkFile)
|
|
||||||
{
|
{
|
||||||
qCDebug(findRepoLog) << ">" << dirS << checkFile;
|
qCDebug(findRepoLog) << ">" << dirS << checkFile;
|
||||||
QTC_ASSERT(!dirS.isEmpty() && !checkFile.isEmpty(), return QString());
|
QTC_ASSERT(!dirS.isEmpty() && !checkFile.isEmpty(), return QString());
|
||||||
@@ -753,32 +752,32 @@ QString VcsBasePlugin::findRepositoryForDirectory(const QString &dirS,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is SSH prompt configured?
|
// Is SSH prompt configured?
|
||||||
QString VcsBasePlugin::sshPrompt()
|
QString sshPrompt()
|
||||||
{
|
{
|
||||||
return Internal::VcsPlugin::instance()->settings().sshPasswordPrompt;
|
return Internal::VcsPlugin::instance()->settings().sshPasswordPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VcsBasePlugin::isSshPromptConfigured()
|
bool isSshPromptConfigured()
|
||||||
{
|
{
|
||||||
return !sshPrompt().isEmpty();
|
return !sshPrompt().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char SOURCE_PROPERTY[] = "qtcreator_source";
|
static const char SOURCE_PROPERTY[] = "qtcreator_source";
|
||||||
|
|
||||||
void VcsBasePlugin::setSource(IDocument *document, const QString &source)
|
void setSource(IDocument *document, const QString &source)
|
||||||
{
|
{
|
||||||
document->setProperty(SOURCE_PROPERTY, source);
|
document->setProperty(SOURCE_PROPERTY, source);
|
||||||
VcsBasePluginPrivate::m_listener->slotStateChanged();
|
VcsBasePluginPrivate::m_listener->slotStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsBasePlugin::source(IDocument *document)
|
QString source(IDocument *document)
|
||||||
{
|
{
|
||||||
return document->property(SOURCE_PROPERTY).toString();
|
return document->property(SOURCE_PROPERTY).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
|
void setProcessEnvironment(QProcessEnvironment *e,
|
||||||
bool forceCLocale,
|
bool forceCLocale,
|
||||||
const QString &sshPromptBinary)
|
const QString &sshPromptBinary)
|
||||||
{
|
{
|
||||||
if (forceCLocale) {
|
if (forceCLocale) {
|
||||||
e->insert("LANG", "C");
|
e->insert("LANG", "C");
|
||||||
@@ -790,12 +789,12 @@ void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
|
|||||||
|
|
||||||
// Run a process synchronously, returning Utils::SynchronousProcessResponse
|
// Run a process synchronously, returning Utils::SynchronousProcessResponse
|
||||||
// response struct and using the VcsBasePlugin flags as applicable
|
// response struct and using the VcsBasePlugin flags as applicable
|
||||||
SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir,
|
SynchronousProcessResponse runVcs(const QString &workingDir,
|
||||||
const CommandLine &cmd,
|
const CommandLine &cmd,
|
||||||
int timeOutS,
|
int timeOutS,
|
||||||
unsigned flags,
|
unsigned flags,
|
||||||
QTextCodec *outputCodec,
|
QTextCodec *outputCodec,
|
||||||
const QProcessEnvironment &env)
|
const QProcessEnvironment &env)
|
||||||
{
|
{
|
||||||
VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
||||||
command.addFlags(flags);
|
command.addFlags(flags);
|
||||||
|
@@ -123,6 +123,36 @@ inline bool operator==(const VcsBasePluginState &s1, const VcsBasePluginState &s
|
|||||||
inline bool operator!=(const VcsBasePluginState &s1, const VcsBasePluginState &s2)
|
inline bool operator!=(const VcsBasePluginState &s1, const VcsBasePluginState &s2)
|
||||||
{ return !s1.equals(s2); }
|
{ return !s1.equals(s2); }
|
||||||
|
|
||||||
|
// Convenience that searches for the repository specifically for version control
|
||||||
|
// systems that do not have directories like "CVS" in each managed subdirectory
|
||||||
|
// but have a directory at the top of the repository like ".git" containing
|
||||||
|
// a well known file. See implementation for gory details.
|
||||||
|
VCSBASE_EXPORT QString findRepositoryForDirectory(const QString &dir, const QString &checkFile);
|
||||||
|
|
||||||
|
// Returns SSH prompt configured in settings.
|
||||||
|
VCSBASE_EXPORT QString sshPrompt();
|
||||||
|
// Returns whether an SSH prompt is configured.
|
||||||
|
VCSBASE_EXPORT bool isSshPromptConfigured();
|
||||||
|
|
||||||
|
// Set up the environment for a version control command line call.
|
||||||
|
// Sets up SSH graphical password prompting (note that the latter
|
||||||
|
// requires a terminal-less process) and sets LANG to 'C' to force English
|
||||||
|
// (suppress LOCALE warnings/parse commands output) if desired.
|
||||||
|
VCSBASE_EXPORT void setProcessEnvironment(QProcessEnvironment *e,
|
||||||
|
bool forceCLocale,
|
||||||
|
const QString &sshPasswordPrompt = sshPrompt());
|
||||||
|
// Sets the source of editor contents, can be directory or file.
|
||||||
|
VCSBASE_EXPORT void setSource(Core::IDocument *document, const QString &source);
|
||||||
|
// Returns the source of editor contents.
|
||||||
|
VCSBASE_EXPORT QString source(Core::IDocument *document);
|
||||||
|
|
||||||
|
VCSBASE_EXPORT Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
|
||||||
|
const Utils::CommandLine &cmd,
|
||||||
|
int timeOutS,
|
||||||
|
unsigned flags = 0,
|
||||||
|
QTextCodec *outputCodec = nullptr,
|
||||||
|
const QProcessEnvironment &env = {});
|
||||||
|
|
||||||
class VCSBASE_EXPORT VcsBasePlugin : public ExtensionSystem::IPlugin
|
class VCSBASE_EXPORT VcsBasePlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -138,36 +168,6 @@ public:
|
|||||||
const VcsBasePluginState ¤tState() const;
|
const VcsBasePluginState ¤tState() const;
|
||||||
Core::IVersionControl *versionControl() const;
|
Core::IVersionControl *versionControl() const;
|
||||||
|
|
||||||
// Convenience that searches for the repository specifically for version control
|
|
||||||
// systems that do not have directories like "CVS" in each managed subdirectory
|
|
||||||
// but have a directory at the top of the repository like ".git" containing
|
|
||||||
// a well known file. See implementation for gory details.
|
|
||||||
static QString findRepositoryForDirectory(const QString &dir, const QString &checkFile);
|
|
||||||
|
|
||||||
// Set up the environment for a version control command line call.
|
|
||||||
// Sets up SSH graphical password prompting (note that the latter
|
|
||||||
// requires a terminal-less process) and sets LANG to 'C' to force English
|
|
||||||
// (suppress LOCALE warnings/parse commands output) if desired.
|
|
||||||
static void setProcessEnvironment(QProcessEnvironment *e,
|
|
||||||
bool forceCLocale,
|
|
||||||
const QString &sshPasswordPrompt = sshPrompt());
|
|
||||||
// Returns SSH prompt configured in settings.
|
|
||||||
static QString sshPrompt();
|
|
||||||
// Returns whether an SSH prompt is configured.
|
|
||||||
static bool isSshPromptConfigured();
|
|
||||||
|
|
||||||
// Sets the source of editor contents, can be directory or file.
|
|
||||||
static void setSource(Core::IDocument *document, const QString &source);
|
|
||||||
// Returns the source of editor contents.
|
|
||||||
static QString source(Core::IDocument *document);
|
|
||||||
|
|
||||||
static Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
|
|
||||||
const Utils::CommandLine &cmd,
|
|
||||||
int timeOutS,
|
|
||||||
unsigned flags = 0,
|
|
||||||
QTextCodec *outputCodec = nullptr,
|
|
||||||
const QProcessEnvironment &env = QProcessEnvironment());
|
|
||||||
|
|
||||||
// Display name of the commit action
|
// Display name of the commit action
|
||||||
virtual QString commitDisplayName() const;
|
virtual QString commitDisplayName() const;
|
||||||
|
|
||||||
|
@@ -73,7 +73,7 @@ VcsCommand::VcsCommand(const QString &workingDirectory,
|
|||||||
const QProcessEnvironment VcsCommand::processEnvironment() const
|
const QProcessEnvironment VcsCommand::processEnvironment() const
|
||||||
{
|
{
|
||||||
QProcessEnvironment env = Core::ShellCommand::processEnvironment();
|
QProcessEnvironment env = Core::ShellCommand::processEnvironment();
|
||||||
VcsBasePlugin::setProcessEnvironment(&env, flags() & ForceCLocale, VcsBasePlugin::sshPrompt());
|
VcsBase::setProcessEnvironment(&env, flags() & ForceCLocale, VcsBase::sshPrompt());
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ void VcsCommand::emitRepositoryChanged(const QString &workingDirectory)
|
|||||||
unsigned VcsCommand::processFlags() const
|
unsigned VcsCommand::processFlags() const
|
||||||
{
|
{
|
||||||
unsigned processFlags = 0;
|
unsigned processFlags = 0;
|
||||||
if (!VcsBasePlugin::sshPrompt().isEmpty() && (flags() & SshPasswordPrompt))
|
if (!VcsBase::sshPrompt().isEmpty() && (flags() & SshPasswordPrompt))
|
||||||
processFlags |= SynchronousProcess::UnixTerminalDisabled;
|
processFlags |= SynchronousProcess::UnixTerminalDisabled;
|
||||||
return processFlags;
|
return processFlags;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user