[phpcvsview-cvs-updates] phpcvsview phpcvs.php,1.8,1.9
Status: Pre-Alpha
Brought to you by:
bcheesem
From: Brian C. <bch...@us...> - 2004-10-02 00:32:19
|
Update of /cvsroot/phpcvsview/phpcvsview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9802 Modified Files: phpcvs.php Log Message: Added basic annotation capabilities to the CVS_PServer class. Index: phpcvs.php =================================================================== RCS file: /cvsroot/phpcvsview/phpcvsview/phpcvs.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** phpcvs.php 29 Sep 2004 10:57:59 -0000 1.8 --- phpcvs.php 2 Oct 2004 00:32:08 -0000 1.9 *************** *** 16,27 **** class CVS_PServer { ! var $CVS_REPOSITORY; // Storage of the CVS Repository file system path. ! var $CVS_USERNAME; // Username to use when authenticating with the PServer. ! var $CVS_PASSWORD; // Password for the account above. ! var $CVS_PSERVER; // Hostname of the server running the PServer. ! var $CVS_PORT; // Port number the PServer listener is running on. ! var $CVS_TIMEOUT; // Timeout in seconds for all socket operations. ! var $CVS_VALID_REQUESTS; // List of valid requests the PServer accepts. ! var $SOCKET; // The socket handle for communicating with the PServer. var $ALLOWED_RESPONSES = array( // A hashed array of responses that we are capable of // processing and the contents is the name of the function --- 16,27 ---- class CVS_PServer { ! var $CVS_REPOSITORY; // Storage of the CVS Repository file system path. ! var $CVS_USERNAME; // Username to use when authenticating with the PServer. ! var $CVS_PASSWORD; // Password for the account above. ! var $CVS_PSERVER; // Hostname of the server running the PServer. ! var $CVS_PORT; // Port number the PServer listener is running on. ! var $CVS_TIMEOUT; // Timeout in seconds for all socket operations. ! var $CVS_VALID_REQUESTS; // List of valid requests the PServer accepts. ! var $SOCKET; // The socket handle for communicating with the PServer. var $ALLOWED_RESPONSES = array( // A hashed array of responses that we are capable of // processing and the contents is the name of the function *************** *** 61,72 **** var $ALLOWED_REQUESTS = array(); // A hashed array of requests we are allowed to send. ! var $FINAL_RESPONSE; // A state variable for tracking whether the final response ! // in a chain of lines was a success or failure. ! var $STDERR; // Standard Error output. (Does not mean that an error occured). ! var $MESSAGE_CONTENT; // Message contents. (Standard Out) var $FOLDERS = array(); // An array of the folders in the current module. var $FILES = array(); // An array of the files in the current module. ! var $CURRENT_FOLDER; // The current folder we are building up. ! var $CURRENT_FILE; // The current file we are building up. /** --- 61,73 ---- var $ALLOWED_REQUESTS = array(); // A hashed array of requests we are allowed to send. ! var $FINAL_RESPONSE; // A state variable for tracking whether the final response ! // in a chain of lines was a success or failure. ! var $STDERR; // Standard Error output. (Does not mean that an error occured). ! var $MESSAGE_CONTENT; // Message contents. (Standard Out) var $FOLDERS = array(); // An array of the folders in the current module. var $FILES = array(); // An array of the files in the current module. ! var $CURRENT_FOLDER; // The current folder we are building up. ! var $CURRENT_FILE; // The current file we are building up. ! var $ANNOTATION = array(); // An array of the lines in the file which has been annotated. /** *************** *** 477,480 **** --- 478,593 ---- } + // *************************************************************************** + // Function: sendDirectory() + // Author: Brian A Cheeseman. + // Parameters: string - Directory to pass to the directory command. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendDirectory($Directory) + { + if ($this->ALLOWED_REQUESTS["Directory"] == true) { + if (strncmp($Directory, "/", 1) == 0) { + $Directory = substr($Directory, 1); + } + if ($this->SOCKET->write("Directory $Directory\n") == true) { + $Line = $this->CVS_REPOSITORY; + if ($Directory != ".") { + $Line .= "/" . $Directory; + } + if ($this->SOCKET->write("$Line\n") != true) { + return false; + } + } + else + { + return false; + } + } + return true; + } + + // *************************************************************************** + // Function: sendStaticDirectory() + // Author: Brian A Cheeseman. + // Parameters: None. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendStaticDirectory() + { + if ($this->ALLOWED_REQUESTS["Static-directory"] == true) { + if ($this->SOCKET->write("Static-directory\n") != true) { + return false; + } + } + return true; + } + + // *************************************************************************** + // Function: sendEntry() + // Author: Brian A Cheeseman. + // Parameters: string - $Name - Name of the file. + // string - $Version - Version of the file. + // string - $Conflict - + // string - $Options - Options for the entry line. + // string - $TagOrDate - Another method of identifying the version. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendEntry($Name = "", $Version = "", $Conflict = "", $Options = "", $TagOrDate = "") + { + if ($this->ALLOWED_REQUESTS["Entry"] == true) { + if (strrpos($Name, "/") > -1) { + $FName = substr($Name, strrpos($Name, "/")+1); + } + else + { + $FName = $Name; + } + if ($this->SOCKET->write("Entry /$FName/$Version/$Conflict/$Options/$TagOrDate\n") != true) { + return false; + } + } + return true; + } + + // *************************************************************************** + // Function: sendUnchanged() + // Author: Brian A Cheeseman. + // Parameters: string - $Name - Name of the file. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendUnchanged($Name) + { + if ($this->ALLOWED_REQUESTS["Unchanged"] == true) { + $SlashPos = strrpos($Name, "/"); + if ($SlashPos !== false) { + $BaseFileName = substr($Name, $SlashPos+1); + } + else + { + $BaseFileName = $Name; + } + if ($this->SOCKET->write("Unchanged $BaseFileName\n") != true) { + return false; + } + } + return true; + } + + // *************************************************************************** + // Function: sendAnnotate() + // Author: Brian A Cheeseman. + // Parameters: None. + // Return Value: boolean - Successfully sent. + // *************************************************************************** + function sendAnnotate() + { + if ($this->ALLOWED_REQUESTS["annotate"] == true) { + if ($this->SOCKET->write("annotate\n") != true) { + return false; + } + } + return true; + } + /** * Helper Methods. *************** *** 521,524 **** --- 634,638 ---- $FileRevision = -1; $CurrentRevision = ""; + $PreviousRevision = ""; $LineProcessed = false; if ($this->FINAL_RESPONSE) { *************** *** 555,558 **** --- 669,673 ---- $CurrentDecode = 2; $LineProcessed = true; + } } *************** *** 629,632 **** --- 744,751 ---- $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["Revision"] = $CurrentRevision; $this->FILES[$FileCount]["Revisions"]["$CurrentRevision"]["LogMessage"] = ""; + if ($PreviousRevision != "") { + $this->FILES[$FileCount]["Revisions"]["$PreviousRevision"]["PrevRevision"] = $CurrentRevision; + } + $PreviousRevision = $CurrentRevision; $LineProcessed = true; } *************** *** 671,674 **** --- 790,876 ---- } } + + // *************************************************************************** + // Function: Annotate() + // Author: Brian A Cheeseman. + // Parameters: string - Directory to get the RLog for. + // Return Value: boolean - Were we successful. + // *************************************************************************** + function Annotate($Name, $Revision = "") + { + $this->sendCVSROOT(); + $this->sendValidResponses(); + $this->sendValidRequests(); + + if (!$this->sendUseUnchanged()) { + return false; + } + + if (!$this->sendArgument("--")) { + return false; + } + + $SlashPos = strrpos($Name, "/"); + if ($SlashPos > -1) { + $Directory = substr($Name, 0, $SlashPos); + } + else + { + $Directory = "/"; + } + + if (!$this->sendDirectory($Directory)) { + return false; + } + + if (!$this->sendStaticDirectory()) { + return false; + } + + if (!$this->sendEntry($Name, $Revision)) { + return false; + } + + if (!$this->sendUnchanged($Name)) { + return false; + } + + if (!$this->sendDirectory(".")) { + return false; + } + + if (strncmp($Name, "/", 1) == 0) { + $Arg = substr($Name, 1); + } + else + { + $Arg = $Name; + } + if (!$this->sendArgument($Arg)) { + return false; + } + + if (!$this->sendAnnotate()) { + return false; + } + + $this->processResponse(); + + if ($this->FINAL_RESPONSE) { + $Counter = 0; + $Responses = explode("\n", $this->MESSAGE_CONTENT); + // Iterate through each line. + foreach ($Responses as $Line) + { + $this->ANNOTATION[$Counter]["Revision"] = strtok($Line, "("); + $this->ANNOTATION[$Counter]["Author"] = strtok(" "); + $this->ANNOTATION[$Counter]["Date"] = strtok(")"); + $this->ANNOTATION[$Counter]["Line"] = substr(strtok("\n"), 2); + $Counter++; + } + } + + return true; + } } |