Commit f6aba961 authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarTobias Hunger <tobias.hunger@digia.com>
parent c2803b00
......@@ -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;
......
......@@ -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;
}
......@@ -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
......
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