Commit Graph

68 Commits

Author SHA1 Message Date
Jarek Kobus
93dfa93b7d VcsCommand: Simplify ProgressParser
Get rid of abstract base ProgressParser and replace
it with ProgressParser function. The only one former
subclass GitProgressParser is now functor object.
Pass future interface directly to the ProgressParser
function, along with input text to be parsed.

Change-Id: Icbcf0b6e55097f8b38eb8a32ceaa4414723116d0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-07 14:52:14 +00:00
Jarek Kobus
363731a8c8 RunFlags: Add ProgressiveOutput flag
It replaces VcsCommand::setProgressiveOutput() property.

Change-Id: Icebd2205a5b489f60ded1eeee21e2deacbfde1fe
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-06 13:35:48 +00:00
Jarek Kobus
eec0679234 VcsBase: Move RunFlags into separate header
It is going to be used outside of VcsCommand, too.
Use RunFlags enum as an argument to several functions
instead of unsigned.

Change-Id: I355c80a845a9b5982108fbde3412754392dce702
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-06 12:00:35 +00:00
Jarek Kobus
7591b2f56d VcsCommand: Make runCommand() a static method
And rename it to runBlocking() in order to conform
a bit more to QtcProcess API.

In case of blocking run there is no need to instantiate
VcsCommand on user side. This nicely draw a line between
async usages (i.e. when start() is called and we need
an instance) and blocking ones (i.e. when runBlocking()
is called).

Change-Id: I1ba94ee36c92956d5044236cb9e2dd896bf3cfcf
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-05 17:13:49 +00:00
Jarek Kobus
688ec935cd VcsCommand: Remove internal terminate() signal
This signal was emitted only from cancel() method and
used only when runCommand() was called. However, with
just 2 public usages of cancel() no-one was used
in conjunction with runCommand(). So, this signal is
no-op.

Change-Id: I2541c6498928d313faafc2fbe47ab609393486d1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-05 17:11:17 +00:00
Jarek Kobus
f4233a1c22 VcsCommand: Change the default logic for fully sync
Remove VcsCommand::FullySynchronous flag.
Rename VcsCommand::NoFullySync into UseEventLoop.
By default the command will run fully synchronous
(i.e. without nested event loop). Only when
UseEventLoop is specified, and the command runs in
main thread, the nested event loop will be used.

This change should preserve the current behavior
on all code paths.

Change-Id: Id4bbaf68402ceed5e3fcc6f294521e87eb0b8d4d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-10-05 17:10:04 +00:00
Jarek Kobus
1dbdc46ea1 ClearCasePlugin: Reuse CommandResult
Get rid of ClearCaseResponse struct.
Replace foreach with range-based for loops.

Change-Id: Id78e2ca3598c16ad16ebaeddae73a140e3473936
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-21 13:56:09 +00:00
Jarek Kobus
29ecc7b5dd VcsCommand: Rename execute() to start()
In order to conform to QtcProcess API.

Change-Id: I71fcc03846f32cd3c2df39824ce3f6730c20ebbb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-21 05:33:46 +00:00
Jarek Kobus
353f50693e VcsCommand: Remove finished() signal
Change-Id: I79a1ca05c1bc246f3a850fcbf585c89dddb45cb1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-20 19:10:44 +00:00
Jarek Kobus
5e10ea19c1 VcsCommand: Conform to QtcProcess API
Add result() getter and done() signal in order to
conform to QtcProcess API.

Change-Id: Idc7c57e03d6e8acead9d4c034f4efc56250f944d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-20 10:41:25 +00:00
Jarek Kobus
3978cdde6c VcsCommand: Add std channel getters
Conform to QtcProcess interface and provide cleanedStdOut()
and cleanedStdErr() getters, to be called after the process
finished.

Use cleanedStdOut() inside DiffEditorController for getting
the output after the process finished instead of connecting
to stdOutText() signal.

