Bazaar: Replace CloneWizard with a Json wizard

Change-Id: Ifce4d43a2f8d1ec97af4b30d32e5c8bb03c22bc9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Hugues Delorme <delorme.hugues@fougsys.fr>
This commit is contained in:
Tobias Hunger
2015-05-11 16:23:05 +02:00
parent f356aae5f9
commit 3f6f02f2f1
13 changed files with 198 additions and 597 deletions

View File

@@ -11,9 +11,6 @@ SOURCES += \
annotationhighlighter.cpp \
pullorpushdialog.cpp \
branchinfo.cpp \
clonewizardpage.cpp \
clonewizard.cpp \
cloneoptionspanel.cpp \
uncommitdialog.cpp
HEADERS += \
bazaarclient.h \
@@ -28,15 +25,10 @@ HEADERS += \
annotationhighlighter.h \
pullorpushdialog.h \
branchinfo.h \
clonewizard.h \
clonewizardpage.h \
cloneoptionspanel.h \
uncommitdialog.h
FORMS += \
optionspage.ui \
revertdialog.ui \
bazaarcommitpanel.ui \
pullorpushdialog.ui \
cloneoptionspanel.ui \
uncommitdialog.ui
RESOURCES += bazaar.qrc

View File

@@ -13,7 +13,6 @@ QtcPlugin {
files: [
"annotationhighlighter.cpp",
"annotationhighlighter.h",
"bazaar.qrc",
"bazaarclient.cpp",
"bazaarclient.h",
"bazaarcommitpanel.ui",
@@ -29,13 +28,6 @@ QtcPlugin {
"bazaarsettings.h",
"branchinfo.cpp",
"branchinfo.h",
"cloneoptionspanel.cpp",
"cloneoptionspanel.h",
"cloneoptionspanel.ui",
"clonewizard.cpp",
"clonewizard.h",
"clonewizardpage.cpp",
"clonewizardpage.h",
"commiteditor.cpp",
"commiteditor.h",
"constants.h",

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/bazaar" >
<file>images/bazaar.png</file>
</qresource>
</RCC>

View File

@@ -38,7 +38,6 @@
#include "pullorpushdialog.h"
#include "uncommitdialog.h"
#include "commiteditor.h"
#include "clonewizard.h"
#include "ui_revertdialog.h"
@@ -181,16 +180,6 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters,
[]() { return new CommitEditor(&submitEditorParameters); }));
auto cloneWizardFactory = new BaseCheckoutWizardFactory;
cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR));
cloneWizardFactory->setIcon(QIcon(QLatin1String(":/bazaar/images/bazaar.png")));
cloneWizardFactory->setDescription(tr("Clones a Bazaar branch and tries to load the contained project."));
cloneWizardFactory->setDisplayName(tr("Bazaar Clone (Or Branch)"));
cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) {
return new CloneWizard(path, parent);
});
addAutoReleasedObject(cloneWizardFactory);
const QString prefix = QLatin1String("bzr");
m_commandLocator = new CommandLocator("Bazaar", prefix, prefix);
addAutoReleasedObject(m_commandLocator);

View File

