Commit Graph

561 Commits

Author SHA1 Message Date
Andre Hartmann
c0d7835022 Git: Stop Instant Blame when git returns empty blame data
That can happen for example, when having a file with active
Instant Blame open and choosing "Save As" to save a copy
of that file in a folder not under version control.

Also fix the related case, when the file is saved in the
same folder, but is not under version control yet.
In this case, let's remove the blame mark, otherwise it
will stay forever as we only stopped the cursor connection.

Fixes: QTCREATORBUG-29991
Change-Id: I6ffed869c18334ba87dbcded409d31ead21f4b25
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-12-04 13:07:45 +00:00
Eike Ziller
ad7d559028 Tr: More small fixes
Change-Id: I5d9324d3f64eaa522fa1d435efa39fa43d84798a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-10-18 12:10:45 +00:00
Cristian Adam
d3dcb894e8 Git: Use a hyperlink for the git sha1
This way it's clear how you should get to the commit.

Change-Id: I6131ffab1855d686828137fb608d3edc57846cf5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-19 17:52:13 +00:00
Eike Ziller
dab19c4a8c Use Nanotrace to generate startup performance report
Add various trace points to the code, including the plugin
initialization methods (centrally in plugin manager), code that is
scheduled on the event loop with QTimer::singleShot or
QMetaObject::invokeMethod during initialization, and code that is
triggered from ICore::coreOpened

Can be turned on by configuring with `BUILD_LIBRARY_NANOTRACE=ON`
Run with `-trace <file>` to write trace file. If Nanotrace is not built,
the added code expands to nothing.

Changes in Nanotrace:
- turned generated data to microseconds instead of nanoseconds, because
  that is what Chrome tracing expects
- fixed serialization of duration (needs to be an item of the event, not
  in a "arg" subitem)
- fixed shutdown() to reset the initEvent

Change-Id: I994de82023b820d771e1be0a859ebd8da0b73d4d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-12 07:32:07 +00:00
Orgad Shaneh
4ad3925da4 Merge remote-tracking branch 'origin/11.0'
Change-Id: I5cdff1f5db3fae89beef3d27316b21440541bb1c
2023-07-30 16:24:15 +03:00
Andre Hartmann
e49ac10cb1 Git: Ignore irrelevant changes in instant blame
Optionally ignore whitespace changes or line
moves to only show the last real code changes.

Feature is disabled by default.

Fixes: QTCREATORBUG-29378
Change-Id: Ia2d5ad926f4098554b1ed3365bffadd4e2063e8e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-07-28 11:10:40 +00:00
hjk
778a1d75ba Git: Initialize GitClient on first access
This does not change the current timing of construction a lot as
the GerritPlugin may need it immediately in some cases, in any
case the gitGrep instance will need it.

There's nothing big going on at destruction time, so the prolonged
lifetime until really close to the end does not hurt.

The reason here is that this way we will avoid cases like in change
5e5b90a9a1.

Change-Id: I326d83c1a3d21114322ac6cce8d9e9b782faacdc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-07-26 10:25:43 +00:00
hjk
5e5b90a9a1 Git: Switch order of GitClient and GerritPlugin construction
The GerritPlugin constructor calls GerritParameters::fromSettings()
which then calls calls detectApp() if there is no curl (or no ssh/GIT_SSH).
On Windows this ends up calling GitClient::instance()->gitBinDirectory()
which crashes as the GitClent instance does not exist at this time.

Work around by switching the construction order.

Change-Id: I0b1172d6b7ec96502a51684578b78042a42a95ca
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-07-25 15:43:13 +00:00
Jarek Kobus
481d301c5c GitPlugin: Replace QVector with QList
Change-Id: I20218a5fcd9b4af6e6633de55d41d4ba771bcd75
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-07-18 20:48:28 +00:00
hjk
9a69c78ca5 Vcs: Convert settings pages to latest style
Last change in that area for this year.

Change-Id: Ibae9f1869cb20faf85c0c1669b84751ad022b8fd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-07-18 12:15:07 +00:00
Andre Hartmann
af5a8fe80c Git: Restart instant blame on document save
When the current line is modified, refresh the
blame after saving. Before, the cursor had to
be moved to another line to restart the blame.

