// // Copyright 2000 Perforce Software. All rights reserved. // // This file is part of Perforce - the FAST SCM System. // // ------------------------------------- // Includes // #include <p4wp4.h> #include <changeshelper.h> // ------------------------------------- // Constructors and destructor. // ChangesHelper::ChangesHelper( ClientApi & api, const StrPtr & path, unsigned int maxResults, const StrPtr * user, const StrPtr * client ) : ClientUser() { this->api = &api; this->pathSpec = path; this->maxResults = maxResults ? maxResults : 1; this->totalResults = 0; this->results = NULL; if ( user ) this->user = *user; if ( client ) this->client = *client; } ChangesHelper::~ChangesHelper() { if (results) { if (totalResults) { int i; for (i = -1; ++i < totalResults; ) { if (results[i]) delete results[i]; } } delete results; } } void ChangesHelper::OutputStat( StrDict * varList ) { this->results[ totalResults ] = new StrBufDict( *varList ); totalResults++; } int ChangesHelper::HighestChangeNumber() { GetResults(); return ChangeNumber( 0 ); } int ChangesHelper::LowestChangeNumber() { GetResults(); return ChangeNumber( totalResults - 1 ); } int ChangesHelper::Contains( unsigned int changeNumber ) { unsigned int result = 0; GetResults(); for (int i = 0; i < totalResults; i++) { if ( ChangeNumber( i ) == changeNumber ) return 1; } return 0; } StrDict ** ChangesHelper::GetResults() { // // Check to see if results were already retrieved // if not, get them // if ( !results ) { char *args[1000]; // // Find out how many file paths were given char *q; char *p = pathSpec.Text(); int i = 1; while (q = strstr( p, " | " )) { p = q+3; i++; } // // we need to store results for maxResults * number-of-file-paths results = (StrBufDict **)new void *[ maxResults * i ]; i = 0; StrBuf tempmax; if ( maxResults > 0 ) { tempmax << maxResults; // // -m <numChanges> args[i++] = "-m"; args[i++] = tempmax.Text(); } if (client.Length()) { args[i++] = "-c"; args[i++] = client.Text(); } if (user.Length()) { args[i++] = "-u"; args[i++] = user.Text(); } // // -s submitted args[i++] = "-s"; args[i++] = "submitted"; // // If this is the root directory, don't append // the path because "p4 changes //..." is much more // server-intensive than simple "p4 changes", and // the latter command is equivalent. if( pathSpec != "//..." ) { p = pathSpec.Text(); if (strncmp(p, "////", 4) == 0) p += 2; else if (strncmp(p, "//\"//", 4) == 0) p += 3; q = strstr( p, " | " ); if (q) { *q++ = '\0'; if (*(q-2) == '\"') *(q-2) = '\0'; } args[i++] = p; while (q) { p = q; *q++ = '/'; *q++ = '/'; if (strncmp(p, "////", 4) == 0) p += 2; else if (strncmp(p, "//\"//", 4) == 0) p += 3; else if (strncmp(p, "//-//", 5) == 0) p += 2; q = strstr( p, " | " ); if (q) { *q++ = '\0'; if (*(q-2) == '\"') *(q-2) = '\0'; } args[i++] = p; } p += strlen(p) - 1; if (*p == '\"') *p = '\0'; } this->api->SetArgv( i, args ); this->api->Run( P4Tag::u_changes, this ); } return (StrDict **)results; } StrDict * ChangesHelper::GetResult( unsigned int index ) { GetResults(); if ( index < totalResults ) { return results[ index ]; } else { return NULL; } } unsigned int ChangesHelper::TotalResults() { GetResults(); return totalResults; } int ChangesHelper::ChangeNumber( unsigned int index ) { int result = -1; GetResults(); if ( totalResults ) { if ( index < totalResults ) { StrPtr * change = results[ index ]->GetVar( "change"); if ( change ) { StrRef temp2( change->Text() ); result = StrOps::UnpackIntA( temp2 ); } } } return result; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12234 | Matt Attaway |
Rejigger P4Web project in preparation for official sunsetting The bin directory contains the last official builds of P4Web from the Perforce download site. P4Web is soon to be completely sunsetted; these builds are here for folks who don't want to build their own. To better handle the archived builds the source code has been moved into a separate src directory. |
||
//guest/perforce_software/p4web/util/changeshelper.cpp | |||||
#1 | 8914 | Matt Attaway | Initial add of the P4Web source code |