Commit 741ab2cb authored by Tobias Hunger's avatar Tobias Hunger

Vcs: Remove snapshot support

The functionality is unused.

Change-Id: I45017106509b8dbff9f3eff3aaef6de19be31ce7
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent fe47725a
......@@ -127,26 +127,6 @@ bool BazaarControl::vcsCreateRepository(const QString &directory)
return m_bazaarClient->synchronousCreateRepository(directory);
}
QString BazaarControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList BazaarControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool BazaarControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool BazaarControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
bool BazaarControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
......
......@@ -63,10 +63,6 @@ public:
bool vcsCreateRepository(const QString &directory);
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
public slots:
......
......@@ -185,23 +185,3 @@ bool ClearCaseControl::vcsCreateRepository(const QString &)
{
return false;
}
QString ClearCaseControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList ClearCaseControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool ClearCaseControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool ClearCaseControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
......@@ -63,11 +63,6 @@ public:
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
QString vcsOpenText() const;
......
......@@ -160,27 +160,6 @@ public:
*/
virtual QString vcsTopic(const QString &directory);
/*!
* Create a snapshot of the current state and return an identifier or
* an empty string in case of failure.
*/
virtual QString vcsCreateSnapshot(const QString &topLevel) = 0;
/*!
* List snapshots.
*/
virtual QStringList vcsSnapshots(const QString &topLevel) = 0;
/*!
* Restore a snapshot.
*/
virtual bool vcsRestoreSnapshot(const QString &topLevel, const QString &name) = 0;
/*!
* Remove a snapshot.
*/
virtual bool vcsRemoveSnapshot(const QString &topLevel, const QString &name) = 0;
/*!
* Display annotation for a file and scroll to line
*/
......
......@@ -126,26 +126,6 @@ bool CvsControl::vcsCheckout(const QString &, const QByteArray &)
return false;
}
QString CvsControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList CvsControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool CvsControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool CvsControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
bool CvsControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
......
......@@ -60,10 +60,6 @@ public:
bool vcsCreateRepository(const QString &directory);
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
QString vcsOpenText() const;
......
......@@ -670,18 +670,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(repositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
gitContainer->addAction(createRepositoryCommand);
if (0) {
const QList<QAction*> snapShotActions = createSnapShotTestActions();
const int count = snapShotActions.size();
for (int i = 0; i < count; i++) {
Core::Command *tCommand
= Core::ActionManager::registerAction(snapShotActions.at(i),
Core::Id("Git.Snapshot.").withSuffix(i),
globalcontext);
gitContainer->addAction(tCommand);
}
}
// Submit editor
Core::Context submitContext(Constants::C_GITSUBMITEDITOR);
m_submitCurrentAction = new QAction(VcsBase::VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this);
......
......@@ -35,9 +35,6 @@
#include <QFileInfo>
static const char stashMessageKeywordC[] = "IVersionControl@";
static const char stashRevisionIdC[] = "revision";
namespace Git {
namespace Internal {
......@@ -131,96 +128,6 @@ QString GitVersionControl::vcsTopic(const QString &directory)
return topic;
}
/* Snapshots are implemented using stashes, relying on stash messages for
* naming as the actual stash names (stash{n}) are rotated as one adds stashes.
* Note that the snapshot interface does not care whether we have an unmodified
* repository state, in which case git refuses to stash.
* In that case, return a special identifier as "specialprefix:<branch>:<head revision>",
* which will trigger a checkout in restore(). */
QString GitVersionControl::vcsCreateSnapshot(const QString &topLevel)
{
bool repositoryUnchanged;
// Create unique keyword
static int n = 1;
QString keyword = QLatin1String(stashMessageKeywordC) + QString::number(n++);
const QString stashMessage =
m_client->synchronousStash(topLevel, keyword,
GitClient::StashImmediateRestore
| GitClient::StashIgnoreUnchanged,
&repositoryUnchanged);
if (!stashMessage.isEmpty())
return stashMessage;
if (repositoryUnchanged) {
// For unchanged repository state: return identifier + top revision
QString topRevision = m_client->synchronousTopRevision(topLevel);
if (topRevision.isEmpty())
return QString();
QString branch = m_client->synchronousTopic(topLevel);
const QChar colon = QLatin1Char(':');
QString id = QLatin1String(stashRevisionIdC);
id += colon;
id += branch;
id += colon;
id += topRevision;
return id;
}
return QString(); // Failure
}
QStringList GitVersionControl::vcsSnapshots(const QString &topLevel)
{
QList<Stash> stashes;
if (!m_client->synchronousStashList(topLevel, &stashes))
return QStringList();
// Return the git stash 'message' as identifier, ignoring empty ones
QStringList rc;
foreach (const Stash &s, stashes)
if (!s.message.isEmpty())
rc.push_back(s.message);
return rc;
}
bool GitVersionControl::vcsRestoreSnapshot(const QString &topLevel, const QString &name)
{
bool success = false;
do {
// Is this a revision or a stash
if (name.startsWith(QLatin1String(stashRevisionIdC))) {
// Restore "id:branch:revision"
const QStringList tokens = name.split(QLatin1Char(':'));
if (tokens.size() != 3)
break;
const QString branch = tokens.at(1);
const QString revision = tokens.at(2);
success = m_client->synchronousReset(topLevel);
if (success && !branch.isEmpty()) {
success = m_client->synchronousCheckout(topLevel, branch) &&
m_client->synchronousCheckoutFiles(topLevel, QStringList(), revision);
} else {
success = m_client->synchronousCheckout(topLevel, revision);
}
} else {
// Restore stash if it can be resolved.
QString stashName;
success = m_client->stashNameFromMessage(topLevel, name, &stashName)
&& m_client->synchronousReset(topLevel)
&& m_client->synchronousStashRestore(topLevel, stashName, true);
}
} while (false);
return success;
}
bool GitVersionControl::vcsRemoveSnapshot(const QString &topLevel, const QString &name)
{
// Is this a revision -> happy
if (name.startsWith(QLatin1String(stashRevisionIdC)))
return true;
QString stashName;
return m_client->stashNameFromMessage(topLevel, name, &stashName)
&& m_client->synchronousStashRemove(topLevel, stashName);
}
bool GitVersionControl::managesDirectory(const QString &directory, QString *topLevel) const
{
const QString topLevelFound = m_client->findRepositoryForDirectory(directory);
......
......@@ -59,10 +59,6 @@ public:
bool vcsCreateRepository(const QString &directory);
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
QString vcsTopic(const QString &directory);
......
......@@ -129,26 +129,6 @@ bool MercurialControl::vcsCreateRepository(const QString &directory)
return mercurialClient->synchronousCreateRepository(directory);
}
QString MercurialControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList MercurialControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool MercurialControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool MercurialControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
bool MercurialControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
......
......@@ -63,10 +63,6 @@ public:
bool vcsCreateRepository(const QString &directory);
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool sccManaged(const QString &filename);
bool vcsAnnotate(const QString &file, int line);
......
......@@ -125,26 +125,6 @@ bool PerforceVersionControl::vcsCreateRepository(const QString &)
return false;
}
QString PerforceVersionControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList PerforceVersionControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool PerforceVersionControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool PerforceVersionControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
bool PerforceVersionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
......
......@@ -60,10 +60,6 @@ public:
bool vcsCreateRepository(const QString &directory);
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
QString vcsOpenText() const;
QString vcsMakeWritableText() const;
......
......@@ -121,26 +121,6 @@ bool SubversionControl::vcsCreateRepository(const QString &)
return false;
}
QString SubversionControl::vcsCreateSnapshot(const QString &)
{
return QString();
}
QStringList SubversionControl::vcsSnapshots(const QString &)
{
return QStringList();
}
bool SubversionControl::vcsRestoreSnapshot(const QString &, const QString &)
{
return false;
}
bool SubversionControl::vcsRemoveSnapshot(const QString &, const QString &)
{
return false;
}
bool SubversionControl::managesDirectory(const QString &directory, QString *topLevel) const
{
return m_plugin->managesDirectory(directory, topLevel);
......
......@@ -59,11 +59,6 @@ public:
bool vcsCheckout(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
QString vcsCreateSnapshot(const QString &topLevel);
QStringList vcsSnapshots(const QString &topLevel);
bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
bool vcsRemoveSnapshot(const QString &topLevel, const QString &name);
bool vcsAnnotate(const QString &file, int line);
void emitRepositoryChanged(const QString &);
......
......@@ -500,8 +500,9 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
the virtual submitEditorAboutToClose() to trigger the submit process.
*/
struct VcsBasePluginPrivate
class VcsBasePluginPrivate
{
public:
explicit VcsBasePluginPrivate();
inline bool supportsRepositoryCreation() const;
......@@ -510,22 +511,13 @@ struct VcsBasePluginPrivate
Core::IVersionControl *m_versionControl;
VcsBasePluginState m_state;
int m_actionState;
QAction *m_testSnapshotAction;
QAction *m_testListSnapshotsAction;
QAction *m_testRestoreSnapshotAction;
QAction *m_testRemoveSnapshotAction;
QString m_testLastSnapshot;
static Internal::StateListener *m_listener;
};
VcsBasePluginPrivate::VcsBasePluginPrivate() :
m_versionControl(0),
m_actionState(-1),
m_testSnapshotAction(0),
m_testListSnapshotsAction(0),
m_testRestoreSnapshotAction(0),
m_testRemoveSnapshotAction(0)
m_actionState(-1)
{
}
......@@ -710,62 +702,6 @@ bool VcsBasePlugin::raiseSubmitEditor() const
return true;
}
// For internal tests: Create actions driving IVersionControl's snapshot interface.
QList<QAction*> VcsBasePlugin::createSnapShotTestActions()
{
if (!d->m_testSnapshotAction) {
d->m_testSnapshotAction = new QAction(QLatin1String("Take snapshot"), this);
connect(d->m_testSnapshotAction, SIGNAL(triggered()), this, SLOT(slotTestSnapshot()));
d->m_testListSnapshotsAction = new QAction(QLatin1String("List snapshots"), this);
connect(d->m_testListSnapshotsAction, SIGNAL(triggered()), this, SLOT(slotTestListSnapshots()));
d->m_testRestoreSnapshotAction = new QAction(QLatin1String("Restore snapshot"), this);
connect(d->m_testRestoreSnapshotAction, SIGNAL(triggered()), this, SLOT(slotTestRestoreSnapshot()));
d->m_testRemoveSnapshotAction = new QAction(QLatin1String("Remove snapshot"), this);
connect(d->m_testRemoveSnapshotAction, SIGNAL(triggered()), this, SLOT(slotTestRemoveSnapshot()));
}
QList<QAction*> rc;
rc << d->m_testSnapshotAction << d->m_testListSnapshotsAction << d->m_testRestoreSnapshotAction
<< d->m_testRemoveSnapshotAction;
return rc;
}
void VcsBasePlugin::slotTestSnapshot()
{
QTC_ASSERT(currentState().hasTopLevel(), return);
d->m_testLastSnapshot = versionControl()->vcsCreateSnapshot(currentState().topLevel());
qDebug() << "Snapshot " << d->m_testLastSnapshot;
VcsBaseOutputWindow::instance()->append(QLatin1String("Snapshot: ") + d->m_testLastSnapshot);
if (!d->m_testLastSnapshot.isEmpty())
d->m_testRestoreSnapshotAction->setText(QLatin1String("Restore snapshot ") + d->m_testLastSnapshot);
}
void VcsBasePlugin::slotTestListSnapshots()
{
QTC_ASSERT(currentState().hasTopLevel(), return);
const QStringList snapshots = versionControl()->vcsSnapshots(currentState().topLevel());
qDebug() << "Snapshots " << snapshots;
VcsBaseOutputWindow::instance()->append(QLatin1String("Snapshots: ") + snapshots.join(QLatin1String(", ")));
}
void VcsBasePlugin::slotTestRestoreSnapshot()
{
QTC_ASSERT(currentState().hasTopLevel() && !d->m_testLastSnapshot.isEmpty(), return);
const bool ok = versionControl()->vcsRestoreSnapshot(currentState().topLevel(), d->m_testLastSnapshot);
const QString msg = d->m_testLastSnapshot+ (ok ? QLatin1String(" restored") : QLatin1String(" failed"));
qDebug() << msg;
VcsBaseOutputWindow::instance()->append(msg);
}
void VcsBasePlugin::slotTestRemoveSnapshot()
{
QTC_ASSERT(currentState().hasTopLevel() && !d->m_testLastSnapshot.isEmpty(), return);
const bool ok = versionControl()->vcsRemoveSnapshot(currentState().topLevel(), d->m_testLastSnapshot);
const QString msg = d->m_testLastSnapshot+ (ok ? QLatin1String(" removed") : QLatin1String(" failed"));
qDebug() << msg;
VcsBaseOutputWindow::instance()->append(msg);
d->m_testLastSnapshot.clear();
}
// Find top level for version controls like git/Mercurial that have
// a directory at the top of the repository.
// Note that checking for the existence of files is preferred over directories
......
......@@ -55,7 +55,7 @@ namespace VcsBase {
namespace Internal { struct State; }
class VcsBaseSubmitEditor;
struct VcsBasePluginPrivate;
class VcsBasePluginPrivate;
class VcsBasePluginStateData;
class VcsBasePlugin;
......@@ -137,9 +137,6 @@ public:
const VcsBasePluginState &currentState() const;
Core::IVersionControl *versionControl() const;
// For internal tests: Create actions driving IVersionControl's snapshot interface.
QList<QAction*> createSnapShotTestActions();
// Convenience that searches for the repository specifically for version control
// systems that do not have directories like "CVS" in each managed subdirectory
// but have a directory at the top of the repository like ".git" containing
......@@ -222,10 +219,6 @@ protected:
private slots:
void slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result);
void slotStateChanged(const VcsBase::Internal::State &s, Core::IVersionControl *vc);
void slotTestSnapshot();
void slotTestListSnapshots();
void slotTestRestoreSnapshot();
void slotTestRemoveSnapshot();
private:
VcsBasePluginPrivate *d;
......
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