// FileLogCache.cpp: implementation of the FileLogCache class. // ////////////////////////////////////////////////////////////////////// #include "FileLogCache.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// /* Create a new FileLogCache. After a FileLogCache has been constructed, * not much else needs to be done to it. */ FileLogCache::FileLogCache(StrBuf filepath) { changes = new ChangeSorter(); main = new FileHead(filepath, this); //Create the "main" FileHead. StrBuf rot = StrBuf(); //An empty StrBuf. from = NULL; into = NULL; main->scanFrom(rot); //check all revs in "main" for ancestors. main->scanInto(rot, NULL); //check all revs in "main" for descendants. } FileHead* FileLogCache::AddFrom(StrBuf filepath) { if (from == NULL) //If we don't have any "from" FileHeads yet: { from = new FileHead(filepath, this); return from; } //otherwise: FileHead* working = from; //this is the first one in the line. while (working->next != NULL) { working = working->next;} //find the last one. working->next = new FileHead(filepath, this); //tack a new FileHead on there. return working->next; //return it. } /*AddInto works much like AddFrom - I don't think it needs explanation. */ FileHead* FileLogCache::AddInto(StrBuf filepath) { if (into == NULL) { into = new FileHead(filepath, this); return into; } FileHead* working = into; while (working->next != NULL) { working = working->next;} working->next = new FileHead(filepath, this); return working->next; } FileHead* FileLogCache::Get(StrBuf filepath, bool exfrom) { if (main->file == filepath){ //Was it main? return main; } FileHead* working = from; //Is it in from? while (working != NULL) { if (working->file == filepath) return working; working = working->next; } working = into; //Is it in into? while (working != NULL) { if (working->file == filepath) return working; working = working->next; } /* Make a new one, then. */ if (exfrom) return AddFrom(filepath); else return AddInto(filepath); } FileLogCache::~FileLogCache() //Clean up everything when deleting this object. { if (main != NULL) delete main; if (from != NULL) delete from; if (into != NULL) delete into; delete changes; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 937 | Sam Stafford |
Renaming my guest directory to the more conventional sam_stafford. |
||
#1 | 936 | Sam Stafford |
Adding P4HL to the public depot. See relnotes.txt for installation instructions; all relevant files are under p4hl/dist. Source code is under p4hl/src in the form of a VC++ project. |