forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -439,11 +439,11 @@ void MercurialPlugin::pull()
|
|||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasTopLevel(), return);
|
QTC_ASSERT(state.hasTopLevel(), return);
|
||||||
|
|
||||||
SrcDestDialog dialog;
|
SrcDestDialog dialog(SrcDestDialog::incoming);
|
||||||
dialog.setWindowTitle(tr("Pull Source"));
|
dialog.setWindowTitle(tr("Pull Source"));
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
m_client->synchronousPull(state.topLevel(), dialog.getRepositoryString());
|
m_client->synchronousPull(dialog.workingDir(), dialog.getRepositoryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercurialPlugin::push()
|
void MercurialPlugin::push()
|
||||||
@@ -451,11 +451,11 @@ void MercurialPlugin::push()
|
|||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasTopLevel(), return);
|
QTC_ASSERT(state.hasTopLevel(), return);
|
||||||
|
|
||||||
SrcDestDialog dialog;
|
SrcDestDialog dialog(SrcDestDialog::outgoing);
|
||||||
dialog.setWindowTitle(tr("Push Destination"));
|
dialog.setWindowTitle(tr("Push Destination"));
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
m_client->synchronousPush(state.topLevel(), dialog.getRepositoryString());
|
m_client->synchronousPush(dialog.workingDir(), dialog.getRepositoryString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercurialPlugin::update()
|
void MercurialPlugin::update()
|
||||||
@@ -491,7 +491,7 @@ void MercurialPlugin::incoming()
|
|||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasTopLevel(), return);
|
QTC_ASSERT(state.hasTopLevel(), return);
|
||||||
|
|
||||||
SrcDestDialog dialog;
|
SrcDestDialog dialog(SrcDestDialog::incoming);
|
||||||
dialog.setWindowTitle(tr("Incoming Source"));
|
dialog.setWindowTitle(tr("Incoming Source"));
|
||||||
if (dialog.exec() != QDialog::Accepted)
|
if (dialog.exec() != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -38,9 +38,10 @@
|
|||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
using namespace Mercurial::Internal;
|
using namespace Mercurial::Internal;
|
||||||
|
|
||||||
SrcDestDialog::SrcDestDialog(QWidget *parent) :
|
SrcDestDialog::SrcDestDialog(Direction dir, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Ui::SrcDestDialog)
|
m_ui(new Ui::SrcDestDialog),
|
||||||
|
m_direction(dir)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||||
@@ -91,10 +92,28 @@ QString SrcDestDialog::getRepositoryString() const
|
|||||||
return m_ui->urlLineEdit->text();
|
return m_ui->urlLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SrcDestDialog::workingDir() const
|
||||||
|
{
|
||||||
|
return m_workingdir;
|
||||||
|
}
|
||||||
|
|
||||||
QUrl SrcDestDialog::getRepoUrl() const
|
QUrl SrcDestDialog::getRepoUrl() const
|
||||||
{
|
{
|
||||||
MercurialPlugin *plugin = MercurialPlugin::instance();
|
MercurialPlugin *plugin = MercurialPlugin::instance();
|
||||||
const VcsBasePluginState state = plugin->currentState();
|
const VcsBasePluginState state = plugin->currentState();
|
||||||
QSettings settings(QString(QLatin1String("%1/.hg/hgrc")).arg(state.currentProjectPath()), QSettings::IniFormat);
|
// Repo to use: Default to the project repo, but use the current
|
||||||
return settings.value(QLatin1String("paths/default")).toUrl();
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrcDestDialog(QWidget *parent = 0);
|
enum Direction { outgoing, incoming };
|
||||||
|
explicit SrcDestDialog(Direction dir, QWidget *parent = 0);
|
||||||
~SrcDestDialog();
|
~SrcDestDialog();
|
||||||
|
|
||||||
void setPathChooserKind(Utils::PathChooser::Kind kind);
|
void setPathChooserKind(Utils::PathChooser::Kind kind);
|
||||||
QString getRepositoryString() const;
|
QString getRepositoryString() const;
|
||||||
|
QString workingDir() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl getRepoUrl() const;
|
QUrl getRepoUrl() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SrcDestDialog *m_ui;
|
Ui::SrcDestDialog *m_ui;
|
||||||
|
Direction m_direction;
|
||||||
|
mutable QString m_workingdir;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user