Commit c3eb4b66 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

VCS: Windows slash display fixing spree.

Task-number: QTCREATORBUG-1795
parent 87794fb3
......@@ -73,7 +73,8 @@ namespace CVS {
static inline QString msgCannotFindTopLevel(const QString &f)
{
return CVSPlugin::tr("Cannot find repository for '%1'").arg(f);
return CVSPlugin::tr("Cannot find repository for '%1'").
arg(QDir::toNativeSeparators(f));
}
static inline QString msgLogParsingFailed()
......
......@@ -488,7 +488,8 @@ bool GitClient::synchronousAdd(const QString &workingDirectory,
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString errorMessage = tr("Unable to add %n file(s) to %1: %2", 0, files.size()).
arg(workingDirectory, commandOutputFromLocal8Bit(errorText));
arg(QDir::toNativeSeparators(workingDirectory),
commandOutputFromLocal8Bit(errorText));
outputWindow()->appendError(errorMessage);
}
return rc;
......@@ -510,7 +511,7 @@ bool GitClient::synchronousDelete(const QString &workingDirectory,
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString errorMessage = tr("Unable to remove %n file(s) from %1: %2", 0, files.size()).
arg(workingDirectory, commandOutputFromLocal8Bit(errorText));
arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText));
outputWindow()->appendError(errorMessage);
}
return rc;
......@@ -563,8 +564,9 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
&& !output.contains(QLatin1String("Unstaged changes after reset")))) {
const QString stdErr = commandOutputFromLocal8Bit(errorText);
const QString msg = files.isEmpty() ?
tr("Unable to reset %1: %2").arg(workingDirectory, stdErr) :
tr("Unable to reset %n file(s) in %1: %2", 0, files.size()).arg(workingDirectory, stdErr);
tr("Unable to reset %1: %2").arg(QDir::toNativeSeparators(workingDirectory), stdErr) :
tr("Unable to reset %n file(s) in %1: %2", 0, files.size()).
arg(QDir::toNativeSeparators(workingDirectory), stdErr);
if (errorMessage) {
*errorMessage = msg;
} else {
......@@ -727,7 +729,7 @@ bool GitClient::synchronousShortDescriptions(const QString &workingDirectory, co
static inline QString msgCannotDetermineBranch(const QString &workingDirectory, const QString &why)
{
return GitClient::tr("Unable to retrieve branch of %1: %2").arg(workingDirectory, why);
return GitClient::tr("Unable to retrieve branch of %1: %2").arg(QDir::toNativeSeparators(workingDirectory), why);
}
// Retrieve head revision/branch
......@@ -749,7 +751,7 @@ bool GitClient::synchronousTopRevision(const QString &workingDirectory,
arguments << QLatin1String("log") << QLatin1String(noColorOption)
<< QLatin1String("--max-count=1") << QLatin1String("--pretty=format:%H");
if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText)) {
errorMessage = tr("Unable to retrieve top revision of %1: %2").arg(workingDirectory, commandOutputFromLocal8Bit(errorText));
errorMessage = tr("Unable to retrieve top revision of %1: %2").arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText));
break;
}
*revision = commandOutputFromLocal8Bit(outputTextData);
......@@ -899,7 +901,9 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory,
arguments << QLatin1String("save") << message;
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString msg = tr("Unable stash in %1: %2").arg(workingDirectory, commandOutputFromLocal8Bit(errorText));
const QString msg = tr("Unable stash in %1: %2").
arg(QDir::toNativeSeparators(workingDirectory),
commandOutputFromLocal8Bit(errorText));
if (errorMessage) {
*errorMessage = msg;
} else {
......@@ -1691,9 +1695,12 @@ bool GitClient::synchronousStashRestore(const QString &workingDirectory,
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString stdErr = commandOutputFromLocal8Bit(errorText);
const QString nativeWorkingDir = QDir::toNativeSeparators(workingDirectory);
const QString msg = branch.isEmpty() ?
tr("Unable to restore stash %1: %2").arg(workingDirectory, stdErr) :
tr("Unable to restore stash %1 to branch %2: %3").arg(workingDirectory, branch, stdErr);
tr("Unable to restore stash %1: %2").
arg(nativeWorkingDir, stdErr) :
tr("Unable to restore stash %1 to branch %2: %3").
arg(nativeWorkingDir, branch, stdErr);
if (errorMessage) {
*errorMessage = msg;
} else {
......@@ -1723,9 +1730,12 @@ bool GitClient::synchronousStashRemove(const QString &workingDirectory,
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString stdErr = commandOutputFromLocal8Bit(errorText);
const QString nativeWorkingDir = QDir::toNativeSeparators(workingDirectory);
const QString msg = stash.isEmpty() ?
tr("Unable to remove stashes of %1: %2").arg(workingDirectory, stdErr) :
tr("Unable to remove stash %1 of %2: %3").arg(stash, workingDirectory, stdErr);
tr("Unable to remove stashes of %1: %2").
arg(nativeWorkingDir, stdErr) :
tr("Unable to remove stash %1 of %2: %3").
arg(stash, nativeWorkingDir, stdErr);
if (errorMessage) {
*errorMessage = msg;
} else {
......@@ -1764,7 +1774,9 @@ bool GitClient::synchronousStashList(const QString &workingDirectory,
QByteArray errorText;
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
const QString msg = tr("Unable retrieve stash list of %1: %2").arg(workingDirectory, commandOutputFromLocal8Bit(errorText));
const QString msg = tr("Unable retrieve stash list of %1: %2").
arg(QDir::toNativeSeparators(workingDirectory),
commandOutputFromLocal8Bit(errorText));
if (errorMessage) {
*errorMessage = msg;
} else {
......
......@@ -187,7 +187,8 @@ static inline QString msgParentRevisionFailed(const QString &workingDirectory,
const QString &revision,
const QString &why)
{
return MercurialClient::tr("Unable to find parent revisions of %1 in %2: %3").arg(revision, workingDirectory, why);
return MercurialClient::tr("Unable to find parent revisions of %1 in %2: %3").
arg(revision, QDir::toNativeSeparators(workingDirectory), why);
}
static inline QString msgParseParentsOutputFailed(const QString &output)
......@@ -526,7 +527,8 @@ void MercurialClient::outgoing(const QString &repositoryRoot)
args << QLatin1String("outgoing") << QLatin1String("-g") << QLatin1String("-p");
const QString kind = QLatin1String(Constants::DIFFLOG);
const QString title = tr("Hg outgoing %1").arg(repositoryRoot);
const QString title = tr("Hg outgoing %1").
arg(QDir::toNativeSeparators(repositoryRoot));
VCSBase::VCSBaseEditor *editor = createVCSEditor(kind, title, repositoryRoot, true,
"outgoing", repositoryRoot);
......
......@@ -41,6 +41,7 @@
#include <QtCore/QProcessEnvironment>
#include <QtCore/QString>
#include <QtCore/QDebug>
#include <QtCore/QDir>
using namespace Mercurial::Internal;
using namespace Mercurial;
......@@ -151,7 +152,8 @@ void MercurialJobRunner::run()
QString MercurialJobRunner::msgStartFailed(const QString &binary, const QString &why)
{
return tr("Unable to start mercurial process '%1': %2").arg(binary, why);
return tr("Unable to start mercurial process '%1': %2").
arg(QDir::toNativeSeparators(binary), why);
}
QString MercurialJobRunner::msgTimeout(int timeoutSeconds)
......
......@@ -602,7 +602,8 @@ void MercurialPlugin::showCommitWidget(const QList<QPair<QString, QString> > &st
return;
}
const QString msg = tr("Commit changes for \"%1\".").arg(m_submitRepository);
const QString msg = tr("Commit changes for \"%1\".").
arg(QDir::toNativeSeparators(m_submitRepository));
commitEditor->setDisplayName(msg);
QString branch = m_client->branchQuerySync(m_submitRepository);
......
......@@ -35,6 +35,7 @@
#include <QtCore/QRegExp>
#include <QtCore/QTimer>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtGui/QApplication>
#include <QtGui/QCursor>
......@@ -108,7 +109,8 @@ void PerforceChecker::slotTimeOut()
return;
m_timedOut = true;
Utils::SynchronousProcess::stopProcess(m_process);
emitFailed(tr("\"%1\" timed out after %2ms.").arg(m_binary).arg(m_timeOutMS));
emitFailed(tr("\"%1\" timed out after %2ms.").
arg(m_binary).arg(m_timeOutMS));
}
void PerforceChecker::slotError(QProcess::ProcessError error)
......@@ -117,7 +119,8 @@ void PerforceChecker::slotError(QProcess::ProcessError error)
return;
switch (error) {
case QProcess::FailedToStart:
emitFailed(tr("Unable to launch \"%1\": %2").arg(m_binary, m_process.errorString()));
emitFailed(tr("Unable to launch \"%1\": %2").
arg(QDir::toNativeSeparators(m_binary), m_process.errorString()));
break;
case QProcess::Crashed: // Handled elsewhere
case QProcess::Timedout:
......@@ -136,12 +139,13 @@ void PerforceChecker::slotFinished(int exitCode, QProcess::ExitStatus exitStatus
return;
switch (exitStatus) {
case QProcess::CrashExit:
emitFailed(tr("\"%1\" crashed.").arg(m_binary));
emitFailed(tr("\"%1\" crashed.").arg(QDir::toNativeSeparators(m_binary)));
break;
case QProcess::NormalExit:
if (exitCode) {
const QString stdErr = QString::fromLocal8Bit(m_process.readAllStandardError());
emitFailed(tr("\"%1\" terminated with exit code %2: %3").arg(m_binary).arg(exitCode).arg(stdErr));
emitFailed(tr("\"%1\" terminated with exit code %2: %3").
arg(QDir::toNativeSeparators(m_binary)).arg(exitCode).arg(stdErr));
} else {
parseOutput(QString::fromLocal8Bit(m_process.readAllStandardOutput()));
}
......@@ -178,7 +182,8 @@ void PerforceChecker::parseOutput(const QString &response)
if (fi.exists()) {
emitSucceeded(repositoryRoot);
} else {
emitFailed(tr("The repository \"%1\" does not exist.").arg(repositoryRoot));
emitFailed(tr("The repository \"%1\" does not exist.").
arg(QDir::toNativeSeparators(repositoryRoot)));
}
}
......
......@@ -1089,7 +1089,9 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD
if (process.write(stdInput) == -1) {
Utils::SynchronousProcess::stopProcess(process);
response.error = true;
response.message = tr("Unable to write input data to process %1: %2").arg(m_settings.p4Command(), process.errorString());
response.message = tr("Unable to write input data to process %1: %2").
arg(QDir::toNativeSeparators(m_settings.p4Command()),
process.errorString());
return response;
}
process.closeWriteChannel();
......@@ -1403,7 +1405,8 @@ static inline QString msgWhereFailed(const QString & file, const QString &why)
{
//: Failed to run p4 "where" to resolve a Perforce file name to a local
//: file system name.
return PerforcePlugin::tr("Error running \"where\" on %1: %2").arg(file, why);
return PerforcePlugin::tr("Error running \"where\" on %1: %2").
arg(QDir::toNativeSeparators(file), why);
}
// Map a perforce name "//xx" to its real name in the file system
......@@ -1458,7 +1461,9 @@ PerforceVersionControl *PerforcePlugin::perforceVersionControl() const
void PerforcePlugin::slotTopLevelFound(const QString &t)
{
m_settings.setTopLevel(t);
VCSBase::VCSBaseOutputWindow::instance()->appendSilently(tr("Perforce repository: %1").arg(t));
const QString msg = tr("Perforce repository: %1").
arg(QDir::toNativeSeparators(t));
VCSBase::VCSBaseOutputWindow::instance()->appendSilently(msg);
if (Perforce::Constants::debug)
qDebug() << "P4: " << t;
}
......
......@@ -71,7 +71,7 @@ void SettingsPageWidget::slotTest()
void SettingsPageWidget::testSucceeded(const QString &repo)
{
setStatusText(tr("Test succeeded (%1).").arg(repo));
setStatusText(tr("Test succeeded (%1).").arg(QDir::toNativeSeparators(repo)));
}
Settings SettingsPageWidget::settings() const
......
......@@ -159,7 +159,8 @@ QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessa
// Search the directory for project files
const QDir dir(path);
if (!dir.exists()) {
*errorMessage = tr("'%1' does not exist.").arg(path); // Should not happen
*errorMessage = tr("'%1' does not exist.").
arg(QDir::toNativeSeparators(path)); // Should not happen
return QString();
}
QFileInfoList projectFiles = findProjectFiles(dir, errorMessage);
......@@ -168,7 +169,8 @@ QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessa
// Open. Do not use a busy cursor here as additional wizards might pop up
const QString projectFile = projectFiles.front().absoluteFilePath();
if (!pe->openProject(projectFile)) {
*errorMessage = tr("Unable to open the project '%1'.").arg(projectFile);
*errorMessage = tr("Unable to open the project '%1'.").
arg(QDir::toNativeSeparators(projectFile));
return QString();
}
return projectFile;
......
......@@ -32,6 +32,7 @@
#include <vcsbaseplugin.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <utils/synchronousprocess.h>
enum { debug = 0 };
......@@ -111,7 +112,8 @@ void ProcessCheckoutJob::slotError(QProcess::ProcessError error)
{
switch (error) {
case QProcess::FailedToStart:
emit failed(tr("Unable to start %1: %2").arg(d->binary, d->process->errorString()));
emit failed(tr("Unable to start %1: %2").
arg(QDir::toNativeSeparators(d->binary), d->process->errorString()));
break;
default:
emit failed(d->process->errorString());
......
......@@ -65,13 +65,15 @@ static void removeFileRecursion(const QFileInfo &f, QString *errorMessage)
removeFileRecursion(fi, errorMessage);
QDir parent = f.absoluteDir();
if (!parent.rmdir(f.fileName()))
errorMessage->append(VCSBase::CleanDialog::tr("The directory %1 could not be deleted.").arg(f.absoluteFilePath()));
errorMessage->append(VCSBase::CleanDialog::tr("The directory %1 could not be deleted.").
arg(QDir::toNativeSeparators(f.absoluteFilePath())));
return;
}
if (!QFile::remove(f.absoluteFilePath())) {
if (!errorMessage->isEmpty())
errorMessage->append(QLatin1Char('\n'));
errorMessage->append(VCSBase::CleanDialog::tr("The file %1 could not be deleted.").arg(f.absoluteFilePath()));
errorMessage->append(VCSBase::CleanDialog::tr("The file %1 could not be deleted.").
arg(QDir::toNativeSeparators(f.absoluteFilePath())));
}
}
......@@ -107,7 +109,8 @@ void CleanFilesTask::run()
removeFileRecursion(QFileInfo(name), &m_errorMessage);
if (!m_errorMessage.isEmpty()) {
// Format and emit error.
const QString msg = CleanDialog::tr("There were errors when cleaning the repository %1:").arg(m_repository);
const QString msg = CleanDialog::tr("There were errors when cleaning the repository %1:").
arg(QDir::toNativeSeparators(m_repository));
m_errorMessage.insert(0, QLatin1Char('\n'));
m_errorMessage.insert(0, msg);
emit error(m_errorMessage);
......@@ -157,7 +160,8 @@ CleanDialog::~CleanDialog()
void CleanDialog::setFileList(const QString &workingDirectory, const QStringList &l)
{
d->m_workingDirectory = workingDirectory;
d->ui.groupBox->setTitle(tr("Repository: %1").arg(workingDirectory));
d->ui.groupBox->setTitle(tr("Repository: %1").
arg(QDir::toNativeSeparators(workingDirectory)));
if (const int oldRowCount = d->m_filesModel->rowCount())
d->m_filesModel->removeRows(0, oldRowCount);
......@@ -235,7 +239,8 @@ bool CleanDialog::promptToDelete()
Qt::QueuedConnection);
QFuture<void> task = QtConcurrent::run(cleanTask, &CleanFilesTask::run);
const QString taskName = tr("Cleaning %1").arg(d->m_workingDirectory);
const QString taskName = tr("Cleaning %1").
arg(QDir::toNativeSeparators(d->m_workingDirectory));
Core::ICore::instance()->progressManager()->addTask(task, taskName,
QLatin1String("VCSBase.cleanRepository"));
return true;
......
......@@ -32,6 +32,7 @@
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtGui/QPushButton>
#include <QtGui/QStandardItemModel>
#include <QtGui/QSortFilterProxyModel>
......@@ -230,7 +231,8 @@ bool NickNameDialog::populateModelFromMailCapFile(const QString &fileName,
return true;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
*errorMessage = tr("Cannot open '%1': %2").arg(fileName, file.errorString());
*errorMessage = tr("Cannot open '%1': %2").
arg(QDir::toNativeSeparators(fileName), file.errorString());
return false;
}
// Split into lines and read
......@@ -241,7 +243,9 @@ bool NickNameDialog::populateModelFromMailCapFile(const QString &fileName,
if (entry.parse(lines.at(i))) {
model->appendRow(entry.toModelRow());
} else {
qWarning("%s: Invalid mail cap entry at line %d: '%s'\n", qPrintable(fileName), i + 1, qPrintable(lines.at(i)));
qWarning("%s: Invalid mail cap entry at line %d: '%s'\n",
qPrintable(QDir::toNativeSeparators(fileName)),
i + 1, qPrintable(lines.at(i)));
}
}
model->sort(0);
......
......@@ -156,7 +156,8 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
fi = QFileInfo(repository + QLatin1Char('/') + token);
if (fi.isFile()) {
menu->addSeparator();
openAction = menu->addAction(VCSBaseOutputWindow::tr("Open \"%1\"").arg(fi.fileName()));
openAction = menu->addAction(VCSBaseOutputWindow::tr("Open \"%1\"").
arg(QDir::toNativeSeparators(fi.fileName())));
openAction->setData(fi.absoluteFilePath());
}
}
......@@ -397,10 +398,11 @@ QString VCSBaseOutputWindow::msgExecutionLogEntry(const QString &workingDir,
const QStringList &arguments)
{
const QString args = formatArguments(arguments);
const QString nativeExecutable = QDir::toNativeSeparators(executable);
if (workingDir.isEmpty())
return tr("Executing: %1 %2\n").arg(executable, args);
return tr("Executing: %1 %2\n").arg(nativeExecutable, args);
return tr("Executing in %1: %2 %3\n").
arg(QDir::toNativeSeparators(workingDir), executable, args);
arg(QDir::toNativeSeparators(workingDir), nativeExecutable, args);
}
void VCSBaseOutputWindow::appendCommand(const QString &text)
......
......@@ -542,7 +542,10 @@ void VCSBasePlugin::promptToDeleteCurrentFile()
QTC_ASSERT(state.hasFile(), return)
const bool rc = Core::ICore::instance()->vcsManager()->promptToDelete(versionControl(), state.currentFile());
if (!rc)
QMessageBox::warning(0, tr("Version Control"), tr("The file '%1' could not be deleted.").arg(state.currentFile()), QMessageBox::Ok);
QMessageBox::warning(0, tr("Version Control"),
tr("The file '%1' could not be deleted.").
arg(QDir::toNativeSeparators(state.currentFile())),
QMessageBox::Ok);
}
static inline bool ask(QWidget *parent, const QString &title, const QString &question, bool defaultValue = true)
......@@ -576,12 +579,15 @@ void VCSBasePlugin::createRepository()
} while (true);
// Create
const bool rc = d->m_versionControl->vcsCreateRepository(directory);
const QString nativeDir = QDir::toNativeSeparators(directory);
if (rc) {
QMessageBox::information(mw, tr("Repository created"),
tr("A version control repository has been created in %1.").arg(directory));
tr("A version control repository has been created in %1.").
arg(nativeDir));
} else {
QMessageBox::warning(mw, tr("Repository creation failed"),
tr("A version control repository could not be created in %1.").arg(directory));
tr("A version control repository could not be created in %1.").
arg(nativeDir));
}
}
......
......@@ -549,9 +549,11 @@ bool VCSBaseSubmitEditor::checkSubmitMessage(QString *errorMessage) const
static inline QString msgCheckScript(const QString &workingDir, const QString &cmd)
{
const QString nativeCmd = QDir::toNativeSeparators(cmd);
return workingDir.isEmpty() ?
VCSBaseSubmitEditor::tr("Executing %1").arg(cmd) :
VCSBaseSubmitEditor::tr("Executing [%1] %2").arg(workingDir, cmd);
VCSBaseSubmitEditor::tr("Executing %1").arg(nativeCmd) :
VCSBaseSubmitEditor::tr("Executing [%1] %2").
arg(QDir::toNativeSeparators(workingDir), nativeCmd);
}
bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript, QString *errorMessage) const
......@@ -564,7 +566,9 @@ bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
QTemporaryFile messageFile(tempFilePattern);
messageFile.setAutoRemove(true);
if (!messageFile.open()) {
*errorMessage = tr("Unable to open '%1': %2").arg(messageFile.fileName(), messageFile.errorString());
*errorMessage = tr("Unable to open '%1': %2").
arg(QDir::toNativeSeparators(messageFile.fileName()),
messageFile.errorString());
return false;
}
const QString messageFileName = messageFile.fileName();
......@@ -586,11 +590,13 @@ bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
QByteArray stdErrData;
if (!Utils::SynchronousProcess::readDataFromProcess(checkProcess, 30000, &stdOutData, &stdErrData, false)) {
Utils::SynchronousProcess::stopProcess(checkProcess);
*errorMessage = tr("The check script '%1' timed out.").arg(checkScript);
*errorMessage = tr("The check script '%1' timed out.").
arg(QDir::toNativeSeparators(checkScript));
return false;
}
if (checkProcess.exitStatus() != QProcess::NormalExit) {
*errorMessage = tr("The check script '%1' crashed").arg(checkScript);
*errorMessage = tr("The check script '%1' crashed").
arg(QDir::toNativeSeparators(checkScript));
return false;
}
if (!stdOutData.isEmpty())
......@@ -600,7 +606,8 @@ bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
outputWindow->appendSilently(stdErr);
const int exitCode = checkProcess.exitCode();
if (exitCode != 0) {
const QString exMessage = tr("The check script returned exit code %1.").arg(exitCode);
const QString exMessage = tr("The check script returned exit code %1.").
arg(exitCode);
outputWindow->appendError(exMessage);
*errorMessage = stdErr;
if (errorMessage->isEmpty())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment