Commit a5a42c3f authored by Tobias Hunger's avatar Tobias Hunger Committed by Orgad Shaneh
Browse files

Vcs: Prettify output in CheckoutProgressWizardPage



Handle CR in the output of the VCS we are running in the checkout
wizards. This makes sure we get proper progress information when
running the checkout operation.

Note that this is not a perfect implementation: It will fail when
e.g. only a number at the start of the line is updated and the
rest of the text in the line is reused.

Task-number: QTCREATORBUG-10112
Change-Id: If742e5cb945a2fcada8319d08610d1ccc7fa2ae8
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 1bda0b3e
......@@ -54,6 +54,7 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
QWizardPage(parent),
ui(new Ui::CheckoutProgressWizardPage),
m_startedStatus(tr("Checkout started...")),
m_overwriteOutput(false),
m_state(Idle)
{
ui->setupUi(this);
......@@ -86,6 +87,7 @@ void CheckoutProgressWizardPage::start(Command *command)
connect(command, SIGNAL(finished(bool,int,QVariant)), this, SLOT(slotFinished(bool,int,QVariant)));
QApplication::setOverrideCursor(Qt::WaitCursor);
ui->logPlainTextEdit->clear();
m_overwriteOutput = false;
ui->statusLabel->setText(m_startedStatus);
ui->statusLabel->setPalette(QPalette());
m_state = Running;
......@@ -121,7 +123,20 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari
void CheckoutProgressWizardPage::slotOutput(const QString &text)
{
ui->logPlainTextEdit->appendPlainText(text.trimmed());
int startPos = 0;
int crPos = -1;
const QString ansiEraseToEol = QLatin1String("\x1b[K");
while ((crPos = text.indexOf(QLatin1Char('\r'), startPos)) >= 0) {
QString part = text.mid(startPos, crPos - startPos);
// Discard ANSI erase-to-eol
if (part.endsWith(ansiEraseToEol))
part.chop(ansiEraseToEol.length());
outputText(part);
startPos = crPos + 1;
m_overwriteOutput = true;
}
if (startPos < text.count())
outputText(text.mid(startPos));
}
void CheckoutProgressWizardPage::slotError(const QString &text)
......@@ -129,6 +144,18 @@ void CheckoutProgressWizardPage::slotError(const QString &text)
m_error.append(text);
}
void CheckoutProgressWizardPage::outputText(const QString &text)
{
if (m_overwriteOutput) {
QTextCursor cursor = ui->logPlainTextEdit->textCursor();
cursor.clearSelection();
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
ui->logPlainTextEdit->setTextCursor(cursor);
m_overwriteOutput = false;
}
ui->logPlainTextEdit->insertPlainText(text);
}
void CheckoutProgressWizardPage::terminate()
{
if (m_command)
......
......@@ -67,11 +67,14 @@ private slots:
void slotError(const QString &text);
private:
void outputText(const QString &text);
Ui::CheckoutProgressWizardPage *ui;
Command *m_command;
QString m_startedStatus;
QString m_error;
bool m_overwriteOutput;
State m_state;
};
......
......@@ -40,10 +40,10 @@ def verifyCloneLog(targetDir, canceled):
else:
cloneLog = str(waitForObject(":Git Repository Clone.logPlainTextEdit_QPlainTextEdit").plainText)
# test for QTCREATORBUG-10112
test.xcompare(cloneLog.count("remote: Counting objects:"), 1)
test.xcompare(cloneLog.count("remote: Finding sources:"), 1)
test.xcompare(cloneLog.count("Receiving objects:"), 1)
test.xcompare(cloneLog.count("Resolving deltas:"), 1)
test.compare(cloneLog.count("remote: Counting objects:"), 1)
test.compare(cloneLog.count("remote: Finding sources:"), 1)
test.compare(cloneLog.count("Receiving objects:"), 1)
test.compare(cloneLog.count("Resolving deltas:"), 1)
test.verify(not "Stopping..." in cloneLog,
"Searching for 'Stopping...' in clone log")
test.verify(("'" + cloneDir + "'..." in cloneLog),
......
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