Prevent unnecessary dialog when updating with no new changes
FossilOrigin-Name: f718ab845eb859700e230090f2fcbc7ddb068e62
This commit is contained in:
@ -85,33 +85,6 @@ struct TreeViewItem
|
||||
Q_DECLARE_METATYPE(TreeViewItem)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
static QStringMap MakeKeyValues(QStringList lines)
|
||||
{
|
||||
QStringMap res;
|
||||
|
||||
foreach(QString l, lines)
|
||||
{
|
||||
l = l.trimmed();
|
||||
int index = l.indexOf(' ');
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
if(index!=-1)
|
||||
{
|
||||
key = l.left(index).trimmed();
|
||||
value = l.mid(index).trimmed();
|
||||
}
|
||||
else
|
||||
key = l;
|
||||
|
||||
res.insert(key, value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspacePath) :
|
||||
QMainWindow(parent),
|
||||
@ -1476,11 +1449,15 @@ void MainWindow::on_actionUpdate_triggered()
|
||||
if(!fossil().updateRepository(res, "", true))
|
||||
return;
|
||||
|
||||
// FIXME: parse "changes: None. Already up-to-date" and avoid dialog
|
||||
|
||||
if(res.length()==0)
|
||||
return;
|
||||
|
||||
QStringMap kv;
|
||||
ParseProperties(kv, res, ':');
|
||||
// If no changes exit
|
||||
if(kv.contains("changes") && kv["changes"].indexOf("None."))
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run(this, tr("Update"), tr("The following files will be updated.")+"\n"+tr("Are you sure?"), res))
|
||||
return;
|
||||
|
||||
@ -1505,7 +1482,8 @@ void MainWindow::loadFossilSettings()
|
||||
if(!fossil().getFossilSettings(out))
|
||||
return;
|
||||
|
||||
QStringMap kv = MakeKeyValues(out);
|
||||
QStringMap kv;
|
||||
ParseProperties(kv, out);
|
||||
|
||||
for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
|
||||
{
|
||||
@ -2213,6 +2191,12 @@ void MainWindow::updateRevision(const QString &revision)
|
||||
if(res.length()==0)
|
||||
return;
|
||||
|
||||
QStringMap kv;
|
||||
ParseProperties(kv, res, ':');
|
||||
// If no changes exit
|
||||
if(kv.contains("changes") && kv["changes"].indexOf("None."))
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run(this, tr("Update"), tr("The following files will be updated.")+"\n"+tr("Are you sure?"), res))
|
||||
return;
|
||||
|
||||
|
@ -306,3 +306,26 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
||||
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator)
|
||||
{
|
||||
properties.clear();
|
||||
foreach(QString l, lines)
|
||||
{
|
||||
l = l.trimmed();
|
||||
int index = l.indexOf(separator);
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
if(index!=-1)
|
||||
{
|
||||
key = l.left(index).trimmed();
|
||||
value = l.mid(index).trimmed();
|
||||
}
|
||||
else
|
||||
key = l;
|
||||
|
||||
properties.insert(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QMap>
|
||||
|
||||
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
|
||||
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
|
||||
@ -14,6 +15,9 @@ QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, c
|
||||
QString QuotePath(const QString &path);
|
||||
QStringList QuotePaths(const QStringList &paths);
|
||||
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator=' ');
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user