Change-Id: I7ba3735b0ab2167ac1f3b0954dd5dc9553910aac
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-19 10:31:35 +00:00
Jarek Kobus
7274cad083 VcsCommand: Always install std callbacks
Do it also in fully synchronous case, as QtcProcess
is able to handle them even when EventLoopMode is off.

Change-Id: Ic24ff34e3d8808d2aaaf0300ba4ac95662e46d23
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-16 07:20:21 +00:00
Jarek Kobus
5047802f0a VcsCommand: Remove one runCommand() overload
Not used anymore after changing implementation of execute().

Change-Id: I0af0e61b3bd9184f30f11cd80d377d25acf805f8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-05 06:11:41 +00:00
Jarek Kobus
2a2b136624 VcsCommand: Get rid of abort()
Use destructor of VcsCommand instead.

Change-Id: Ie914d016c6d3d57a88674ce8534d5edec4bc79c1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-02 13:22:15 +00:00
Jarek Kobus
3dc3870475 VcsCommand: Don't run in separate thread
Change-Id: Ief0e859d3ce48f804e128cc0f5cb1b390a066923
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-02 13:21:57 +00:00
Jarek Kobus
6f50040e13 VcsCommand: Extract some methods for further usage
Change-Id: I385a02d773527a73bbd7fff0a40a40db476a70b8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-01 16:31:17 +00:00
Jarek Kobus
28fdeefe6f VcsCommand: Move some methods into VcsCommandPrivate
Change-Id: I49302dadcc1ceaa7c73970aff9e41237d554098a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-09-01 15:16:07 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
a50afa486a VcsCommand: Remove unused SshPasswordPrompt
Change-Id: I402d619656d8339b1e81bc9ae96acf56178505d2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-26 08:36:34 +00:00
Jarek Kobus
7bd33bc247 VcsCommand: Remove defaultWorkingRepository() getter
It wasn't really broadly used.

Change-Id: If2e185a7d8d0f920f3ec7f507bf96dd81f4559b0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-03 11:30:36 +00:00
Jarek Kobus
191fc196d5 VcsCommand: Remove one addJob overload
Remove defaultTimeoutS field, as it wasn't broadly used.

Change-Id: I0056788b066eb6d682d5ba7acdb01d5dd3568967
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-03 06:09:44 +00:00
Jarek Kobus
278d297397 VcsCommand: Simplify public runCommand()
Get rid of unused workingDirectory (default working
directory will be used) and exitCodeInterpreter.
Simplify internals a bit.

Change-Id: I2a7547e5a594dd7a21f390daeb06778656e9e971
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-02 17:34:31 +00:00
Jarek Kobus
0a7f76ca8d VcsCommand: Get rid of setCookie()
Remove cookie arg from finished() signal, as it's not used
currently. Thus, remove setCookie() method.

Change-Id: Iedd328aece776eebd2d161a36ec28370b8bc4bfc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-02 09:00:01 +00:00
Jarek Kobus
0de4e9092f VcsCommand: Remove cookie() method
Change-Id: I2f83e141b05100c84c140d15a131e06ee62c6f68
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-01 17:25:59 +00:00
Jarek Kobus
83739bde38 VcsCommand: Merge with VcsCommandDecorator
Change-Id: I84df1779377648624984c9e57806f1307ae62b5b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-01 17:24:53 +00:00
Jarek Kobus
60302debd7 Move ShellCommand into VcsBase plugin
Rename it to VcsCommand. Move also ShellCommandPage into
VcsBase plugin.

Change-Id: I335ac47e3090f2be497643ebcda0eaad2987ac81
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-08-01 14:33:06 +00:00
Jarek Kobus
06023df8be VcsCommand: Move the class into vcsbaseclient.cpp
No need for a separate header.

Change-Id: I870ea0d9547829037644d79a286d87d4c77dc4ae
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-14 08:57:21 +00:00
Jarek Kobus
cb9ead8c8d VcsCommand: Remove m_preventRepositoryChanged field
Disconnect the appropriate connection instead.