@@ -1,91 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cloneoptionspanel.h"
#include "ui_cloneoptionspanel.h"
#include <QDebug>
namespace Bazaar {
namespace Internal {
CloneOptionsPanel::CloneOptionsPanel(QWidget *parent)
: QWidget(parent),
m_ui(new Ui::CloneOptionsPanel)
{
m_ui->setupUi(this);
}
CloneOptionsPanel::~CloneOptionsPanel()
{
delete m_ui;
}
bool CloneOptionsPanel::isUseExistingDirectoryOptionEnabled() const
{
return m_ui->useExistingDirCheckBox->isChecked();
}
bool CloneOptionsPanel::isStackedOptionEnabled() const
{
return m_ui->stackedCheckBox->isChecked();
}
bool CloneOptionsPanel::isStandAloneOptionEnabled() const
{
return m_ui->standAloneCheckBox->isChecked();
}
bool CloneOptionsPanel::isBindOptionEnabled() const
{
return m_ui->bindCheckBox->isChecked();
}
bool CloneOptionsPanel::isSwitchOptionEnabled() const
{
return m_ui->switchCheckBox->isChecked();
}
bool CloneOptionsPanel::isHardLinkOptionEnabled() const
{
return m_ui->hardlinkCheckBox->isChecked();
}
bool CloneOptionsPanel::isNoTreeOptionEnabled() const
{
return m_ui->noTreeCheckBox->isChecked();
}
QString CloneOptionsPanel::revision() const
{
return m_ui->revisionLineEdit->text().simplified();
}
} // namespace Internal
} // namespace Bazaar

View File

@@ -1,64 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLONEOPTIONSPANEL_H
#define CLONEOPTIONSPANEL_H
#include <QWidget>
namespace Bazaar {
namespace Internal {
namespace Ui { class CloneOptionsPanel; }
class CloneOptionsPanel : public QWidget
{
Q_OBJECT
public:
CloneOptionsPanel(QWidget *parent = 0);
~CloneOptionsPanel();
bool isUseExistingDirectoryOptionEnabled() const;
bool isStackedOptionEnabled() const;
bool isStandAloneOptionEnabled() const;
bool isBindOptionEnabled() const;
bool isSwitchOptionEnabled() const;
bool isHardLinkOptionEnabled() const;
bool isNoTreeOptionEnabled() const;
QString revision() const;
private:
Ui::CloneOptionsPanel *m_ui;
};
} // namespace Internal
} // namespace Bazaar
#endif // CLONEOPTIONSPANEL_H

View File

@@ -1,137 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Bazaar::Internal::CloneOptionsPanel</class>
<widget class="QWidget" name="Bazaar::Internal::CloneOptionsPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>283</width>
<height>278</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="optionsGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Options</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="useExistingDirCheckBox">
<property name="toolTip">
<string>By default, branch will fail if the target directory exists, but does not already have a control directory.
This flag will allow branch to proceed.</string>
</property>
<property name="text">
<string>Use existing directory</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="stackedCheckBox">
<property name="toolTip">
<string>Creates a stacked branch referring to the source branch.
The new branch will depend on the availability of the source branch for all operations.</string>
</property>
<property name="text">
<string>Stacked</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="standAloneCheckBox">
<property name="toolTip">
<string>Does not use a shared repository, even if available.</string>
</property>
<property name="text">
<string>Standalone</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="bindCheckBox">
<property name="text">
<string>Bind new branch to source location</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="switchCheckBox">
<property name="toolTip">
<string>Switches the checkout in the current directory to the new branch.</string>
</property>
<property name="text">
<string>Switch checkout</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="hardlinkCheckBox">
<property name="toolTip">
<string>Hard-links working tree files where possible.</string>
</property>
<property name="text">
<string>Hardlink</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="noTreeCheckBox">
<property name="toolTip">
<string>Creates a branch without a working-tree.</string>
</property>
<property name="text">
<string>No working-tree</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Revision:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="revisionLineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -1,96 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "clonewizard.h"
#include "clonewizardpage.h"
#include "cloneoptionspanel.h"
#include "bazaarplugin.h"
#include "bazaarclient.h"
#include "bazaarsettings.h"
#include <coreplugin/iversioncontrol.h>
#include <vcsbase/vcscommand.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/wizard/vcsconfigurationpage.h>
#include <utils/qtcassert.h>
using namespace VcsBase;
namespace Bazaar {
namespace Internal {
// --------------------------------------------------------------------
// CloneWizard:
// --------------------------------------------------------------------
CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
BaseCheckoutWizard(Constants::VCS_ID_BAZAAR, parent)
{
setTitle(tr("Cloning"));
setStartedStatus(tr("Cloning started..."));
auto page = new CloneWizardPage;
page->setPath(path.toString());
addPage(page);
}
VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
{
const CloneWizardPage *cwp = find<CloneWizardPage>();
QTC_ASSERT(cwp, return 0);
*checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory());
const CloneOptionsPanel *panel = cwp->cloneOptionsPanel();
QStringList extraOptions;
if (panel->isUseExistingDirectoryOptionEnabled())
extraOptions += QLatin1String("--use-existing-dir");
if (panel->isStackedOptionEnabled())
extraOptions += QLatin1String("--stacked");
if (panel->isStandAloneOptionEnabled())
extraOptions += QLatin1String("--standalone");
if (panel->isBindOptionEnabled())
extraOptions += QLatin1String("--bind");
if (panel->isSwitchOptionEnabled())
extraOptions += QLatin1String("--switch");
if (panel->isHardLinkOptionEnabled())
extraOptions += QLatin1String("--hardlink");
if (panel->isNoTreeOptionEnabled())
extraOptions += QLatin1String("--no-tree");
if (!panel->revision().isEmpty())
extraOptions << QLatin1String("-r") << panel->revision();
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(cwp->path()),
cwp->directory(), extraOptions);
}
} // namespace Internal
} // namespace Bazaar

