summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2014-03-07 14:23:54 +0100
committerOrgad Shaneh <orgads@gmail.com>2014-03-18 13:34:29 +0100
commita5a42c3f67570809fca3970d40b0ddf71269c74d (patch)
tree632b679aa9cb2836df276a528225e7e999fb13e2
parent1bda0b3ec1188552a6c3fae810947a0bce6783fc (diff)
downloadqt-creator-a5a42c3f67570809fca3970d40b0ddf71269c74d.tar.gz
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: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r--src/plugins/vcsbase/checkoutprogresswizardpage.cpp29
-rw-r--r--src/plugins/vcsbase/checkoutprogresswizardpage.h3
-rw-r--r--tests/system/suite_tools/tst_git_clone/test.py8
3 files changed, 35 insertions, 5 deletions
diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp
index b319e3f97b..e188f5391d 100644
--- a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp
+++ b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp
@@ -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)
diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.h b/src/plugins/vcsbase/checkoutprogresswizardpage.h
index f59782e979..bd0bf104a3 100644
--- a/src/plugins/vcsbase/checkoutprogresswizardpage.h
+++ b/src/plugins/vcsbase/checkoutprogresswizardpage.h
@@ -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;
};
diff --git a/tests/system/suite_tools/tst_git_clone/test.py b/tests/system/suite_tools/tst_git_clone/test.py
index c913e71ee9..d94797639b 100644
--- a/tests/system/suite_tools/tst_git_clone/test.py
+++ b/tests/system/suite_tools/tst_git_clone/test.py
@@ -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),