Change-Id: Ie5cd8b3bcbab526aa770c493a465c9cdb07437f6
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-14 08:57:14 +00:00
Jarek Kobus
84de21b702 VcsCommand: Don't store the FutureProgress
Amends 9891a879aa

Change-Id: I164eda5935847343bf76bfbcf650ba372ccb6681
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-14 07:39:50 +00:00
Jarek Kobus
197ad524a6 ShellCommand: De-virtualize postRunCommand()
Provide runCommandFinished() signal instead.

Change-Id: I7c5e7d4aa484a7248dc369880343996e18c7c4b0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-14 07:39:44 +00:00
Jarek Kobus
c7f24f9f13 ShellCommand: De-virtualize addTask()
Provide executedAsync() signal instead.

Change-Id: I8f04dc90875e5f27827ea553a9f23f41656cc4db
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-14 07:39:37 +00:00
Jarek Kobus
85071d8e8d ShellCommand: De-virtualize environment()
Provide instead a protected setter, used in VcsCommand c'tor.

Remove a forceCLocale arg from setProcessEnvironment() method,
as it is used only in VcsCommand context when
ShellCommand::ForceCLocale flag was set. Move setting
C locale env directly to the shell command, just before
the command is executed, so that we are sure the flag
was already set.

Modify env directly in VcsCommand c'tor with regards to
SSH_ASKPASS variable.

Change-Id: Icff555ade4984368f7ce79f762d1bb5d3614076a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-13 19:29:10 +00:00
Jarek Kobus
89e7201048 VcsBase: Hide VcsCommand class
Make it an implementation detail.
Introduce VcsBaseClient::createVcsCommand() method instead
for instantiating VcsCommands.

Replace all occuriences of VcsBase::VcsCommand in public API
with Utils::ShellCommand.

Change-Id: Ie438cc3a5e867b3ee8f9e935b56b2f16ea453f8a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-13 16:01:28 +00:00
Jarek Kobus
0490e3426d ShellCommand: Merge VcsCommand::VcsRunFlags into RunFlags
Use ShellCommand class name in signal-slot connections.

Change-Id: Id50ee6887708558a2ba0972ece6c420b0be36f72
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-12 14:49:10 +00:00
Jarek Kobus
e3da02248a ShellCommand: De-virtualize runCommand()
Add virtual postRunCommand() method, called
by the end of runCommand().

In this way the rest of the API of VcsCommand remains
an implementation detail.

Change-Id: Ia4149334bd39a1448266d2406e0987bee07a9c58
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-12 14:49:00 +00:00
Jarek Kobus
cea7be0486 VcsBase: Remove some ssh related methods
Remove VcsCommand::m_sshPrompt, as it is always taken
from settings.

Change-Id: I9f46bb5a9de03e907f2098ca72a647c969e55a27
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-12 11:04:29 +00:00
Jarek Kobus
975baf23ac ShellCommand: Make processEnvironment() protected
Rename it to environment().

Change-Id: Ib393ea09d324cbd86b0b74ac928fcb37f243f8fc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-12 11:04:23 +00:00
Jarek Kobus
e793841b4f Remove Core::ShellCommand
Move the implementation into VcsCommand.
Use Utils::ShellCommand inside coreplugin API.

Change-Id: I74a34057b33832a138b05f1dfa6937565027edb4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-07-11 10:04:08 +00:00
hjk
bbde6ac9bf VCS: Use more FilePath in ShellCommand and surroundings
Change-Id: Ie8c5fac09b45a54bcbe9a876044b653e7fccede5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-17 07:16:04 +00:00
hjk
ff57cb548d Vcs: Use more FilePath for file paths
Change-Id: I855cde65d034a9647972a7fddf1e8266d7ccfa88
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-08-02 14:40:33 +00:00
hjk
430e81facd All: Replace most SynchronousProcess by QtcProcess
Change-Id: I0bf22fef2cd4a7297ef5a1e9aa9c3e2b9348ba42
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-23 07:55:31 +00:00
Jarek Kobus
bcd3feeaa7 Fix a possible crash on shutdown while executing VcsCommand
Add a global synchronizer to the VcsPlugin.

