Support for deleting tags

When parsing tags, also keep track of the checkin uuid
Fixed key-value parsing
Prevent apply stash when nothing is selected

FossilOrigin-Name: 72ac541c4c28f83c94c371f2d81e116b8f3cf261
This commit is contained in:
kostas
2015-05-03 10:05:46 +00:00
parent 8e21224a5e
commit 9777e1e2da
9 changed files with 84 additions and 33 deletions

View File

@ -439,23 +439,38 @@ bool Fossil::stashDiff(const QString& name)
}
//------------------------------------------------------------------------------
bool Fossil::tagList(QStringList& tags)
bool Fossil::tagList(QStringMap& tags)
{
tags.clear();
QStringList res;
QStringList tagnames;
if(!runFossil(QStringList() << "tag" << "ls", &res, RUNFLAGS_SILENT_ALL))
if(!runFossil(QStringList() << "tag" << "ls", &tagnames, RUNFLAGS_SILENT_ALL))
return false;
foreach(const QString &line, res)
QStringList info;
foreach(const QString &line, tagnames)
{
QString tag = line.trimmed();
if(tag.isEmpty())
continue;
tags.append(tag);
info.clear();
if(!runFossil(QStringList() << "info" << tag, &info, RUNFLAGS_SILENT_ALL))
return false;
QStringMap props;
ParseProperties(props, info, ':');
Q_ASSERT(props.contains("uuid"));
// uuid: 0e29a46f036d2e0cc89727190ad34c2dfdc5737c 2015-04-27 15:41:45 UTC
QStringList uuid = props["uuid"].trimmed().split(' ');
Q_ASSERT(uuid.length()>0);
QString revision = uuid[0].trimmed();
tags.insert(tag, revision);
}
tags.sort();
return true;
}
@ -464,11 +479,22 @@ bool Fossil::tagNew(const QString& name, const QString& revision)
{
QStringList res;
if(!runFossil(QStringList() << "tag" << "add" << name << revision, &res, RUNFLAGS_SILENT_ALL))
if(!runFossil(QStringList() << "tag" << "add" << name << revision, &res))
return false;
return true;
}
//------------------------------------------------------------------------------
bool Fossil::tagDelete(const QString& name, const QString &revision)
{
QStringList res;
if(!runFossil(QStringList() << "tag" << "cancel" << name << revision, &res))
return false;
return true;
}
//------------------------------------------------------------------------------
bool Fossil::branchList(QStringList& branches, QStringList& activeBranches)
{

View File

@ -111,9 +111,9 @@ public:
void abortOperation() { operationAborted = true; }
bool tagList(QStringList& tags);
bool tagList(QStringMap& tags);
bool tagNew(const QString& name, const QString& revision);
bool tagDelete(const QString& name);
bool tagDelete(const QString& name, const QString& revision);
bool branchList(QStringList& branches, QStringList& activeBranches);

View File

@ -591,7 +591,10 @@ void MainWindow::scanWorkspace()
versionList.clear();
versionList.append(latest);
versionList += getWorkspace().getBranches();
versionList += getWorkspace().getTags();
versionList += getWorkspace().getTags().keys();
selectedTags.clear();
selectedBranches.clear();
setBusy(false);
setStatus("");
@ -677,8 +680,9 @@ void MainWindow::updateWorkspaceView()
tags->setData(TreeViewItem(TreeViewItem::TYPE_TAGS, ""), REPODIRMODEL_ROLE_PATH);
tags->setEditable(false);
getWorkspace().getDirModel().appendRow(tags);
foreach(const QString &tag_name, getWorkspace().getTags())
for(QStringMap::const_iterator it=getWorkspace().getTags().begin(); it!=getWorkspace().getTags().end(); ++it)
{
const QString &tag_name = it.key();
QStandardItem *tag = new QStandardItem(QIcon(":icons/icons/Book-01.png"), tag_name);
tag->setData(TreeViewItem(TreeViewItem::TYPE_TAG, tag_name), REPODIRMODEL_ROLE_PATH);
tags->appendRow(tag);
@ -1613,10 +1617,12 @@ void MainWindow::onWorkspaceTreeViewSelectionChanged(const QItemSelection &/*sel
Q_ASSERT(data.isValid());
TreeViewItem tv = data.value<TreeViewItem>();
if(tv.Type != TreeViewItem::TYPE_FOLDER && tv.Type != TreeViewItem::TYPE_WORKSPACE)
continue;
new_dirs.insert(tv.Value);
if(tv.Type == TreeViewItem::TYPE_FOLDER || tv.Type == TreeViewItem::TYPE_WORKSPACE)
new_dirs.insert(tv.Value);
else if(tv.Type == TreeViewItem::TYPE_TAG)
selectedTags.append(tv.Value);
else if(tv.Type == TreeViewItem::TYPE_BRANCH)
selectedBranches.append(tv.Value);
}
// Update the selection if we have any new folders
@ -1870,6 +1876,9 @@ void MainWindow::on_actionApplyStash_triggered()
QStringList stashes;
getSelectionStashes(stashes);
if(stashes.empty())
return;
bool delete_stashes = false;
if(!FileActionDialog::run(this, tr("Apply Stash"), tr("The following stashes will be applied.")+"\n"+tr("Are you sure?"), stashes, tr("Delete after applying"), &delete_stashes))
return;
@ -2225,7 +2234,20 @@ void MainWindow::on_actionNewTag_triggered()
//------------------------------------------------------------------------------
void MainWindow::on_actionDeleteTag_triggered()
{
if(selectedTags.size()!=1)
return;
const QString &tagname = selectedTags.first();
if(QMessageBox::Yes != DialogQuery(this, tr("Delete Tag"), tr("Are you sure want to delete the tag %0 ?").arg(tagname)))
return;
Q_ASSERT(getWorkspace().getTags().contains(tagname));
const QString &revision = getWorkspace().getTags()[tagname];
fossil().tagDelete(tagname, revision);
refresh();
}
//------------------------------------------------------------------------------

View File

@ -164,6 +164,8 @@ private:
bool operationAborted;
stringset_t selectedDirs; // The directory selected in the tree
QStringList selectedTags;
QStringList selectedBranches;
QStringList versionList;
Workspace workspace;

View File

@ -320,7 +320,7 @@ void ParseProperties(QStringMap &properties, const QStringList &lines, QChar sep
if(index!=-1)
{
key = l.left(index).trimmed();
value = l.mid(index).trimmed();
value = l.mid(index+1).trimmed();
}
else
key = l;

View File

@ -189,11 +189,11 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
fossil().branchList(branchList, branchList);
fossil().tagList(tagList);
fossil().tagList(tags);
// Fossil includes the branches in the tag list
// So remove them
foreach(const QString &name, branchList)
tagList.removeAll(name);
tags.remove(name);
_done:
uiCallback.endProcess();

View File

@ -6,6 +6,7 @@
#include <QDir>
#include <QSet>
#include <QMap>
#include "Utils.h"
#include "Fossil.h"
//////////////////////////////////////////////////////////////////////////
@ -120,7 +121,7 @@ public:
filemap_t &getFiles() { return workspaceFiles; }
stringset_t &getPaths() { return pathSet; }
stashmap_t &getStashes() { return stashMap; }
QStringList &getTags() { return tagList; }
QStringMap &getTags() { return tags; }
QStringList &getBranches() { return branchList; }
private:
@ -129,7 +130,7 @@ private:
stringset_t pathSet;
stashmap_t stashMap;
QStringList branchList;
QStringList tagList;
QStringMap tags;
QStandardItemModel repoFileModel;
QStandardItemModel repoDirModel;