-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi file tool support #535
base: master
Are you sure you want to change the base?
Conversation
Extend DiffTool, MergeTool, EditTool, and ShowTool to support one or more files in each tool.
Avoid the inconvenience of having to close the drop-down list manually after checking out a branch. ...and format...
Using the workspace file as "merged" allows for the file to be edited in-place for the merge.
@gh-devnull sorry for the late review |
src/tools/MergeTool.cpp
Outdated
if (--numMergeFiles) { | ||
deleteLater(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be if (--numMergeFiles == 0) {}. Otherwise it will be called by every process you are creating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed? If you remove the "this" from the qprocess constructor and then deleting the process here might be less error prone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that makes sense. While the value of the processes created by start() may be diminished if gittyup exits before them, there appears to be no good reason to tie their lifetimes (and possibly stability) to gittyup's. I've removed "this" as a QProcess constructor parameter for MergeTool, DiffTool, and EditTool. ShowTool uses QProcess::startDetached() which has the same semantics in this regard so no change is required there.
b82d934
to
fb6218c
Compare
…r from the QProcess constructor for DiffTool.cpp, EditTool.cpp, and MergeTool.cpp so the external tool process lifetimes are not in anyway tied to gittup's lifetime. This simulates QProcess::startDetached() behavior.
…r from the QProcess constructor for DiffTool.cpp, EditTool.cpp, and MergeTool.cpp so the external tool process lifetimes are not in anyway tied to gittup's lifetime. This simulates QProcess::startDetached() behavior.
@Murmele - I have a subsequent patch to make on top of these. It resolves issues that occur when a multi-selection includes directories (from a tree view). Do you want me to add it here now or do you want to close out the changes so far? |
Hi @gh-devnull I would prefer creating a new mr for this, because they can be handled indipendently or? Sorry I am completely under right now. I hope I get to your mr soon |
OK, I'll keep the new patch local until this one finishes. |
…eration. When a directory is selected, all files within it, recursively, are added to the list of files selected. This is not really what the user intends (i.e. if the files are displayed as a tree and the user selects from the first to the last, the user really only wants to interact with the selected files, not all those in any selected directory). Introduce the AccumRepoFiles class to keep track of files actually selected by the user as well as those under any selected directory and provide a way to get either list individually or both file lists together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not test yet, what do you think about this?
|
||
int numFiles = mFiles.size(); | ||
foreach (const QString &filePathAndName, mFiles) { | ||
git::Blob filePathOld, filePathNew; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git::Blob filePathOld, filePathNew; | |
QProcess *process = new QProcess(); | |
git::Blob filePathOld, filePathNew; |
} | ||
|
||
// Destroy this after process finishes. | ||
QProcess *process = new QProcess(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QProcess *process = new QProcess(); |
// Get the path to the file (either a full or relative path). | ||
QString otherPathAndName = filePathAndName; | ||
if (filePathOld.isValid()) { | ||
otherPathAndName = makeBlobTempFullFilePath(filePathAndName, filePathOld); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherPathAndName = makeBlobTempFullFilePath(filePathAndName, filePathOld); | |
otherPathAndName = makeBlobTempFullFilePath(filePathAndName, filePathOld, process); |
if (--numFiles == 0) { | ||
deleteLater(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (--numFiles == 0) { | |
deleteLater(); | |
} | |
delete process; |
if (!process->waitForStarted()) { | ||
qDebug() << "DiffTool starting failed"; | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
deleteLater(); |
} | ||
|
||
QString DiffTool::makeBlobTempFullFilePath(const QString &filePathAndName, | ||
const git::Blob &fileBlob) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const git::Blob &fileBlob) { | |
const git::Blob &fileBlob, QObject* parent) { |
|
||
QFileInfo fileInfo(filePathAndName); | ||
QString templatePath = QDir::temp().filePath(fileInfo.fileName()); | ||
QTemporaryFile *temp = new QTemporaryFile(templatePath, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QTemporaryFile *temp = new QTemporaryFile(templatePath, this); | |
QTemporaryFile *temp = new QTemporaryFile(templatePath, parent); |
git::Blob &blob) const; | ||
|
||
QString makeBlobTempFullFilePath(const QString &filePathAndName, | ||
const git::Blob &fileBlob); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const git::Blob &fileBlob); | |
const git::Blob &fileBlob, QObject* parent); |
process->start(git::Command::substitute(env, command)); | ||
} else { | ||
emit error(BashNotFound); | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false; | |
delete process; | |
return false; |
return false; | ||
if (!process->waitForStarted()) { | ||
qDebug() << "DiffTool starting failed"; | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false; | |
delete process; | |
return false; |
The idea is that QProcess will be detached and the QTemporaryFile will be deleted once the QProcess will be deleted. So the MergeTool/DiffTool Object can be deleted indipendently |
Sure, that looks like it's an incremental improvement on the existing logic. You'd want similar logic changes for MergeTool and EditTool too. |
editor.remove("\""); | ||
|
||
// Destroy this after process finishes. | ||
QProcess *process = new QProcess(this); | ||
QProcess *process = new QProcess(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have to be carefull here, because without parent, the process object has to be deleted manually.
If you pass a parent, the Destructor of the parent will delete all childs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that accounts for the cryptic comment. 😉 I'll review this.
Yes this would be nice. Maybe you can move |
Yes, I was thinking there may be some refactoring that could be done for this too. Is there anything else that you want to see before you accept this mr? I'm not against iterating further to improve code maintainability and readability but I'd also like to finish off at least the first round of this functionality particularly because I have a dependent change affecting user-visible functionality already waiting. |
No I think this is all. Moving this temp file function into external tools and then executing the process. So it is independent of the rest of the gui application. |
OK, I'll investigate tool/process lifetime dependencies and interactions. |
Thank you. Refactoring is here just needed, because I don't like this counter counting down and it is not much more work to change. |
@gh-devnull can I help you somehow? |
@Murmele - Sorry, I did spend some further time on this but the work is incomplete and I haven't had a chance to finish it yet. |
@gh-devnull don't rush. When it is finish, it is finish 😃 thanks for working on it! |
3c92cc0 ("Adds "Hide Untracked Files" option to DoubleTreeWidget cogwheel context menu", 2023-07-02) pvacatel a80ffed ("Fixes code format according to clang-format", 2023-07-03) pvacatel b202f1a ("Reverts format changes to test/Settings.cpp", 2023-07-04) pablov 0a935f8 ("enable debug build by setting a settings Reason: so the debug possibility is always available and is by default off for performance reason", 2023-07-14) Martin Marmsoler 198fb7a ("Update src/app/Application.cpp", 2023-07-14) Martin Marmsoler
1e57e7d ("Spanish translation", 2023-06-17) José Miguel Manzano 3c92cc0 ("Adds "Hide Untracked Files" option to DoubleTreeWidget cogwheel context menu", 2023-07-02) pvacatel a80ffed ("Fixes code format according to clang-format", 2023-07-03) pvacatel b202f1a ("Reverts format changes to test/Settings.cpp", 2023-07-04) pablov 0a935f8 ("enable debug build by setting a settings Reason: so the debug possibility is always available and is by default off for performance reason", 2023-07-14) Martin Marmsoler 198fb7a ("Update src/app/Application.cpp", 2023-07-14) Martin Marmsoler
…as a list in TreeViews. Resolves Dense layout issue Murmele#547
Conflicts: .gitignore src/ui/FileContextMenu.cpp
Extend DiffTool, MergeTool, EditTool, and ShowTool to support one or more files in each tool.
Each of these tools is extended to handle multiple files as input, allowing the user to handle all the files in one instance of the external tool, if the external tools supports this. An example would be diffing multiple files, one per tab, in one session of meld (or other diff application that allows similar tab-like behavior).