#include "FileEntry.h"
#include "P4Client.h"
#include <qstringlist.h>
namespace Perforce
{
QDict< FileEntry::FileEntryCache > FileEntry::_fileEntryCaches;
const FileEntryList& FileEntry::getFileEntries( const QString depotPath )
{
FileEntryCache* cache = _fileEntryCaches.find( depotPath );
if (cache == NULL) {
cache = new FileEntryCache();
cache->_depotPath = depotPath;
_fileEntryCaches.insert( depotPath, cache );
}
cache->updateCacheIfNecessary();
return cache->getCache();
}
void FileEntry::FileEntryCache::HandleError( Error* err )
{
qWarning( "Failed to update file entry cache." );
}
void FileEntry::FileEntryCache::OutputStat( StrDict* varList )
{
QString temp;
FileEntry* f = new FileEntry();
f->setDepotFile( varList->GetVar("depotFile")->Text() );
f->setClient( varList->GetVar("clientFile")->Text() );
temp = varList->GetVar( "headRev" )->Text();
f->setRevision( temp.toInt() );
f->setAction( varList->GetVar("headAction")->Text() );
f->setChange( varList->GetVar("headChange")->Text() );
f->setType( varList->GetVar("headType")->Text() );
QStringList lst = QStringList::split( "/", f->getDepotFile() );
f->setName( lst.last() );
// f->setUser( varList->GetVar("user")->Text() );
// f->setClient( varList->GetVar("client")->Text() );
_cache.append( f );
}
void FileEntry::FileEntryCache::updateCache()
{
QString temp = _depotPath + "/*";
char* p[] = { "-C", const_cast<char *>(temp.latin1()) };
RunP4Command( 2, p, "fstat", this );
}
}