forked from qt-creator/qt-creator
VCS[git], CodePaster: Add support for applying patches.
Modify CodePaster::fetch to do a mimetype detection on the content, create a filename with the matching extension and open that file. This gives correct syntax highlighting and makes "Save as" more convenient. Keep the file around and delete on exit. Modify patch mimetype with some content detection (higher priority than C++). Add a "current patch file" to the VCSBasePlugin::State. Add "Apply patch" to git with whitespace fix.
This commit is contained in:
@@ -973,6 +973,26 @@ bool GitClient::synchronousCleanList(const QString &workingDirectory,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
|
||||
const QString &file, QString *errorMessage)
|
||||
{
|
||||
if (Git::Constants::debug)
|
||||
qDebug() << Q_FUNC_INFO << workingDirectory;
|
||||
QStringList args;
|
||||
args << QLatin1String("apply") << QLatin1String("--whitespace=fix") << file;
|
||||
QByteArray outputText;
|
||||
QByteArray errorText;
|
||||
const bool rc = synchronousGit(workingDirectory, args, &outputText, &errorText);
|
||||
if (rc) {
|
||||
if (!errorText.isEmpty())
|
||||
*errorMessage = tr("There were warnings while applying %1 to %2:\n%3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText));
|
||||
} else {
|
||||
*errorMessage = tr("Unable apply patch %1 to %2: %3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Factory function to create an asynchronous command
|
||||
GitCommand *GitClient::createCommand(const QString &workingDirectory,
|
||||
VCSBase::VCSBaseEditor* editor,
|
||||
|
||||
Reference in New Issue
Block a user