// Implementation of FileLogCache #include <clientapi.h> #include "changesorter.h" #include "filehead.h" #include "filelogcache.h" // After the FileLogCache constructor returns, the entire data structure // has been laid out and is ready to use. FileLogCache::FileLogCache ( StrBuf filepath, ClientApi* cli, Error* e, const char* cst, const char* dst, const char* en, bool all, char* cfile ) : client( cli ), errors ( e ), numarrows( 0 ), size( 1 ), changes( new ChangeSorter() ), from( NULL ), into ( NULL ), cstart( cst ), dstart( dst ), end( en ), showall( all ), cachefile( cfile ) { main = new FileHead( filepath, this ); //Create the "main" FileHead. main->loc = cl_main; head = main; tail = main; client->WaitTag(); //flesh out "main" before scan! main->scanMain(); //check all revs in "main" } FileHead* FileLogCache::AddFrom( StrBuf filepath ) { size++; if ( !from ) // this is the first "from" FH { from = new FileHead( filepath, this ); from->loc = cl_from; head = from; from->next_into = main; main->next_from = from; } else // otherwise, insert this as the new "from" { FileHead* working = new FileHead( filepath, this ); working->loc = cl_from; working->next = from; main->next_from = working; working->next_into = main; from->next_into = working; working->next_from = from; from = working; } return from; } // AddInto works much like AddFrom. FileHead* FileLogCache::AddInto( StrBuf filepath ) { size++; if ( !into ) { into = new FileHead( filepath, this ); into->loc = cl_into; into->next_from = main; main->next_into = into; } else { FileHead* working = new FileHead( filepath, this ); working->loc = cl_into; working->next = into; main->next_into = working; working->next_from = main; into->next_from = working; working->next_into = into; into = working; } return into; } // Insert the new FileHead one place after the caller, where "after" // means farther away from "main". FileHead* FileLogCache::AddAfter( StrBuf filepath, FileHead* caller ) { size++; if ( caller == main ) return AddFrom( filepath ); FileHead* working = new FileHead( filepath, this ); working->loc = caller->loc; working->next = caller->next; caller->next = working; switch ( caller->loc ) { case cl_from: if ( caller == head ) head = working; working->next_from = caller->next_from; working->next_into = caller; if ( caller->next_from ) caller->next_from->next_into = working; caller->next_from = working; break; case cl_into: if ( caller == tail ) tail = working; working->next_into = caller->next_into; working->next_from = caller; if ( caller->next_into ) caller->next_into->next_from = working; caller->next_into = working; break; } return working; } FileHead* FileLogCache::Get( StrBuf& filepath, bool exfrom, FileHead* caller ) { // If this is a Windows server, do case insensitive compares. if ( client->GetProtocol( "nocase" ) ) return GetI( filepath, exfrom, caller ); // Check for an existing FileHead matching that path. for ( FileHead* fh = head ; fh ; fh = fh->next_into ) if ( fh->name == filepath ) return fh; // If it doesn't exist, create it. // If the caller was "main", use AddFrom/Into if ( caller == main ) { if ( exfrom ) return AddFrom( filepath ); else return AddInto( filepath ); } else { return AddAfter( filepath, caller ); } } FileHead* FileLogCache::GetI( StrBuf& filepath, bool efrom, FileHead* caller ) { // Check for an existing FileHead matching that path. for ( FileHead* fh = head ; fh ; fh = fh->next_into ) if ( !fh->name.CCompare( filepath ) ) return fh; // Make a new one, then. if ( caller == main ) //If the caller was "main"... { if ( efrom ) return AddFrom( filepath ); else return AddInto( filepath ); } else { return AddAfter( filepath, caller ); } } // This sets the FLC up for supporting graphs that omit uninteged edits. void FileLogCache::SetArrows() { for ( FileHead* fh = head; fh; fh = fh->next_into ) { for ( FileRev* fr = fh->head; fr; fr = fr->next ) { if ( fr == fh->head || !fr->next ) { fr->hasarrow = true; changes->MarkArrChange( fr->change ); } for ( FileRevArrow* fra = fr->fromarrows ; fra ; fra = fra->next ) { if ( fra->type != edit ) { fr->hasarrow = true; changes->MarkArrChange( fr->change ); fra->ptr->hasarrow = true; changes->MarkArrChange( fra->ptr->change ); } } } } changes->AlignArr(); } // Clean up all FileHeads when deleting the FLC. FileLogCache::~FileLogCache() { if ( main ) delete main; if ( from ) delete from; if ( into ) delete into; delete changes; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 2946 | Sam Stafford |
Pull in read-filelogs-from-file capabilities. No functional change yet. |
||
#3 | 2398 | Sam Stafford |
Support for PB's "show all" feature. Still needs the UI bits to turn it on. Infrastructure change. |
||
#2 | 2380 | Sam Stafford |
At some point I want to go around and get the integ records tween P4HL and P4QTree to reflect their relationship. Here's a start. |
||
#1 | 2377 | Sam Stafford | P4QTree. |