forked from qt-creator/qt-creator
VCS: Use relative path for apply/revert chunk
Task-number: QTCREATORBUG-9715 Change-Id: I3bfaea3922ace396230ef5e215712a9f3459808b Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
db4ce016bc
commit
20e9b33741
@@ -98,9 +98,11 @@ bool DiffChunk::isValid() const
|
||||
return !fileName.isEmpty() && !chunk.isEmpty();
|
||||
}
|
||||
|
||||
QByteArray DiffChunk::asPatch() const
|
||||
QByteArray DiffChunk::asPatch(const QString &workingDirectory) const
|
||||
{
|
||||
const QByteArray fileNameBA = QFile::encodeName(fileName);
|
||||
QString relativeFile = workingDirectory.isEmpty() ?
|
||||
fileName : QDir(workingDirectory).relativeFilePath(fileName);
|
||||
const QByteArray fileNameBA = QFile::encodeName(relativeFile);
|
||||
QByteArray rc = "--- ";
|
||||
rc += fileNameBA;
|
||||
rc += "\n+++ ";
|
||||
@@ -1466,7 +1468,8 @@ bool VcsBaseEditorWidget::canApplyDiffChunk(const DiffChunk &dc) const
|
||||
// (passing '-R' for revert), assuming we got absolute paths from the VCS plugins.
|
||||
bool VcsBaseEditorWidget::applyDiffChunk(const DiffChunk &dc, bool revert) const
|
||||
{
|
||||
return VcsBasePlugin::runPatch(dc.asPatch(), QString(), 0, revert);
|
||||
return VcsBasePlugin::runPatch(dc.asPatch(d->m_diffBaseDirectory),
|
||||
d->m_diffBaseDirectory, 0, revert);
|
||||
}
|
||||
|
||||
QString VcsBaseEditorWidget::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
|
||||
|
||||
@@ -78,7 +78,7 @@ class VCSBASE_EXPORT DiffChunk
|
||||
{
|
||||
public:
|
||||
bool isValid() const;
|
||||
QByteArray asPatch() const;
|
||||
QByteArray asPatch(const QString &workingDirectory) const;
|
||||
|
||||
QString fileName;
|
||||
QByteArray chunk;
|
||||
|
||||
@@ -1056,7 +1056,7 @@ bool VcsBasePlugin::runPatch(const QByteArray &input, const QString &workingDire
|
||||
QStringList args(QLatin1String("-p") + QString::number(strip));
|
||||
if (reverse)
|
||||
args << QLatin1String("-R");
|
||||
ow->appendCommand(QString(), patch, args);
|
||||
ow->appendCommand(workingDirectory, patch, args);
|
||||
patchProcess.start(patch, args);
|
||||
if (!patchProcess.waitForStarted()) {
|
||||
ow->appendError(tr("Unable to launch '%1': %2").arg(patch, patchProcess.errorString()));
|
||||
|
||||
Reference in New Issue
Block a user