forked from qt-creator/qt-creator
Vcs: Re-implement Fossil's topic indicator using a TopicCache sub-class
The functionality for tracking project's current topic/branch has long been folded into a base class Core::IVersionControl::TopicCache. Fossil plugin should just sub-class it and pass the instance to the base. Change-Id: I1b6c1631f5fc10987d8a608d573defeecbc31b37 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -568,36 +568,17 @@ QString FossilClient::synchronousGetRepositoryURL(const QString &workingDirector
|
||||
return output;
|
||||
}
|
||||
|
||||
struct TopicData
|
||||
{
|
||||
QDateTime timeStamp;
|
||||
QString topic;
|
||||
};
|
||||
|
||||
QString FossilClient::synchronousTopic(const QString &workingDirectory)
|
||||
{
|
||||
static QMap<QString, TopicData> topicCache;
|
||||
|
||||
if (workingDirectory.isEmpty())
|
||||
return QString();
|
||||
|
||||
// return current branch name
|
||||
|
||||
const QString topLevel = findTopLevelForFile(workingDirectory);
|
||||
const QFileInfo currentStateFile(topLevel + "/" + Constants::FOSSILREPO);
|
||||
|
||||
TopicData &data = topicCache[workingDirectory];
|
||||
const QDateTime lastModified = currentStateFile.lastModified();
|
||||
if (lastModified == data.timeStamp)
|
||||
return data.topic;
|
||||
|
||||
const BranchInfo branchInfo = synchronousCurrentBranch(workingDirectory);
|
||||
if (branchInfo.name().isEmpty())
|
||||
return QString();
|
||||
|
||||
data.timeStamp = lastModified;
|
||||
data.topic = branchInfo.name();
|
||||
return data.topic;
|
||||
return branchInfo.name();
|
||||
}
|
||||
|
||||
bool FossilClient::synchronousCreateRepository(const QString &workingDirectory, const QStringList &extraOptions)
|
||||
|
||||
Reference in New Issue
Block a user