forked from qt-creator/qt-creator
VCS: Make initialization of a repo trigger updateActions
Make initialization/cloning of a repo trigger an updateActions. This is needed to e.g. enable git actions after a git repo is created. Reviewed-by: Hugues Delorme Change-Id: Ia8513a216e584fe8e512fdd5d6215aa96c075f3f Reviewed-on: http://codereview.qt-project.org/4878 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -85,9 +85,13 @@ public:
|
||||
qDeleteAll(m_vcsInfoList);
|
||||
}
|
||||
|
||||
VcsInfo *findInCache(const QString &directory)
|
||||
VcsInfo *findInCache(const QString &dir)
|
||||
{
|
||||
const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(directory);
|
||||
Q_ASSERT(QDir(dir).isAbsolute());
|
||||
Q_ASSERT(!dir.endsWith(QLatin1Char('/')));
|
||||
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir);
|
||||
|
||||
const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(dir);
|
||||
if (it != m_cachedMatches.constEnd())
|
||||
return it.value();
|
||||
return 0;
|
||||
@@ -108,9 +112,25 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
void cache(IVersionControl *vc, const QString topLevel, const QString directory)
|
||||
void resetCache(const QString &dir)
|
||||
{
|
||||
Q_ASSERT(directory.startsWith(topLevel));
|
||||
Q_ASSERT(QDir(dir).isAbsolute());
|
||||
Q_ASSERT(!dir.endsWith(QLatin1Char('/')));
|
||||
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir);
|
||||
|
||||
const QString dirSlash = dir + QLatin1Char('/');
|
||||
foreach (const QString &key, m_cachedMatches.keys()) {
|
||||
if (key == dir || key.startsWith(dirSlash))
|
||||
m_cachedMatches.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
void cache(IVersionControl *vc, const QString topLevel, const QString dir)
|
||||
{
|
||||
Q_ASSERT(QDir(dir).isAbsolute());
|
||||
Q_ASSERT(!dir.endsWith(QLatin1Char('/')));
|
||||
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir);
|
||||
Q_ASSERT(dir.startsWith(topLevel));
|
||||
|
||||
VcsInfo *newInfo = new VcsInfo(vc, topLevel);
|
||||
bool createdNewInfo(true);
|
||||
@@ -126,7 +146,7 @@ public:
|
||||
if (createdNewInfo)
|
||||
m_vcsInfoList.append(newInfo);
|
||||
|
||||
QString tmpDir = directory;
|
||||
QString tmpDir = dir;
|
||||
while (tmpDir.count() >= topLevel.count() && tmpDir.count() > 0) {
|
||||
m_cachedMatches.insert(tmpDir, newInfo);
|
||||
int slashPos = tmpDir.lastIndexOf(SLASH);
|
||||
@@ -168,6 +188,17 @@ static bool longerThanPath(QPair<QString, IVersionControl *> &pair1, QPair<QStri
|
||||
return pair1.first.size() > pair2.first.size();
|
||||
}
|
||||
|
||||
void VcsManager::resetVersionControlForDirectory(const QString &inputDirectory)
|
||||
{
|
||||
if (inputDirectory.isEmpty())
|
||||
return;
|
||||
|
||||
const QString directory = QDir(inputDirectory).absolutePath();
|
||||
|
||||
d->resetCache(directory);
|
||||
emit repositoryChanged(directory);
|
||||
}
|
||||
|
||||
IVersionControl* VcsManager::findVersionControlForDirectory(const QString &inputDirectory,
|
||||
QString *topLevelDirectory)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user