Indefero

Indefero Commit Details


Date:2010-06-23 18:58:41 (14 years 5 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, master, release-1.1, release-1.2, release-1.3
Commit:1fd1e630437bdf7e94a25053d5b67d6a1272be16
Parents: 5ce324f35f2b43a8cd28141dc8eb688b92e444c2
Message:* idf.php-dist: rework the documentation of the configuration options and add two scenarios, one with a single, global database and one with multiple project databases and usher as proxy; add an option for additional command line options for the mtn process; remove the protocol type configuration option - we're handling this implicit with the new mtn_remote_url configuration * Monotone.php: add the IDF user for ssh:// URIs; add support for remote_stdio and rework the command line stitching

Changes:

File differences

src/IDF/Scm/Monotone.php
3636
3737
3838
39
39
4040
4141
4242
......
4646
4747
4848
49
49
5050
51
51
5252
53
53
5454
5555
5656
......
7070
7171
7272
73
74
75
76
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
77102
78103
79104
......
369394
370395
371396
372
397
373398
374
375399
376
400
377401
378402
379403
......
381405
382406
383407
384
408
409
410
411
412
385413
386414
387415
388
389
390416
391
417
392418
393419
394420
......
821847
822848
823849
824
825
826
850
851
827852
828
829
830
831
832
853
833854
834855
835
836
837
838
839
856
840857
841858
842859
......
844861
845862
846863
847
864
865
848866
849867
850868
......
855873
856874
857875
858
859
876
860877
861878
862879
do not output it and are therefor incompatible */
public static $SUPPORTED_STDIO_VERSION = 2;
private $repo;
private $project;
private $proc;
private $pipes;
private $oob;
/**
* Constructor - starts the stdio process
*
* @param string Repository path
* @param IDF_Project
*/
public function __construct($repo)
public function __construct(IDF_Project $project)
{
$this->repo = $repo;
$this->project = $project;
$this->start();
}
if (is_resource($this->proc))
$this->stop();
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
.sprintf("%s -d %s automate stdio --no-workspace --norc",
Pluf::f('mtn_path', 'mtn'),
escapeshellarg($this->repo));
$remote_db_access = Pluf::f('mtn_db_access', 'remote') == "remote";
$cmd = Pluf::f('idf_exec_cmd_prefix', '') .
Pluf::f('mtn_path', 'mtn') . ' ';
$opts = Pluf::f('mtn_opts', array());
foreach ($opts as $opt)
{
$cmd .= sprintf('%s ', escapeshellarg($opt));
}
// FIXME: we might want to add an option for anonymous / no key
// access, but upstream bug #30237 prevents that for now
if ($remote_db_access)
{
$host = sprintf(Pluf::f('mtn_remote_url'), $this->project->shortname);
$cmd .= sprintf('automate remote_stdio %s', escapeshellarg($host));
}
else
{
$repo = sprintf(Pluf::f('mtn_repositories'), $this->project->shortname);
if (!file_exists($repo))
{
throw new IDF_Scm_Exception(
"repository file '$repo' does not exist"
);
}
$cmd .= sprintf('--db %s automate stdio', escapeshellarg($repo));
}
$descriptors = array(
0 => array("pipe", "r"),
/**
* @see IDF_Scm::__construct()
*/
public function __construct($repo, $project=null)
public function __construct($project)
{
$this->repo = $repo;
$this->project = $project;
$this->stdio = new IDF_Scm_Monotone_Stdio($repo);
$this->stdio = new IDF_Scm_Monotone_Stdio($project);
}
/**
*/
public function getRepositorySize()
{
if (!file_exists($this->repo)) {
// FIXME: this obviously won't work with remote databases - upstream
// needs to implement mtn db info in automate at first
$repo = sprintf(Pluf::f('mtn_repositories'), $this->project->shortname);
if (!file_exists($repo))
{
return 0;
}
// FIXME: this won't work with remote databases - upstream
// needs to implement mtn db info in automate at first
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'du -sk '
.escapeshellarg($this->repo);
.escapeshellarg($repo);
$out = explode(' ',
self::shell_exec('IDF_Scm_Monotone::getRepositorySize', $cmd),
2);
}
}
$protocol = Pluf::f('mtn_remote_protocol', 'netsync');
if ($protocol == "ssh")
$remote_url = Pluf::f('mtn_remote_url', '');
if (empty($remote_url))
{
// ssh is protocol + host + db-path + branch
return "ssh://" .
sprintf(Pluf::f('mtn_remote_host'), $project->shortname) .
sprintf(Pluf::f('mtn_repositories'), $project->shortname) .
" " . $branch;
return '';
}
// netsync is the default
return sprintf(
Pluf::f('mtn_remote_host'),
$project->shortname
)." ".$branch;
return sprintf($remote_url, $project->shortname)."?".$branch;
}
/**
*/
public static function getAuthAccessUrl($project, $user, $commit = null)
{
return self::getAnonymousAccessUrl($project, $commit);
$url = self::getAnonymousAccessUrl($project, $commit);
return preg_replace("#^ssh://#", "ssh://$user@", $url);
}
/**
*/
public static function factory($project)
{
$rep = sprintf(Pluf::f('mtn_repositories'), $project->shortname);
return new IDF_Scm_Monotone($rep, $project);
return new IDF_Scm_Monotone($project);
}
/**
src/IDF/conf/idf.php-dist
7575
7676
7777
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
93130
94
95
96
97
98
131
132
133
134
135
136
137
138
139
140
141
142
99143
100144
101145
# Path to the monotone binary
$cfg['mtn_path'] = 'mtn';
# Same as for git, you can have multiple repositories, one for each
# project or a single one for all the projects. Beware though that
# if you want to setup separate write access for the projects, you
# you have to setup different databases for each one.
#
# To access an mtn repository remotely you have two possibilities,
# via ssh and monotone's own netsync protocol. Usually each repository
# has to serve its contents in a separate process, but there exists a tool,
# called "usher", which acts as single entry point and distributes incoming
# requests further, based either on a particular branch pattern or configured
# host name (similar to SNI, the Server Name Indication, of TLS).
#
# A full HOWTO set this up is beyond this scope, please refer to the
# documentation of monotone and / or ask on their mailing list / IRC channel
# (irc.oftc.net/#monotone)
# Additional options for the started monotone process
$cfg['mtn_opts'] = array('--no-workspace', '--norc');
#
# You can setup monotone for use with indefero in two ways:
#
# 1) One database for everything:
# Set 'mtn_repositories' below to a fixed database path, such as
# '/home/mtn/repositories/all_projects.mtn'
#
# Pro: - easy to setup and to manage
# Con: - while read access can be configured per-branch,
# granting write access rights to a user means that
# he can write anything in the global database
# - database lock problem: the database from which
# indefero reads its data cannot be used to serve the
# contents to the users, as the serve process locks
# the database
#
# 2) One database for every project with 'usher':
# Set 'mtn_remote_url' below to a string which matches your setup.
# Again, the '%s' placeholder will be expanded to the project's
# short name. Note that 'mtn_remote_url' is used as internal
# URI (to access the data for indefero) as well as external URI
# (for end users) at the same time.
#
# Then download and configure 'usher'
# (mtn clone mtn://monotone.ca?net.venge.monotone.contrib.usher)
# which acts as proxy in front of all single project databases.
# Usher's server name should be mapped to the project's short name,
# so you end up with something like this for every project:
#
# server "project"
# local "-d" "/home/mtn/repositories/project.mtn" "*"
#
# Alternatively if you assign every project a unique DNS such as
# 'project.my-hosting.biz', you can also configure it like this:
#
# host "project.my-hosting.biz"
# local "-d" "/home/mtn/repositories/project.mtn" "*"
#
# Pro: - read and write access can be granted per project
# - no database locking issues
# - one public server running on the one well-known port
# Con: - harder to setup
#
# Usher can also be used to forward sync requests to remote servers,
# please consult its README file for more information.
#
# monotone also allows to use SSH as transport protocol, so if you do not plan
# to setup a netsync server as described above, then just enter a URI like
# 'ssh://my-host.biz/home/mtn/repositories/%s.mtn' in 'mtn_remote_url'.
#
$cfg['mtn_repositories'] = '/home/mtn/repositories/%s.mtn';
# The preferred URL with which people can access this service. The placeholder
# denotes the unique project name which could be used as distinguishable SNI.
$cfg['mtn_remote_host'] = '%s.my.host.com';
# Possible values 'ssh' and 'netsync'
$cfg['mtn_remote_protocol'] = 'netsync';
$cfg['mtn_remote_url'] = 'mtn://my-host.biz/%s';
#
# Whether the particular database(s) are accessed locally (via automate stdio)
# or remotely (via automate remote_stdio). 'remote' is the default for
# netsync setups, while 'local' access should be choosed for ssh access.
#
# Note that you need to setup the hook 'get_remote_automate_permitted' for
# each remotely accessible database. A full HOWTO set this up is beyond this
# scope, please refer to the documentation of monotone and / or ask on the
# mailing list / IRC channel (irc.oftc.net/#monotone)
#
$cfg['mtn_db_access'] = 'remote';
# Mercurial repositories path
#$cfg['mercurial_repositories'] = '/home/mercurial/repositories/%s';

Archive Download the corresponding diff file

Page rendered in 0.09242s using 13 queries.