Indefero

Indefero Commit Details


Date:2011-03-22 18:47:17 (13 years 8 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:78a040235148d52eb39dfa8ac55872895c29f38a
Parents: 5b5705fe906670b5533fa9f6bd3759695887aeea
Message:Prepare the Stdio class for easier testing. - create an interface that describes the basic methods - let the real stdio class implement this interface - inject the stdio instance into IDF_Scm_Monotone and do not create it in the constructor - ensure in IDF_Scm_Monotone_ZipRender that we get the proper constructor arguments On a slighly unrelated note, make _getAuthOptions() in the stdio implementation private.

Changes:

File differences

src/IDF/Scm/Monotone.php
3636
3737
3838
39
39
4040
41
41
4242
4343
44
44
4545
4646
4747
......
458458
459459
460460
461
461462
462
463
463464
464465
465466
......
676677
677678
678679
679
680
680
681
681682
682683
683684
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;
}
/**
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];
}
$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']);
src/IDF/Scm/Monotone/IStdio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Monotone stdio interface
*
* @author Thomas Keller <me@thomaskeller.biz>
*/
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();
}
src/IDF/Scm/Monotone/Stdio.php
2121
2222
2323
24
25
2426
2527
2628
......
2931
3032
3133
32
34
3335
3436
3537
......
6870
6971
7072
71
73
7274
7375
7476
#
# ***** END LICENSE BLOCK ***** */
require_once 'IDF/Scm/Monotone/IStdio.php';
/**
* Monotone stdio class
*
*
* @author Thomas Keller <me@thomaskeller.biz>
*/
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)
*
* @return string
*/
public function _getAuthOptions()
private function _getAuthOptions()
{
$prjconf = $this->project->getConf();
$name = $prjconf->getVal('mtn_client_key_name', false);
src/IDF/Scm/Monotone/ZipRender.php
2424
2525
2626
27
27
2828
2929
3030
......
4545
4646
4747
48
48
4949
5050
5151
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.
*
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;

Archive Download the corresponding diff file

Page rendered in 0.08692s using 13 queries.