#include "BranchSpec.h"
#include "P4Client.h"
#include <qstringlist.h>
static const char* lockNames[] = {
"Locked",
"Unlocked"
};
namespace Perforce {
BranchSpec::BranchSpecCache Perforce::BranchSpec::_branchSpecCache;
QString BranchSpec::lockToString( Lock l )
{
ASSERT( l >= 0 && l <= 1 );
return lockNames[ l ];
}
void BranchSpec::BranchSpecCache::OutputStat( StrDict *varList )
{
ASSERT( varList != NULL );
// DumpDict( varList );
BranchSpec* bs = new BranchSpec();
bs->_branchName = varList->GetVar( "branch" )->Text();
bs->_branchName.stripWhiteSpace();
QString temp = varList->GetVar( "Update" )->Text();
bs->_date.setTime_t( temp.toInt() );
bs->_description = varList->GetVar( "Description" )->Text();
bs->_description.stripWhiteSpace();
replaceNewlinesWithSpaces( bs->_description );
temp = varList->GetVar( "Options" )->Text();
if (temp.find("unlocked") != -1) {
bs->_lock = Locked;
} else {
bs->_lock = Unlocked;
}
bs->_owner = varList->GetVar( "Owner" )->Text();
bs->_owner.stripWhiteSpace();
_cache.append( bs );
}
void BranchSpec::BranchSpecCache::updateCache()
{
char* p [] = { "" };
RunP4Command( 0, p, "branches", this );
}
const BranchSpecList& BranchSpec::getBranches()
{
_branchSpecCache.updateCacheIfNecessary();
return _branchSpecCache.getCache();
}
} // end namespace