Change-Id: I61012f1c8583545b9bc34a71ff63ade2f9cc5b13
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-07-17 11:38:37 +00:00
hjk
93d96c9d75 Vcs: Code cosmetics
Drop some Utils:: and rely on some aspects' operator()()

Change-Id: I40d2c2973c1c9eff443bb74b8da44e0824d8d5c6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-07-14 09:53:50 +00:00
hjk
379e7f906e Utils: Rework aspect implementation
This avoids some repetition and could be a step towards
having type storage in (or rather accessible from) the base,
so we can have aspects for more complex data (treemodels...)
that are not easily converted to QVariant.

Change-Id: I9797b3d5646195705212db1830d2b415291ac651
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-29 11:25:44 +00:00
Andre Hartmann
419f5416c5 Git: Avoid main loop blocking in instant blame
Query the author and encoding information asynchronous
after the current repository is changed.

Set the default codec to UTF-8, which should cover most
configurations (i.e. almost never be different).

In case requesting the information takes longer, the blame
mark is already created with the cached information.

In case the author or encoding changed, the blame mark
has to be recreated.

The call to refreshWorkingDirectory() is moved after the
widget checks in setupInstantBlame() to avoid requesting
these information in VCS editors.

Fixes: QTCREATORBUG-29151
Change-Id: I6feccbbed67c877f1015295f630dd63cf3ccf4a0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-05-29 06:06:54 +00:00
hjk
6f31d87444 Use more FilePathAspect
Change-Id: Ib348df1460f8610607251498b07010df58d51ddf
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-05-19 15:07:17 +00:00
Andre Hartmann
29371dc2f3 Git: Cache author and encoding for instant blame
Querying both may be expensive and is only
necessary when the repository is changed.

Fixes: QTCREATORBUG-29151
Change-Id: I1d37f8b8708c02a8c3dc2d89fe7e331f0f416818
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-05-17 07:06:05 +00:00
Andre Hartmann
ac0f273081 Git: Fix missing instant blame with line folding
When lines are folded (e.g. the license header),
the editors lineCount() is smaller than its
blockCount(). That resulted in missing blame marks
for the last document lines. E.g. if 10 lines were
folded, the last 10 lines did not have blame marks.

Change-Id: I502afb09697fd3d6a062d3ae2321357a3e565a0e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-17 07:05:33 +00:00
hjk
ce7ee677d8 Vcs: Use PagedSettings for all plugin settings
Hopefully the last structural change for a while.

Settings lifetime is again tied to the plugin private.

Change-Id: I221e8b8baa69422306191b48a9f034ef5b1a0dc2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-05-15 13:11:05 +00:00
hjk
545a105634 Git: Also use the latest settings setup approach
Change-Id: I34a210575d02d18927c1e0f6d8ea6cb9924c563d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-05-15 13:09:47 +00:00
hjk
3f1a75eacc Git: Small simplification to Gerrit "plugin" setup
The indirection is not needed. It's not really stand-alone, and not
touched before GitPlugin::initialize().

Change-Id: If8552dc69ff9efa18a3f1d6d998a8f28ab65e501
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-05-08 13:25:48 +00:00
Orgad Shaneh
2c61eac1cb Git: Change default shortcuts for "Current Project" to Repository
Current Project is misleading. Current Repository refers to the
repository of the current file, which is much more expected for
"everything around" actions (Diff, Log).

Task-number: QTCREATORBUG-10170
Change-Id: I252f40cd3dfd9de184a889355b59f91bb64983dd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-05-08 06:29:59 +00:00
Jarek Kobus
a3a5b8f806 Utils: Rename asynctask.{cpp,h} -> async.{cpp,h}
Follows AsyncTask -> Async rename.

