Indefero

Indefero Commit Details


Date:2010-05-01 18:31:30 (14 years 7 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:e0b0a732b4f4bd2a47218fa6216212f8312ddff0
Parents: 59ad0f5b1183b9f48cb7a307044708b69b323c6d
Message:phpdoc improved; remove _getMasterBranch() method and implement the specific code directly in getMainBranch()

Changes:

File differences

src/IDF/Scm/Monotone.php
2222
2323
2424
25
25
2626
27
28
29
30
2731
28
2932
3033
34
35
36
3137
3238
3339
......
3743
3844
3945
46
47
48
49
50
4051
4152
4253
4354
4455
4556
57
58
59
4660
4761
4862
4963
5064
65
66
67
5168
5269
5370
......
7592
7693
7794
95
96
97
7898
7999
80100
......
87107
88108
89109
110
111
112
113
114
115
116
90117
91118
92119
......
115142
116143
117144
145
146
147
148
149
118150
119151
120152
......
132164
133165
134166
135
167
168
169
170
171
172
173
174
136175
137176
138177
......
168207
169208
170209
210
211
212
213
214
215
171216
172217
173218
......
248293
249294
250295
251
296
297
298
299
300
301
302
303
304
305
252306
253307
254308
255309
256310
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
311
312
313
314
315
316
317
318
276319
277
278
320
279321
280322
281323
324
325
326
327
328
282329
283330
331
284332
285333
286334
287335
288
289
290
291
292
293
336
337
338
294339
295340
296341
......
298343
299344
300345
346
347
348
301349
302350
303351
304352
305353
354
355
356
306357
307358
308359
......
311362
312363
313364
365
366
367
314368
315369
316370
......
323377
324378
325379
380
381
382
326383
327384
328385
329386
330387
331
388
389
332390
333391
334
392
335393
336394
337395
......
347405
348406
349407
350
408
351409
352
410
353411
354412
355413
356
357
414
415
416
417
418
419
358420
359421
360422
......
447509
448510
449511
512
513
514
515
516
517
518
450519
451520
452521
......
487556
488557
489558
559
560
561
562
563
564
565
566
490567
491568
492569
......
501578
502579
503580
581
582
583
584
585
586
587
588
504589
505590
506591
......
510595
511596
512597
513
598
514599
515600
516601
......
526611
527612
528613
529
614
530615
531616
532617
......
536621
537622
538623
539
624
540625
541626
542627
......
573658
574659
575660
576
661
577662
578663
579664
......
648733
649734
650735
651
652
653
654
655
736
656737
657738
658739
......
671752
672753
673754
674
675
676
677
678
679
680
681
682
683
755
756
757
684758
685759
686
760
761
762
687763
688764
689
690765
691766
692767
......
722797
723798
724799
800
801
802
725803
726804
727805
......
739817
740818
741819
820
821
822
742823
743824
744825
......
746827
747828
748829
749
750
751
752
753
830
754831
755832
756833
757834
758
835
759836
760837
761838
......
818895
819896
820897
898
899
900
821901
822902
823903
......
829909
830910
831911
912
913
914
915
916
917
918
919
832920
833921
834922
......
859947
860948
861949
862
863
864
865
866
950
867951
868952
869953
......
891975
892976
893977
894
895
896
897
978
898979
899980
900981
901982
902983
903
984
904985
905986
906987
......
9241005
9251006
9261007
927
928
929
930
931
1008
9321009
9331010
9341011
......
9831060
9841061
9851062
1063
# ***** END LICENSE BLOCK ***** */
/**
* Monotone utils.
* Monotone stdio class
*
* Connects to a monotone process and executes commands via its
* stdio interface
*
* @author Thomas Keller <me@thomaskeller.biz>
*/
class IDF_Scm_Monotone_Stdio
{
/** this is the most recent STDIO version. The number is output
at the protocol start. Older versions of monotone (prior 0.47)
do not output it and are therefor incompatible */
public static $SUPPORTED_STDIO_VERSION = 2;
private $repo;
private $cmdnum;
private $lastcmd;
/**
* Constructor - starts the stdio process
*
* @param string Repository path
*/
public function __construct($repo)
{
$this->repo = $repo;
$this->start();
}
/**
* Destructor - stops the stdio process
*/
public function __destruct()
{
$this->stop();
}
/**
* Starts the stdio process and resets the command counter
*/
public function start()
{
if (is_resource($this->proc))
$this->cmdnum = -1;
}
/**
* Stops the stdio process and closes all pipes
*/
public function stop()
{
if (!is_resource($this->proc))
$this->proc = null;
}
/**
* select()'s on stdout and returns true as soon as we got new
* data to read, false if the select() timed out
*
* @return boolean
* @throws IDF_Scm_Exception
*/
private function _waitForReadyRead()
{
if (!is_resource($this->pipes[1]))
return true;
}
/**
* Checks the version of the used stdio protocol
*
* @throws IDF_Scm_Exception
*/
private function _checkVersion()
{
$this->_waitForReadyRead();
fgets($this->pipes[1]);
}
private function _write($args, $options = array())
/**
* Writes a command to stdio
*
* @param array
* @param array
* @throws IDF_Scm_Exception
*/
private function _write(array $args, array $options = array())
{
$cmd = "";
if (count($options) > 0)
$this->cmdnum++;
}
/**
* Reads the last output from the stdio process, parses and returns it
*
* @return string
* @throws IDF_Scm_Exception
*/
private function _read()
{
$this->oob = array('w' => array(),
return $output;
}
public function exec($args, $options = array())
/**
* 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())
{
$this->_write($args, $options);
return $this->_read();
}
public function getLastWarnings()
{
return array_key_exists('w', $this->oob) ?
$this->oob['w'] : array();
}
public function getLastProgress()
{
return array_key_exists('p', $this->oob) ?
$this->oob['p'] : array();
}
public function getLastTickers()
{
return array_key_exists('t', $this->oob) ?
$this->oob['t'] : array();
}
public function getLastErrors()
/**
* 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()
{
return array_key_exists('e', $this->oob) ?
$this->oob['e'] : array();
return $this->oob;
}
}
/**
* Monotone scm class
*
* @author Thomas Keller <me@thomaskeller.biz>
*/
class IDF_Scm_Monotone extends IDF_Scm
{
/** the minimum supported interface version */
public static $MIN_INTERFACE_VERSION = 12.0;
private $stdio;
/* ============================================== *
* *
* Common Methods Implemented By All The SCMs *
* *
* ============================================== */
/**
* @see IDF_Scm::__construct()
*/
public function __construct($repo, $project=null)
{
$this->repo = $repo;
$this->stdio = new IDF_Scm_Monotone_Stdio($repo);
}
/**
* @see IDF_Scm::getRepositorySize()
*/
public function getRepositorySize()
{
if (!file_exists($this->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);
$out = explode(' ',
return (int) $out[0]*1024;
}
/**
* @see IDF_Scm::isAvailable()
*/
public function isAvailable()
{
try
return false;
}
/**
* @see IDF_Scm::getBranches()
*/
public function getBranches()
{
if (isset($this->cache['branches'])) {
return $this->cache['branches'];
}
// FIXME: introduce handling of suspended branches
// FIXME: we could / should introduce handling of suspended
// (i.e. dead) branches here by hiding them from the user's eye...
$out = $this->stdio->exec(array("branches"));
// FIXME: we could expand each branch with one of its head revisions
// note: we could expand each branch with one of its head revisions
// here, but these would soon become bogus anyway and we cannot
// map multiple head revisions here either, so we just use the
// selector as placeholder
/**
* monotone has no concept of a "main" branch, so just return
* the first one (the branch list is already sorted)
* the confiured one
*
* @return string
* @see IDF_Scm::getMainBranch()
*/
public function getMainBranch()
{
$branches = $this->getBranches();
return key($branches);
$conf = $this->project->getConf();
if (false === ($branch = $conf->getVal('mtn_master_branch', false))
|| empty($branch)) {
$branch = "*";
}
return $branch;
}
/**
return $stanzas;
}
/**
* Queries the certs for a given revision and returns them in an
* associative array array("branch" => array("branch1", ...), ...)
*
* @param string
* @param array
*/
private function _getCerts($rev)
{
static $certCache = array();
return $certCache[$rev];
}
/**
* Returns unique certificate values for the given revs and the specific
* cert name
*
* @param array
* @param string
* @return array
*/
private function _getUniqueCertValuesFor($revs, $certName)
{
$certValues = array();
return array_unique($certValues);
}
/**
* Returns the revision in which the file has been last changed,
* starting from the start rev
*
* @param string
* @param string
* @return string
*/
private function _getLastChangeFor($file, $startrev)
{
$out = $this->stdio->exec(array(
$stanzas = self::_parseBasicIO($out);
// FIXME: we only care about the first returned content mark
// everything else seem to be very rare cases
// everything else seem to be very, very rare cases
foreach ($stanzas as $stanza)
{
foreach ($stanza as $stanzaline)
/**
* @see IDF_Scm::inBranches()
**/
*/
public function inBranches($commit, $path)
{
$revs = $this->_resolveSelector($commit);
/**
* @see IDF_Scm::getTags()
**/
*/
public function getTags()
{
if (isset($this->cache['tags']))
/**
* @see IDF_Scm::inTags()
**/
*/
public function inTags($commit, $path)
{
$revs = $this->_resolveSelector($commit);
}
/**
* Given the string describing the author from the log find the
* author in the database.
*
* @param string Author
* @return mixed Pluf_User or null
* @see IDF_Scm::findAuthor()
*/
public function findAuthor($author)
{
return null;
}
private static function _getMasterBranch($project)
{
$conf = $project->getConf();
if (false === ($branch = $conf->getVal('mtn_master_branch', false))
|| empty($branch)) {
$branch = "*";
}
return $branch;
}
/**
* @see IDF_Scm::getAnonymousAccessUrl()
*/
public static function getAnonymousAccessUrl($project, $commit = null)
{
$branch = self::_getMasterBranch($project);
$scm = IDF_Scm::get($project);
$branch = $scm->getMainBranch();
if (!empty($commit))
{
$scm = IDF_Scm::get($project);
$revs = $scm->_resolveSelector($commit);
if (count($revs) > 0)
{
)." ".$branch;
}
/**
* @see IDF_Scm::getAuthAccessUrl()
*/
public static function getAuthAccessUrl($project, $user, $commit = null)
{
return self::getAnonymousAccessUrl($project, $commit);
return new IDF_Scm_Monotone($rep, $project);
}
/**
* @see IDF_Scm::isValidRevision()
*/
public function isValidRevision($commit)
{
$revs = $this->_resolveSelector($commit);
}
/**
* Get the file info.
*
* @param string File
* @param string Commit ('HEAD')
* @return false Information
* @see IDF_Scm::getPathInfo()
*/
public function getPathInfo($file, $commit = null)
{
if ($commit === null) {
$commit = 'h:' . self::_getMasterBranch($this->project);
$commit = 'h:' . $this->getMainBranch();
}
$revs = $this->_resolveSelector($commit);
return false;
}
/**
* @see IDF_Scm::getFile()
*/
public function getFile($def, $cmd_only=false)
{
// this won't work with remote databases
return $this->stdio->exec(array("get_file", $def->hash));
}
/**
* Returns the differences between two revisions as unified diff
*
* @param string The target of the diff
* @param string The source of the diff, if not given, the first
* parent of the target is used
* @return string
*/
private function _getDiff($target, $source = null)
{
if (empty($source))
}
/**
* Get commit details.
*
* @param string Commit
* @param bool Get commit diff (false)
* @return array Changes
* @see IDF_Scm::getCommit()
*/
public function getCommit($commit, $getdiff=false)
{
}
/**
* Check if a commit is big.
*
* @param string Commit ('HEAD')
* @return bool The commit is big
* @see IDF_Scm::isCommitLarge()
*/
public function isCommitLarge($commit=null)
{
if (empty($commit))
{
$commit = "h:"+self::_getMasterBranch($this->project);
$commit = "h:"+$this->getMainBranch();
}
$revs = $this->_resolveSelector($commit);
}
/**
* Get latest changes.
*
* @param string Commit ('HEAD').
* @param int Number of changes (10).
* @return array Changes.
* @see IDF_Scm::getChangeLog()
*/
public function getChangeLog($commit=null, $n=10)
{
return $logs;
}
}

Archive Download the corresponding diff file

Page rendered in 0.08629s using 13 queries.