a new CVS-client module
| From: | Shie Erlich | Date: | Wed, 14 Apr 2004 17:49:06 +0000 |
| Subject: | a new CVS-client module | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-552@lists.php.net to get a copy of this message | ||
hi people,
i've written a new extention that handles CVS operations, by using the CVS executable.
i'd like to add it to the PECL repository. it's already working, although i'm sure it has
some bugs (maybe the diff needs more complex inputs) - but as i said, it's working.
==> Right now, only the PSERVER authentication method is supported <==
The following functions are available:
string scvs_get_host()
int scvs_get_authMethod() - returns SCVS_AUTH_PSERVER or SCVS_AUTH_EXT
int scvs_get_compressionLevel() - returns 0..3
string scvs_get_username()
string scvs_get_cvsroot()
string scvs_get_moduleName()
string scvs_get_workingDir()
scvs_set_host(string hostname)
scvs_set_authMethod(int method) - SCVS_AUTH_PSERVER or SCVS_AUTH_EXT supported
scvs_set_compressionLevel(int level) - level can be 0..3
scvs_set_username(string username)
scvs_set_cvsroot(string cvsroot)
scvs_set_moduleName(string modulename)
scvs_set_workingDir(string workingdir)
Boolean scvs_checkout() - checks out the module to the working directory
Boolean scvs_commit(string msg, string args) - commits 'args' using message 'msg'
array scvs_status(string relativePath) - runs a STATUS command, and returns an
array containing the results. the array contains pairs of {filename, status},
such that $array[0]='1st filename', $array[1]=stat1, $array[2]='2nd name' etc.
Status is defined as one of the SCVS_STAT_* constants defined below
array scvs_diff(string path) - runs a DIFF over a filename specified in path.
array contains multiple arrays, each one can be one of the following:
{SCVS_DIFF_ADDED, int line#, string str1} or
{SCVS_DIFF_REMOVED, int line#, string str1} or
{SCVS_DIFF_CHANGED, int line#, string beforeStr, string afterStr}
Boolean scvs_login() - attempts to login
array scvs_update(path) - performs an UPDATE command using 'path'
array contains pairs of {filename, status},
such that $array[0]='1st filename', $array[1]=stat1, $array[2]='2nd name' etc.
Status is defined as one of the SCVS_STAT_* constants defined below
The following constants are declard by this module:
(authentican methods)
SCVS_AUTH_PSERVER
SCVS_AUTH_EXT
(file status)SCVS_STAT_UPTODATE - file is up to date SCVS_STAT_MODIFIED - file was locally modified SCVS_STAT_NEEDS_PATCH - file needs patch from repository SCVS_STAT_NEEDS_MERGE - file needs merge from repository SCVS_STAT_NEEDS_CHECKOUT - file needs checkout SCVS_STAT_CONFLICT - conflict was detected (by STATUS or UPDATE) SCVS_STAT_ADDED - file was locally added and needs a COMMIT SCVS_STAT_REMOVED - file was locally removed and needs a COMMIT SCVS_STAT_UPDATED - file was updated (by UPDATE) SCVS_STAT_PATCHED - file was patched (by UPDATE) SCVS_STAT_NOTINCVS - file is not in CVS
(diff)SCVS_DIFF_ADDED - this line was added SCVS_DIFF_REMOVED - this line was removed SCVS_DIFF_CHANGED - this line has changed A typical usage script (almost without error checking) -------------------------- // set arguments for CVSROOT scvs_set_host("cvs.sourceforge.net"); scvs_set_authMethod(SCVS_AUTH_PSERVER); scvs_set_compressionLevel(3); scvs_set_userName("username"); scvs_set_cvsroot("/cvsroot/project"); scvs_set_moduleName("moduleName"); scvs_set_workingDir("/usr/tmp/test"); scvs_login("my secret password"); if (scvs_checkout() == 0) print("failed during checkout"); $tmp = scvs_update("subFolder"); for ($i=0; $i<count($tmp); $i+=2) {
print $tmp[$i]." (".$tmp[$i+1].")\n";
}
$tmp = scvs_commit("commiting to subFolder","subFolder/");
comments are very welcome!
bye,
--
//
// Shie Erlich
//
// shie@zend.com
// erlich@users.sourceforge.net
//