diff --git a/src/IDF/Scm/Monotone.php b/src/IDF/Scm/Monotone.php index 5ec5bfa..7a3c210 100644 --- a/src/IDF/Scm/Monotone.php +++ b/src/IDF/Scm/Monotone.php @@ -36,12 +36,12 @@ class IDF_Scm_Monotone extends IDF_Scm private static $instances = array(); /** - * @see IDF_Scm::__construct() + * Constructor */ - public function __construct($project) + public function __construct(IDF_Project $project, IDF_Scm_Monotone_IStdio $stdio) { $this->project = $project; - $this->stdio = new IDF_Scm_Monotone_Stdio($project); + $this->stdio = $stdio; } /** @@ -458,8 +458,9 @@ class IDF_Scm_Monotone extends IDF_Scm public static function factory($project) { if (!array_key_exists($project->shortname, self::$instances)) { + $stdio = new IDF_Scm_Monotone_Stdio($project); self::$instances[$project->shortname] = - new IDF_Scm_Monotone($project); + new IDF_Scm_Monotone($project, $stdio); } return self::$instances[$project->shortname]; } @@ -676,8 +677,8 @@ class IDF_Scm_Monotone extends IDF_Scm $parents = $this->stdio->exec(array('parents', $revs[0])); $res['parents'] = preg_split("/\n/", $parents, -1, PREG_SPLIT_NO_EMPTY); - - $certs = $this->_getCerts($revs[0]); + + $certs = $this->_getCerts($revs[0]); // FIXME: this assumes that author, date and changelog are always given $res['author'] = implode(', ', $certs['author']); diff --git a/src/IDF/Scm/Monotone/IStdio.php b/src/IDF/Scm/Monotone/IStdio.php new file mode 100644 index 0000000..b6cf544 --- /dev/null +++ b/src/IDF/Scm/Monotone/IStdio.php @@ -0,0 +1,66 @@ + + */ +interface IDF_Scm_Monotone_IStdio +{ + /** + * Constructor + */ + public function __construct(IDF_Project $project); + + /** + * Starts the stdio process and resets the command counter + */ + public function start(); + + /** + * Stops the stdio process and closes all pipes + */ + public function stop(); + + /** + * Executes a command over stdio and returns its result + * + * @param array Array of arguments + * @param array Array of options as key-value pairs. Multiple options + * can be defined in sub-arrays, like + * "r" => array("123...", "456...") + * @return string + */ + public function exec(array $args, array $options = array()); + + /** + * Returns the last out-of-band output for a previously executed + * command as associative array with 'e' (error), 'w' (warning), + * 'p' (progress) and 't' (ticker, unparsed) as keys + * + * @return array + */ + public function getLastOutOfBandOutput(); +} + diff --git a/src/IDF/Scm/Monotone/Stdio.php b/src/IDF/Scm/Monotone/Stdio.php index 86c4b50..c47e005 100644 --- a/src/IDF/Scm/Monotone/Stdio.php +++ b/src/IDF/Scm/Monotone/Stdio.php @@ -21,6 +21,8 @@ # # ***** END LICENSE BLOCK ***** */ +require_once 'IDF/Scm/Monotone/IStdio.php'; + /** * Monotone stdio class * @@ -29,7 +31,7 @@ * * @author Thomas Keller */ -class IDF_Scm_Monotone_Stdio +class IDF_Scm_Monotone_Stdio implements IDF_Scm_Monotone_IStdio { /** this is the most recent STDIO version. The number is output at the protocol start. Older versions of monotone (prior 0.47) @@ -68,7 +70,7 @@ class IDF_Scm_Monotone_Stdio * * @return string */ - public function _getAuthOptions() + private function _getAuthOptions() { $prjconf = $this->project->getConf(); $name = $prjconf->getVal('mtn_client_key_name', false); diff --git a/src/IDF/Scm/Monotone/ZipRender.php b/src/IDF/Scm/Monotone/ZipRender.php index 41f9f7d..eddc4fc 100644 --- a/src/IDF/Scm/Monotone/ZipRender.php +++ b/src/IDF/Scm/Monotone/ZipRender.php @@ -24,7 +24,7 @@ require_once(IDF_PATH.'/../contrib/zipstream-php-0.2.2/zipstream.php'); /** - * Special response object to output + * Special response object to output * * The Content-Length will not be set as it is not possible to predict it. * @@ -45,7 +45,7 @@ class IDF_Scm_Monotone_ZipRender extends Pluf_HTTP_Response private $stdio = null; private $revision = null; - function __construct($stdio, $revision) + function __construct(IDF_Scm_Monotone_IStdio $stdio, $revision) { parent::__construct($revision, 'application/x-zip'); $this->stdio = $stdio;