Fixes: QTCREATORBUG-25744
Change-Id: I97578f4a5b5275071aa0253a22fc9ab2f90d9b75
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-06-08 07:12:30 +00:00
Eike Ziller
a3391e7b33 Improve safety of VcsCommand
Amends 6e85ff9f4b

Using "invokeMethod(m_outputWindow, ..." has the disadvantage that it
crashes if m_outputWindow was deleted. This is nicely handled when
connecting to signals, so switch back to signals.

Change-Id: I6a681ac48a86536fa8e69e42d3c61ffa9d30c3d5
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-06-08 06:37:04 +00:00
Eike Ziller
ee61b09b21 GitGrep: Do not access global state from non-main thread
- VcsCommand calls into VcsOutputWindow at construction, so we need to
  construct it in the main thread
- VcsCommand may not call into global settings from runCommand, so we
  need to store the ssh prompt command
- accessing the GitClient singleton in a non-main thread is not
  thread-safe

Change-Id: I3dcdff8091c2dcea1c165ce5b3eca5ef62d474fd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-06-08 06:36:53 +00:00
Jarek Kobus
6e85ff9f4b Get rid of OutputProxy in ShellCommand
Before we have used the OutputProxyFactory, which
was called in the non-gui thread. The factory, when run,
created the connection between the thread and outside
world (e.g. VersionControl output window). Instead of
setting the factory we provide a set of virtual functions
called directly from non-gui threads. We also provide overrides
for them in VcsCommand class. Their implementation
safely redirects the calls directly to the VcsOutputWindow
through the QMetaObject::invokeMethod() with auto connection
as a default.

Task-number: QTCREATORBUG-25744
Change-Id: I09f2da278003b71095e953a51499a5513cb8f03f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-07 10:44:31 +00:00
hjk
73c0175f4b Vcs: Simplify VcsCommand::runCommand interface
The timeout and exit code interpreter properties are already
accessible via the SynchronousProcess parameter.

Change-Id: I1ba9c768a781009df65b5070a1d017c41d7e2663
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-05-17 09:10:49 +00:00
hjk
55f768e1b0 Utils: Make process results accessible through QtcProcess object
The result is fully stored in the object anyway. Using the extra
SynchronousProcessResponse structure only causes copies of
the data and complicates access on the user side in
a lot of cases.

The result bits are now also accessible individually.

There's obvious room for follow-up changes on the topic, e.g.
ShellCommand::runCommand's parameter list could shrink to
just a SynchronousProcess parameter.

Change-Id: I45aa7eb23832340be06905929280c012e1217263
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-14 13:19:01 +00:00
hjk
0c8d8c6b2a Utils: Don't expose Utils::defaultExitCodeInterpreter
Instead, make its behavior implicit if none is given.

Change-Id: I3c1a054751a0afe22d0f40a2fed6dd00b5aef205
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-11 13:15:25 +00:00
hjk
c262f40b67 Utils: Re-do Replace SynchronousCommand::flags by a named bool
The potential extensibility was never used, and a similar use case
in QtcProcess (setLowPriority()) used a named setter.

Change-Id: I87d84ea2206995d5069265f8df78f40cf2ba8a36
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2021-05-07 14:09:56 +00:00
hjk
635993fbdc Revert "Utils: Replace SynchronousCommand::flags by a named bool"
This reverts commit c617632e4d9291f1b50ec0c7e1a914a6a689284e.

To early, dependencies missing.

Change-Id: I91433aebbaf2c04cbb212585deb3cde5f3208974
Reviewed-by: hjk <hjk@qt.io>
2021-05-07 08:35:58 +00:00