Added HTTP Proxy support during clone
Added file dialog for selecting a local source repository for cloning FossilOrigin-Name: 872751fabaa47ac1f1f9d4caa4bdb42ae2e371cd
This commit is contained in:
@ -21,7 +21,7 @@ CloneDialog::~CloneDialog()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository)
|
||||
bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository, QUrl &urlProxy)
|
||||
{
|
||||
CloneDialog dlg(parent);
|
||||
|
||||
@ -61,37 +61,69 @@ bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository)
|
||||
if(!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
|
||||
if(dlg.ui->lineRepository->text().isEmpty())
|
||||
if(dlg.ui->lineTargetRepository->text().isEmpty())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
|
||||
repository = dlg.ui->lineRepository->text();
|
||||
urlProxy = QUrl::fromUserInput(dlg.ui->lineHttpProxyUrl->text());
|
||||
if(!urlProxy.isEmpty() && !urlProxy.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Proxy URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
|
||||
repository = dlg.ui->lineTargetRepository->text();
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::on_btnSelectRepository_clicked()
|
||||
void CloneDialog::GetRepositoryPath(QString &pathResult)
|
||||
{
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
|
||||
QString path = QFileDialog::getSaveFileName(
|
||||
pathResult = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Select Fossil Repository"),
|
||||
QDir::toNativeSeparators(ui->lineRepository->text()),
|
||||
QDir::toNativeSeparators(pathResult),
|
||||
filter,
|
||||
&filter,
|
||||
QFileDialog::DontConfirmOverwrite);
|
||||
}
|
||||
|
||||
if(path.isEmpty())
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::on_btnSelectSourceRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::on_btnSelectTargetRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineTargetRepository->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("This repository file already exists."), QMessageBox::Ok );
|
||||
QMessageBox::critical(this, tr("Error"), tr("This repository file already exists."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineRepository->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineTargetRepository->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
@ -19,12 +19,15 @@ public:
|
||||
explicit CloneDialog(QWidget *parent = 0);
|
||||
~CloneDialog();
|
||||
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &repository);
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &repository, QUrl& urlProxy);
|
||||
|
||||
private slots:
|
||||
void on_btnSelectRepository_clicked();
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
void on_btnSelectTargetRepo_clicked();
|
||||
|
||||
private:
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
|
||||
Ui::CloneDialog *ui;
|
||||
};
|
||||
|
||||
|
@ -489,15 +489,20 @@ void MainWindow::on_actionCloseRepository_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionCloneRepository_triggered()
|
||||
{
|
||||
QUrl url;
|
||||
QUrl url, url_proxy;
|
||||
QString repository;
|
||||
|
||||
if(!CloneDialog::run(this, url, repository))
|
||||
if(!CloneDialog::run(this, url, repository, url_proxy))
|
||||
return;
|
||||
|
||||
stopUI();
|
||||
|
||||
// Actual command
|
||||
QStringList cmd = QStringList() << "clone";
|
||||
|
||||
// Log Command
|
||||
QStringList logcmd = QStringList() << "fossil" << "clone";
|
||||
|
||||
QString source = url.toString();
|
||||
QString logsource = url.toString(QUrl::RemovePassword);
|
||||
if(url.isLocalFile())
|
||||
@ -505,11 +510,14 @@ void MainWindow::on_actionCloneRepository_triggered()
|
||||
source = url.toLocalFile();
|
||||
logsource = source;
|
||||
}
|
||||
cmd << source << repository;
|
||||
logcmd << logsource << repository;
|
||||
|
||||
QStringList cmd = QStringList() << "clone" << source << repository;
|
||||
|
||||
// Log Command
|
||||
QStringList logcmd = QStringList() << "fossil" << "clone" << logsource << repository;
|
||||
if(!url_proxy.isEmpty())
|
||||
{
|
||||
cmd << "--proxy" << url_proxy.toString();
|
||||
logcmd << "--proxy" << url_proxy.toString(QUrl::RemovePassword);
|
||||
}
|
||||
|
||||
log("<b>>"+logcmd.join(" ")+"</b><br>", true);
|
||||
|
||||
@ -521,7 +529,6 @@ void MainWindow::on_actionCloneRepository_triggered()
|
||||
}
|
||||
|
||||
openWorkspace(repository);
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user