Change-Id: I37f18368ab826c9960a24087b52f6691bb33f225
Reviewed-by: hjk <hjk@qt.io>
2023-05-03 13:24:20 +00:00
Jarek Kobus
7ab0fd56ae RunExtensions: Move onResultReady and onFinished into asynctask.h
Change-Id: I96dbf5b0253251224ae678172cd5fca12b34326a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-17 09:10:33 +00:00
Andre Hartmann
b9af26adf3 Git: Fix soft asserts on failing instant blame
When git blame returns no output, silently avoid creating
annotations instead flooding soft asserts.

This situation can easily happen when navigating to a
header file that is not under version control.

Fixes: QTCREATORBUG-28768
Change-Id: I8d2f443dec98575221995a9016bd2f8442c682cf
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-02-19 14:56:14 +00:00
Andre Hartmann
86ffc29239 Git: Avoid passing strings to resolve text encodings
Therefore, merge the code of codecFor() and encoding()
to avoid further mis-usage.

Change-Id: I086e4ace6c791d16f43f14c423b6529ad199c456
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-01-30 17:51:47 +00:00
Andre Hartmann
61fab0b736 Git: Fix instant blame text encoding
Fixes: QTCREATORBUG-28728
Change-Id: I875488badc84b664eaa1223b37657dcb417157de
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-01-30 12:32:03 +00:00
hjk
2336ff5570 Git: Some more FilePath proliferation
Change-Id: I8d3d97d0c7979d741a7da333f922ce93359afef8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-01-23 07:15:17 +00:00
hjk
013ad1345e VcsBase: Proliferate use of FilePath
... and update user code.

Change-Id: I52c08e9e07238536d31fc72f97312ac582a1e32f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-01-20 12:02:32 +00:00
hjk
17b20e0622 TextEditor: Tr::tr
Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-18 07:02:12 +00:00
David Schulz
baa1e3c2e1 Editor: Allow to hide annotations for a group of text marks
The hiding is not persistent, so on the next Qt Creator start all
annotations are visible again. This is meant to quickly get rid of
annotations if there are to many irrelevant of a specific kind.

Change-Id: I4862e56e0f5624f30aadda26efc9dea672ab1f57
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-12 10:19:10 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Jarek Kobus
ce161d0b16 VcsBase & dependent: Fix const correctness
And some minor cleanups.

Change-Id: Id0c2df6865ba84c054f0fb97c0ac42a76a128355
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-12-14 16:57:14 +00:00
Orgad Shaneh
038847709c Git: Suppress all output for instant blame
Change-Id: I5ad295cef22d0448f79d9187df85b582287b2835
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-12-14 11:54:05 +00:00
Orgad Shaneh
2119dd4397 Git: Do not show progress bar and the command on instant blame
Change-Id: I22d06d0359d82d086062be4990b51858754b9145
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-12-14 11:04:18 +00:00
Jarek Kobus
32e824c762 VcsBase: Don't return editor from annotate()
Take int firstLine as last arg instead. Switch the order of
3rd and 4th args as most callers provide lineNumber
and don't provide revision.

Change-Id: Iab60c1068a4d9829d10219af39bf3dcbf51e37bb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-12-11 11:15:15 +00:00
Jarek Kobus
8d7ced7d83 VcsBase: Get rid of CommandOutputBindMode
Simplify createCommand() implementation. All callers
passed either non-null editor (in this case the
bindMode was always NoBind) or passed a null editor and one
of two values for bindMode (in this case the only
effect was to add (or not) a RunFlags::ShowStdOut flag).

Drop CommandOutputBindMode enum completely and pass
directly RunFlags::ShowStdOut when needed (i.e. in cases
we were passing CommandOutputBindMode::ToVcsWindow).

Change-Id: Ic3af05818933a03f615ba02267403b9f0bd326ba
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-12-09 13:24:34 +00:00
Jarek Kobus
112835922a VcsBase: Reuse CommandOutputBindMode instead of bool
Reuse it inside vcsExec() and vcsExecWithHandler().

Change-Id: I6ff4044bf43e0883fc46a49718f5f44da87a7e13
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-12-09 10:29:51 +00:00
Jarek Kobus
287a7c9268 VcsBase: Introduce vcsExecWithHandler()
Before, vcsExec() returned already started VcsCommand.
Later, callers of vcsExec() were establishing connections
to the retured VcsCommand::done() signal. However, when
process fails to start (e.g. because of non-existing
executable), the done() signal may be emitted synchonously
from inside VcsCommand::start(). In this scenario
callers of VcsCommand could miss the emission of done()
signal and connect to already finished command.