View File

@@ -1,54 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLONEWIZARD_H
#define CLONEWIZARD_H
#include <vcsbase/basecheckoutwizardfactory.h>
#include <vcsbase/basecheckoutwizard.h>
namespace Bazaar {
namespace Internal {
class CloneWizard : public VcsBase::BaseCheckoutWizard
{
Q_OBJECT
public:
CloneWizard(const Utils::FileName &path, QWidget *parent = 0);
protected:
VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir);
};
} // namespace Internal
} // namespace Bazaar
#endif // CLONEWIZARD_H

View File

@@ -1,65 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "clonewizardpage.h"
#include "cloneoptionspanel.h"
using namespace Bazaar::Internal;
CloneWizardPage::CloneWizardPage(QWidget *parent)
: VcsBase::BaseCheckoutWizardPage(parent),
m_optionsPanel(new CloneOptionsPanel)
{
setTitle(tr("Location"));
setSubTitle(tr("Specify repository URL, clone directory and path."));
setRepositoryLabel(tr("Clone URL:"));
setBranchSelectorVisible(false);
addLocalControl(m_optionsPanel);
}
const CloneOptionsPanel *CloneWizardPage::cloneOptionsPanel() const
{
return m_optionsPanel;
}
QString CloneWizardPage::directoryFromRepository(const QString &repository) const
{
// Bazaar repositories are generally of the form
// 'lp:project' or 'protocol://repositoryUrl/repository/'
// We are just looking for repository.
QString repo = repository.trimmed();
if (repo.startsWith(QLatin1String("lp:")))
return repo.mid(3);
const QChar slash = QLatin1Char('/');
if (repo.endsWith(slash))
repo.truncate(repo.size() - 1);
// Take the basename or the repository url
return repo.mid(repo.lastIndexOf(slash) + 1);
}

View File

@@ -1,58 +0,0 @@
/**************************************************************************
**
** Copyright (C) 2015 Hugues Delorme
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLONEWIZARDPAGE_H
#define CLONEWIZARDPAGE_H
#include <vcsbase/basecheckoutwizardpage.h>
namespace Bazaar {
namespace Internal {
class CloneOptionsPanel;
class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage
{
Q_OBJECT
public:
CloneWizardPage(QWidget *parent = 0);
const CloneOptionsPanel *cloneOptionsPanel() const;
protected:
QString directoryFromRepository(const QString &repository) const;
private:
CloneOptionsPanel *m_optionsPanel;
};
} // namespace Internal
} // namespace Bazaar
#endif // CLONEWIZARDPAGE_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB