aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2014-02-24 14:16:12 +0100
committerTobias Hunger <tobias.hunger@digia.com>2014-02-24 14:20:51 +0100
commitf6aba961979270820aa6c1b863c9a4aedcc1cdff (patch)
tree5f74af995338aa55968cbd18536dfb78f066446a
parentc2803b00be65a064fa5217bdd016b530d518ab9f (diff)
Hg: Improve push/pull handling
* Use paths/default-push and paths/default Urls as appropriate * Read the settings from the project location except when the currently open file is not below that project directory. This makes things work for QTCREATORBUG-10261 without breaking .hgsubs (which are required to be children of the top-level repository. Task-number: QTCREATORBUG-10261 Change-Id: Ie7cc4b9a420f17e27b69eae93fb9985e1a218d6e Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp10
-rw-r--r--src/plugins/mercurial/srcdestdialog.cpp27
-rw-r--r--src/plugins/mercurial/srcdestdialog.h6
3 files changed, 33 insertions, 10 deletions
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index 027909d327..80bd27240c 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -439,11 +439,11 @@ void MercurialPlugin::pull()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- SrcDestDialog dialog;
+ SrcDestDialog dialog(SrcDestDialog::incoming);
dialog.setWindowTitle(tr("Pull Source"));
if (dialog.exec() != QDialog::Accepted)
return;
- m_client->synchronousPull(state.topLevel(), dialog.getRepositoryString());
+ m_client->synchronousPull(dialog.workingDir(), dialog.getRepositoryString());
}
void MercurialPlugin::push()
@@ -451,11 +451,11 @@ void MercurialPlugin::push()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- SrcDestDialog dialog;
+ SrcDestDialog dialog(SrcDestDialog::outgoing);
dialog.setWindowTitle(tr("Push Destination"));
if (dialog.exec() != QDialog::Accepted)
return;
- m_client->synchronousPush(state.topLevel(), dialog.getRepositoryString());
+ m_client->synchronousPush(dialog.workingDir(), dialog.getRepositoryString());
}
void MercurialPlugin::update()
@@ -491,7 +491,7 @@ void MercurialPlugin::incoming()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- SrcDestDialog dialog;
+ SrcDestDialog dialog(SrcDestDialog::incoming);
dialog.setWindowTitle(tr("Incoming Source"));
if (dialog.exec() != QDialog::Accepted)
return;
diff --git a/src/plugins/mercurial/srcdestdialog.cpp b/src/plugins/mercurial/srcdestdialog.cpp
index 2fc7ea139e..5fe497750f 100644
--- a/src/plugins/mercurial/srcdestdialog.cpp
+++ b/src/plugins/mercurial/srcdestdialog.cpp
@@ -38,9 +38,10 @@
using namespace VcsBase;
using namespace Mercurial::Internal;
-SrcDestDialog::SrcDestDialog(QWidget *parent) :
+SrcDestDialog::SrcDestDialog(Direction dir, QWidget *parent) :
QDialog(parent),
- m_ui(new Ui::SrcDestDialog)
+ m_ui(new Ui::SrcDestDialog),
+ m_direction(dir)
{
m_ui->setupUi(this);
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
@@ -91,10 +92,28 @@ QString SrcDestDialog::getRepositoryString() const
return m_ui->urlLineEdit->text();
}
+QString SrcDestDialog::workingDir() const
+{
+ return m_workingdir;
+}
+
QUrl SrcDestDialog::getRepoUrl() const
{
MercurialPlugin *plugin = MercurialPlugin::instance();
const VcsBasePluginState state = plugin->currentState();
- QSettings settings(QString(QLatin1String("%1/.hg/hgrc")).arg(state.currentProjectPath()), QSettings::IniFormat);
- return settings.value(QLatin1String("paths/default")).toUrl();
+ // Repo to use: Default to the project repo, but use the current
+ const QString projectLoc = state.currentProjectPath();
+ const QString fileLoc = state.currentFileTopLevel();
+ m_workingdir = projectLoc;
+ if (!fileLoc.isEmpty())
+ m_workingdir = fileLoc;
+ if (!projectLoc.isEmpty() && fileLoc.startsWith(projectLoc + QLatin1Char('/')))
+ m_workingdir = projectLoc;
+ QSettings settings(QString(QLatin1String("%1/.hg/hgrc")).arg(m_workingdir), QSettings::IniFormat);
+ QUrl url;
+ if (m_direction == outgoing)
+ url = settings.value(QLatin1String("paths/default-push")).toUrl();
+ if (url.isEmpty())
+ url = settings.value(QLatin1String("paths/default")).toUrl();
+ return url;
}
diff --git a/src/plugins/mercurial/srcdestdialog.h b/src/plugins/mercurial/srcdestdialog.h
index 5735c6cd66..0969763da2 100644
--- a/src/plugins/mercurial/srcdestdialog.h
+++ b/src/plugins/mercurial/srcdestdialog.h
@@ -43,17 +43,21 @@ class SrcDestDialog : public QDialog
Q_OBJECT
public:
- SrcDestDialog(QWidget *parent = 0);
+ enum Direction { outgoing, incoming };
+ explicit SrcDestDialog(Direction dir, QWidget *parent = 0);
~SrcDestDialog();
void setPathChooserKind(Utils::PathChooser::Kind kind);
QString getRepositoryString() const;
+ QString workingDir() const;
private:
QUrl getRepoUrl() const;
private:
Ui::SrcDestDialog *m_ui;
+ Direction m_direction;
+ mutable QString m_workingdir;
};
} // namespace Internal