Instead, provide a vcsExecWithHandler() function which
takes a handler to be called when command finished.
In addition it takes the context object, too.
Don't return VcsCommand from vcsExec() anymore.

Change-Id: I2fb5fbe5d27632ea039c650d37e5d7d1b60cebc0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-12-09 10:29:04 +00:00
Jarek Kobus
0313470db0 VcsBase: Pass context object to lambda connections
Remove some unneeded lambda () brackets.

Change-Id: I20e43625793401544e86efb627f5921c395026bb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-07 21:54:39 +00:00
Andre Hartmann
8e5c84e3dd Git: Disable instant blame for modified files
Change-Id: Iae24a8bbcbdb3663367ee863e8cc27ad92942e17
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-28 14:37:11 +00:00
Orgad Shaneh
a2baeea394 Git: Enable instant blame only if current file is managed
If the current project is Git managed, but the user opens a header from an
unmanaged directory, don't try to run blame.

Change-Id: I563f7a687b2ea03f4c03bf97c8f5c27c1f8411ec
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-11-22 16:43:36 +00:00
Orgad Shaneh
3a7fee0cc6 Git: Fix crash when closing last editor
before instant blame was activated.

Change-Id: I8a8acf6dc58cb25f7c10c1dfa08e3b7f6bae3e76
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-11-21 15:53:13 +00:00
Orgad Shaneh
252179b938 Git: Stop blame attempts for unmanaged files in the repository
A file that is in the repository directory, but not managed by Git should
not attempt to run instant blame on every cursor change.

Change-Id: Ia7daa2ae9980cea4363e010a98fb1e2f2a3ec05f
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-11-21 15:49:56 +00:00
Andre Hartmann
4d63f2a598 Git: use unique_ptr for instant blame marks
Also simplifies the code.

Change-Id: I5da0aeb86ba5a28c9016cde11aab9dcee922d908
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-11-21 15:46:00 +00:00
Andre Hartmann
cae1936da3 Git: Add instant line annotation (blame)
Inspired by the Visual Studio Code plugin GitLens.

Add an annotation to the editor line the cursor
is  currently in. A tooltip contains the commit
data and allows to invoke git show for the commit.

When the automatic annotation is turned off, it can
still be forced for the current line with an action.
The default shortcut for this action is: Alt+G,Alt+I

Task-number: QTCREATORBUG-23299
Change-Id: I58eef9efcf531afb11470e5f5456e19f282b18d0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-11-19 16:30:29 +00:00
Orgad Shaneh
d63bfa4a29 VCS: Simplify submit editor accept/close flow
* Replace message box with an error on the output pane.
* Separate logic for accept and close.

Change-Id: Ib9fa201a1a67ee195086f7a22bc6678a9642452a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-10-25 19:19:40 +00:00
Orgad Shaneh
1593f869ed VCS: Remove "Commit" option when closing commit editor
Fixes: QTCREATORBUG-22233
Change-Id: I1270cc58a823b919475fc51ac5fc71b892b379b6
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-10-21 13:13:59 +00:00
Orgad Shaneh
890b85d17e VCS: Simplify promptSubmit a bit more
+ fix regression for Git, which allowed to commit invalid commits.

Amends commit 9b61e484be.

Change-Id: I7571863bb982bfae1aa040e08f8c68010b14b147
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-10-18 06:31:53 +00:00
Orgad Shaneh
9b61e484be VCS: Deduplicate some submit editor closing logic
Change-Id: I622f5703c222a48606fcca3b99e87f9398e6a815
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-10-17 16:37:26 +00:00
Orgad Shaneh
eaad78547c VCS: Remove "Prompt to submit" settings
Task-number: QTCREATORBUG-22233
Change-Id: Ifbfd738281066af7913357ff9e2466a6c983452c
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2022-10-17 16:37:17 +00:00