summaryrefslogtreecommitdiff
path: root/src/plugins/mercurial
diff options
context:
space:
mode:
authorcerf <delorme.hugues@gmail.com>2011-08-22 15:33:03 +0000
committerTobias Hunger <tobias.hunger@nokia.com>2011-08-22 17:51:19 +0200
commit3907824b4d080c2949919b48627559f80bfb4e3c (patch)
treed1cb0bab031724f7b5f410e8c01abe499a5d3e74 /src/plugins/mercurial
parent96819ddb7acdf8b9cebee4cc2afe5d7dd1c494ea (diff)
downloadqt-creator-3907824b4d080c2949919b48627559f80bfb4e3c.tar.gz
vcsbase: refactor status parsing in VCSBaseClient
This impacts Bazaar and Mercurial plugins Change-Id: Ife1e83083b268e597928fbae30378e488e31ee96 Merge-request: 358 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/3335
Diffstat (limited to 'src/plugins/mercurial')
-rw-r--r--src/plugins/mercurial/commiteditor.cpp17
-rw-r--r--src/plugins/mercurial/commiteditor.h3
-rw-r--r--src/plugins/mercurial/mercurialclient.cpp20
-rw-r--r--src/plugins/mercurial/mercurialclient.h2
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp10
-rw-r--r--src/plugins/mercurial/mercurialplugin.h3
6 files changed, 28 insertions, 27 deletions
diff --git a/src/plugins/mercurial/commiteditor.cpp b/src/plugins/mercurial/commiteditor.cpp
index a16626dfd1..44371f30bc 100644
--- a/src/plugins/mercurial/commiteditor.cpp
+++ b/src/plugins/mercurial/commiteditor.cpp
@@ -55,7 +55,7 @@ MercurialCommitWidget *CommitEditor::commitWidget()
void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &branch,
const QString &userName, const QString &email,
- const QList<QPair<QString, QString> > &repoStatus)
+ const QList<VCSBase::VCSBaseClient::StatusItem> &repoStatus)
{
MercurialCommitWidget *mercurialWidget = commitWidget();
if (!mercurialWidget)
@@ -66,23 +66,22 @@ void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &bra
fileModel = new VCSBase::SubmitFileModel(this);
//TODO Messy tidy this up
- typedef QPair<QString, QString> StringStringPair;
QStringList shouldTrack;
- foreach (const StringStringPair &status, repoStatus) {
- if (status.first == QLatin1String("Untracked"))
- shouldTrack.append(status.second);
+ foreach (const VCSBase::VCSBaseClient::StatusItem &item, repoStatus) {
+ if (item.flags == QLatin1String("Untracked"))
+ shouldTrack.append(item.file);
else
- fileModel->addFile(status.second, status.first, false);
+ fileModel->addFile(item.file, item.flags, false);
}
VCSBase::VCSBaseSubmitEditor::filterUntrackedFilesOfProject(repositoryRoot.absoluteFilePath(),
&shouldTrack);
foreach (const QString &track, shouldTrack) {
- foreach (const StringStringPair &status, repoStatus) {
- if (status.second == track)
- fileModel->addFile(status.second, status.first, false);
+ foreach (const VCSBase::VCSBaseClient::StatusItem &item, repoStatus) {
+ if (item.file == track)
+ fileModel->addFile(item.file, item.flags, false);
}
}
diff --git a/src/plugins/mercurial/commiteditor.h b/src/plugins/mercurial/commiteditor.h
index 274c8dded7..1c97fc5543 100644
--- a/src/plugins/mercurial/commiteditor.h
+++ b/src/plugins/mercurial/commiteditor.h
@@ -33,6 +33,7 @@
#ifndef COMMITEDITOR_H
#define COMMITEDITOR_H
+#include <vcsbase/vcsbaseclient.h>
#include <vcsbase/vcsbasesubmiteditor.h>
#include <QtCore/QFileInfo>
@@ -55,7 +56,7 @@ public:
void setFields(const QFileInfo &repositoryRoot, const QString &branch,
const QString &userName, const QString &email,
- const QList<QPair<QString, QString> > &repoStatus);
+ const QList<VCSBase::VCSBaseClient::StatusItem> &repoStatus);
QString committerInfo();
QString repoRoot();
diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp
index bf59444932..8b4ff41531 100644
--- a/src/plugins/mercurial/mercurialclient.cpp
+++ b/src/plugins/mercurial/mercurialclient.cpp
@@ -452,29 +452,29 @@ QStringList MercurialClient::viewArguments(const QString &revision) const
return args;
}
-QPair<QString, QString> MercurialClient::parseStatusLine(const QString &line) const
+MercurialClient::StatusItem MercurialClient::parseStatusLine(const QString &line) const
{
- QPair<QString, QString> status;
+ StatusItem item;
if (!line.isEmpty())
{
if (line.startsWith(QLatin1Char('M')))
- status.first = QLatin1String("Modified");
+ item.flags = QLatin1String("Modified");
else if (line.startsWith(QLatin1Char('A')))
- status.first = QLatin1String("Added");
+ item.flags = QLatin1String("Added");
else if (line.startsWith(QLatin1Char('R')))
- status.first = QLatin1String("Removed");
+ item.flags = QLatin1String("Removed");
else if (line.startsWith(QLatin1Char('!')))
- status.first = QLatin1String("Deleted");
+ item.flags = QLatin1String("Deleted");
else if (line.startsWith(QLatin1Char('?')))
- status.first = QLatin1String("Untracked");
+ item.flags = QLatin1String("Untracked");
else
- return status;
+ return item;
//the status line should be similar to "M file_with_changes"
//so just should take the file name part and store it
- status.second = line.mid(2);
+ item.file = line.mid(2);
}
- return status;
+ return item;
}
// Collect all parameters required for a diff to be able to associate them
diff --git a/src/plugins/mercurial/mercurialclient.h b/src/plugins/mercurial/mercurialclient.h
index 7a35e94ed4..ff2c76eb55 100644
--- a/src/plugins/mercurial/mercurialclient.h
+++ b/src/plugins/mercurial/mercurialclient.h
@@ -100,7 +100,7 @@ protected:
QStringList statusArguments(const QString &file) const;
QStringList viewArguments(const QString &revision) const;
- QPair<QString, QString> parseStatusLine(const QString &line) const;
+ StatusItem parseStatusLine(const QString &line) const;
};
} //namespace Internal
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index a59338e958..7c5632b663 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -566,18 +566,18 @@ void MercurialPlugin::commit()
m_submitRepository = state.topLevel();
- connect(m_client, SIGNAL(parsedStatus(QList<QPair<QString,QString> >)),
- this, SLOT(showCommitWidget(QList<QPair<QString,QString> >)));
+ connect(m_client, SIGNAL(parsedStatus(QList<VCSBase::VCSBaseClient::StatusItem>)),
+ this, SLOT(showCommitWidget(QList<VCSBase::VCSBaseClient::StatusItem>)));
m_client->statusWithSignal(m_submitRepository);
}
-void MercurialPlugin::showCommitWidget(const QList<QPair<QString, QString> > &status)
+void MercurialPlugin::showCommitWidget(const QList<VCSBase::VCSBaseClient::StatusItem> &status)
{
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
//Once we receive our data release the connection so it can be reused elsewhere
- disconnect(m_client, SIGNAL(parsedStatus(QList<QPair<QString,QString> >)),
- this, SLOT(showCommitWidget(QList<QPair<QString,QString> >)));
+ disconnect(m_client, SIGNAL(parsedStatus(QList<VCSBase::VCSBaseClient::StatusItem>)),
+ this, SLOT(showCommitWidget(QList<VCSBase::VCSBaseClient::StatusItem>)));
if (status.isEmpty()) {
outputWindow->appendError(tr("There are no changes to commit."));
diff --git a/src/plugins/mercurial/mercurialplugin.h b/src/plugins/mercurial/mercurialplugin.h
index a8e302361d..d6193d8192 100644
--- a/src/plugins/mercurial/mercurialplugin.h
+++ b/src/plugins/mercurial/mercurialplugin.h
@@ -35,6 +35,7 @@
#include "mercurialsettings.h"
+#include <vcsbase/vcsbaseclient.h>
#include <vcsbase/vcsbaseplugin.h>
#include <coreplugin/icontext.h>
@@ -118,7 +119,7 @@ private slots:
void incoming();
void outgoing();
void commit();
- void showCommitWidget(const QList<QPair<QString, QString> > &status);
+ void showCommitWidget(const QList<VCSBase::VCSBaseClient::StatusItem> &status);
void commitFromEditor();
void diffFromEditorSelected(const QStringList &files);