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 67 68 69 70 71 72 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 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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922
|
<?php
/**
* VC_svn implementation.
*
* Copyright 2000-2006 Anil Madhavapeddy, <anil@recoil.org>
*
* $Horde: framework/VC/VC/svn.php,v 1.28.4.18 2006/05/12 04:47:08 chuck Exp $
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @since Horde 3.0
* @package VC
*/
class VC_svn extends VC {
/**
* Constructor.
*
* @param array $params Any parameter the class expects.
* Current parameters:
* 'sourceroot': The source root for this
* repository
* 'paths': Hash with the locations of all
* necessary binaries: 'svn', 'diff'
*/
function VC_svn($params)
{
$this->_sourceroot = $params['sourceroot'];
$this->_paths = $params['paths'];
}
function isFile($where)
{
return true;
}
function &queryDir($where)
{
$dir = new VC_Directory_svn($this, $where);
return $dir;
}
function getCheckout($file, $rev)
{
return VC_Checkout_svn::get($this, $file->queryFullPath(), $rev);
}
function getDiff($file, $rev1, $rev2, $type = 'context', $num = 3, $ws = true)
{
return VC_Diff_svn::get($this, $file, $rev1, $rev2, $type, $num, $ws);
}
function &getFileObject($filename, $cache = null, $quicklog = false)
{
$fo = &VC_File_svn::getFileObject($this, $filename, $cache, $quicklog);
return $fo;
}
function &getAnnotateObject($filename)
{
$blame = new VC_Annotate_svn($this, $filename);
return $blame;
}
function &getPatchsetObject($filename, $cache = null)
{
$po = &VC_Patchset_svn::getPatchsetObject($this, $filename, $cache);
return $po;
}
}
/**
* VC_svn annotate class.
*
* Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Annotate_svn {
var $file;
var $SVN;
var $tmpfile;
function VC_Annotate_svn($rep, $file)
{
$this->SVN = $rep;
$this->file = $file;
}
function doAnnotate($rev)
{
/* Make sure that the file values for this object is valid. */
if (is_a($this->file, 'PEAR_Error')) {
return false;
}
if (!VC_Revision::valid($rev)) {
return false;
}
$Q = VC_WINDOWS ? '"' : "'";
$command = $this->SVN->getPath('svn') . ' annotate -r 1:' . $rev . ' ' . $Q . str_replace($Q, '\\' . $Q, $this->file->queryFullPath()) . $Q . ' 2>&1';
$pipe = popen($command, 'r');
if (!$pipe) {
return PEAR::raiseError('Failed to execute svn annotate: ' . $command);
}
$lines = array();
$lineno = 1;
while (!feof($pipe)) {
$line = fgets($pipe, 4096);
if (preg_match('/^\s+(\d+)\s+([\w\.]+)\s(.*)$/', $line, $regs)) {
$entry = array();
$entry['rev'] = $regs[1];
$entry['author'] = trim($regs[2]);
$entry['date'] = '';
$entry['line'] = $regs[3];
$entry['lineno'] = $lineno++;
$lines[] = $entry;
}
}
pclose($pipe);
return $lines;
}
}
/**
* VC_svn checkout class.
*
* Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Checkout_svn {
/**
* Static function which returns a file pointing to the head of the requested
* revision of an RCS file.
* @param fullname Fully qualified pathname of the desired RCS file to checkout
* @param rev RCS revision number to check out
* @return Either a PEAR_Error object, or a stream pointer to the head of the checkout
*/
function get($rep, $fullname, $rev)
{
if (!VC_Revision::valid($rev)) {
return PEAR::raiseError('Invalid revision number');
}
if (VC_WINDOWS) {
$Q = '"';
$mode = 'rb';
} else {
$Q = "'";
$mode = 'r';
}
if (!($RCS = popen($rep->getPath('svn') . ' cat -r ' . $rev . ' ' . $Q . str_replace($Q, '\\' . $Q, $fullname) . $Q . ' 2>&1', $mode))) {
return PEAR::raiseError('Couldn\'t perform checkout of the requested file');
}
return $RCS;
}
}
/**
* VC_svn diff class.
*
* Copyright Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Diff_svn {
/**
* Obtain the differences between two revisions of a file.
*
* @param VC_svn $rep A repository object.
* @param VC_File_svn $file The desired file.
* @param string $rev1 Original revision number to compare from.
* @param string $rev2 New revision number to compare against.
* @param string $type The type of diff (e.g. 'unified').
* @param integer $num Number of lines to be used in context and
* unified diffs.
* @param boolean $ws Show whitespace in the diff?
*
* @return string|boolean False on failure, or a string containing the
* diff on success.
*/
function get($rep, $file, $rev1, $rev2, $type = 'context', $num = 3,
$ws = true)
{
/* Make sure that the file parameter is valid */
if (is_a($file, 'PEAR_Error')) {
return false;
}
/* Check that the revision numbers are valid */
$rev1 = VC_Revision::valid($rev1) ? $rev1 : 0;
$rev2 = VC_Revision::valid($rev1) ? $rev2 : 0;
$fullName = $file->queryFullPath();
$diff = array();
$options = '';
if (!$ws) {
$options .= ' -bB ';
}
switch ($type) {
case 'context':
$options .= '--context=' . (int)$num;
break;
case 'unified':
$options .= '--unified=' . (int)$num;
break;
case 'column':
$options .= '--side-by-side --width=120';
break;
case 'ed':
$options .= '-e';
break;
}
// TODO: add options for $hr options - however these may not
// be compatible with some diffs.
$Q = VC_WINDOWS ? '"' : "'";
$command = $rep->getPath('svn') . " diff --diff-cmd " . $rep->getPath('diff') . " -r $rev1:$rev2 -x " . $Q . $options . $Q . ' ' . $file->queryFullPath() . ' 2>&1';
exec($command, $diff, $retval);
return $diff;
}
}
/**
* VC_svn directory class.
*
* Copyright Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Directory_svn {
var $rep;
var $dirName;
var $files;
var $atticFiles;
var $mergedFiles;
var $dirs;
var $parent;
var $moduleName;
/**
* Create a SVN Directory object to store information about the
* files in a single directory in the repository
*
* @param VC_Repository_svn $rp The VC_Repository object this directory
* is part of.
* @param string $dn Path to the directory.
* @param VC_Directory_svn $pn The parent VC_Directory to this one.
*/
function VC_Directory_svn($rep, $dn, $pn = '')
{
$this->rep = $rep;
$this->parent = $pn;
$this->moduleName = $dn;
$this->dirName = "/$dn";
$this->files = array();
$this->dirs = array();
}
/**
* Return fully qualified pathname to this directory with no
* trailing /.
*
* @return Pathname of this directory
*/
function queryDir()
{
return $this->dirName;
}
function &queryDirList()
{
return $this->dirs;
}
function &queryFileList($showattic = false)
{
if ($showattic && isset($this->mergedFiles)) {
return $this->mergedFiles;
} else {
return $this->files;
}
}
/**
* Tell the object to open and browse its current directory, and
* retrieve a list of all the objects in there. It then populates
* the file/directory stack and makes it available for retrieval.
*
* @return PEAR_Error object on an error, 1 on success.
*/
function browseDir($cache = null, $quicklog = true, $showattic = false)
{
$Q = VC_WINDOWS ? '"' : "'" ;
$cmd = $this->rep->getPath('svn') . ' ls ' . $Q . str_replace($Q, '\\' . $Q, $this->rep->sourceroot() . $this->queryDir()) . $Q . ' 2>&1';
$dir = popen($cmd, 'r');
if (!$dir) {
return PEAR::raiseError('Failed to execute svn ls: ' . $cmd);
}
/* Create two arrays - one of all the files, and the other of
* all the dirs. */
$errors = array();
while (!feof($dir)) {
$line = chop(fgets($dir, 1024));
if (!strlen($line)) {
continue;
}
if (substr($line, 0, 4) == 'svn:') {
$errors[] = $line;
} elseif (substr($line, -1) == '/') {
$this->dirs[] = substr($line, 0, -1);
} else {
$fl = $this->rep->getFileObject($this->queryDir() . "/$line", $cache, $quicklog);
if (is_a($fl, 'PEAR_Error')) {
return $fl;
} else {
$this->files[] = $fl;
}
}
}
pclose($dir);
if ($errors) {
return PEAR::raiseError(implode("\n", $errors));
}
return true;
}
/**
* Sort the contents of the directory in a given fashion and
* order.
*
* @param $how Of the form VC_SORT_* where * can be:
* NONE, NAME, AGE, REV for sorting by name, age or revision.
* @param $dir Of the form VC_SORT_* where * can be:
* ASCENDING, DESCENDING for the order of the sort.
*/
function applySort($how = VC_SORT_NONE, $dir = VC_SORT_ASCENDING)
{
/* TODO: this code looks very inefficient! optimise... -
* avsm. */
// Assume by name for the moment.
natcasesort($this->dirs);
$this->doFileSort($this->files, $how, $dir);
if (isset($this->atticFiles)) {
$this->doFileSort($this->atticFiles, $how, $dir);
}
if (isset($this->mergedFiles)) {
$this->doFileSort($this->mergedFiles, $how, $dir);
}
if ($dir == VC_SORT_DESCENDING) {
$this->dirs = array_reverse($this->dirs);
$this->files = array_reverse($this->files);
if (isset($this->mergedFiles)) {
$this->mergedFiles = array_reverse($this->mergedFiles);
}
}
}
function doFileSort(&$fileList, $how = VC_SORT_NONE, $dir = VC_SORT_ASCENDING)
{
switch ($how) {
case VC_SORT_AGE:
usort($fileList, array($this, 'fileAgeSort'));
break;
case VC_SORT_NAME:
usort($fileList, array($this, 'fileNameSort'));
break;
case VC_SORT_AUTHOR:
usort($fileList, array($this, 'fileAuthorSort'));
break;
case VC_SORT_REV:
usort($fileList, array($this, 'fileRevSort'));
break;
case VC_SORT_NONE:
default:
break;
}
}
/**
* Sort function for ascending age.
*/
function fileAgeSort($a, $b)
{
$aa = $a->queryLastLog();
$bb = $b->queryLastLog();
if ($aa->queryDate() == $bb->queryDate()) {
return 0;
} else {
return ($aa->queryDate() < $bb->queryDate()) ? 1 : -1;
}
}
/**
* Sort function by author name.
*/
function fileAuthorSort($a, $b)
{
$aa = $a->queryLastLog();
$bb = $b->queryLastLog();
if ($aa->queryAuthor() == $bb->queryAuthor()) {
return 0;
} else {
return ($aa->queryAuthor() > $bb->queryAuthor()) ? 1 : -1;
}
}
/**
* Sort function for ascending filename.
*/
function fileNameSort($a, $b)
{
return strcasecmp($a->name, $b->name);
}
/**
* Sort function for ascending revision.
*/
function fileRevSort($a, $b)
{
return VC_Revision::cmp($a->queryHead(), $b->queryHead());
}
}
/**
* VC_svn file class.
*
* Copyright Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_File_svn extends VC_File {
/**
* Create a repository file object, and give it information about
* what its parent directory and repository objects are.
*
* @param string $fl Full path to this file.
*/
function VC_File_svn($rep, $fl, $quicklog = false)
{
$this->rep = $rep;
$this->name = basename($fl);
$this->dir = dirname($fl);
$this->logs = array();
$this->quicklog = $quicklog;
$this->revs = array();
$this->revsym = array();
$this->symrev = array();
$this->branches = array();
}
function &getFileObject($rep, $filename, $cache = null, $quicklog = false)
{
/* The version of the cached data. Increment this whenever the
* internal storage format changes, such that we must
* invalidate prior cached data. */
$cacheVersion = 2;
$cacheId = $rep->sourceroot() . '_n' . $filename . '_f' . (int)$quicklog . '_v' . $cacheVersion;
if ($cache &&
// The file is cached for one hour no matter what, because
// there is no way to determine with Subversion the time
// the file last changed.
$cache->exists($cacheId, 3600)) {
$fileOb = unserialize($cache->get($cacheId, 3600));
$fileOb->setRepository($rep);
} else {
$fileOb = new VC_File_svn($rep, $filename, $quicklog);
$fileOb->setRepository($rep);
if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
return $result;
}
$fileOb->applySort(VC_SORT_AGE);
if ($cache) {
$cache->set($cacheId, serialize($fileOb));
}
}
return $fileOb;
}
/**
* If this file is present in an Attic directory, this indicates
* it.
*
* @return true if file is in the Attic, and false otherwise
*/
function isAtticFile()
{
// Not implemented yet
return false;
}
/**
* Returns the name of the current file as in the repository
*
* @return Filename (without the path)
*/
function queryRepositoryName()
{
return $this->name;
}
/**
* Returns name of the current file without the repository
* extensions (usually ,v)
*
* @return Filename without repository extension
*/
function queryName()
{
return preg_replace('/,v$/', '', $this->name);
}
/**
* Return the last revision of the current file on the HEAD branch
*
* @return Last revision of the current file
*/
function queryRevision()
{
if (!isset($this->revs[0])) {
return PEAR::raiseError('No revisions');
}
return $this->revs[0];
}
function queryPreviousRevision($rev)
{
$last = false;
foreach ($this->revs as $entry) {
if ($last)
return $entry;
if ($entry == $rev)
$last = true;
}
return false;
}
/**
* Return the HEAD (most recent) revision number for this file.
*
* @return HEAD revision number
*/
function queryHead()
{
return $this->queryRevision();
}
/**
* Return the last VC_Log object in the file.
*
* @return VC_Log of the last entry in the file
*/
function queryLastLog()
{
if (!isset($this->revs[0]) || !isset($this->logs[$this->revs[0]])) {
return PEAR::raiseError('No revisions');
}
return $this->logs[$this->revs[0]];
}
/**
* Sort the list of VC_Log objects that this file contains.
*
* @param how VC_SORT_REV (sort by revision),
* VC_SORT_NAME (sort by author name),
* VC_SORT_AGE (sort by commit date)
*/
function applySort($how = VC_SORT_REV)
{
switch ($how) {
case VC_SORT_REV:
$func = 'Revision';
break;
case VC_SORT_NAME:
$func = 'Name';
break;
case VC_SORT_AGE:
$func = 'Age';
break;
default:
$func = 'Revision';
}
uasort($this->logs, array($this, "sortBy$func"));
return true;
}
/**
* The sortBy*() functions are internally used by applySort.
*/
function sortByRevision($a, $b)
{
return VC_Revision::cmp($b->rev, $a->rev);
}
function sortByAge($a, $b)
{
return $b->date - $a->date;
}
function sortByName($a, $b)
{
return strcmp($a->author, $b->author);
}
/**
* Populate the object with information about the revisions logs
* and dates of the file.
*
* @return mixed boolean True on success,
* PEAR_Error On error.
*/
function getBrowseInfo()
{
/* This doesn't work; need to find another way to simply
* request the most recent revision:
*
* $flag = $this->quicklog ? '-r HEAD ' : ''; */
$flag = '';
$Q = VC_WINDOWS ? '"' : "'";
$cmd = $this->rep->getPath('svn') . ' log -v ' . $flag . $Q . str_replace($Q, '\\' . $Q, $this->queryFullPath()) . $Q . ' 2>&1';
$pipe = popen($cmd, 'r');
if (!$pipe) {
return PEAR::raiseError('Failed to execute svn log: ' . $cmd);
}
fgets($pipe);
while (!feof($pipe)) {
$log = new VC_Log_svn($this->rep, $this);
$err = $log->processLog($pipe);
if ($err) {
$rev = $log->queryRevision();
$this->logs[$rev] = $log;
$this->revs[] = $rev;
}
if ($this->quicklog) {
break;
}
}
pclose($pipe);
return true;
}
/**
* Return the fully qualified filename of this object.
*
* @return Fully qualified filename of this object
*/
function queryFullPath()
{
return $this->rep->sourceroot() . '/' . $this->queryModulePath();
}
/**
* Return the name of this file relative to its sourceroot.
*
* @return string Pathname relative to the sourceroot.
*/
function queryModulePath()
{
return $this->dir . '/' . $this->name;
}
}
/**
* VC_svn log class.
*
* Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Log_svn {
var $rep;
var $err;
var $file;
var $files;
var $tags;
var $rev;
var $date;
var $log;
var $author;
var $state;
var $lines;
var $branches;
/**
* Constructor.
*/
function VC_Log_svn($rep, $fl)
{
$this->rep = $rep;
$this->file = $fl;
$this->branches = array();
}
function processLog($pipe)
{
$line = fgets($pipe);
if (feof($pipe)) {
return false;
}
if (preg_match('/^r([0-9]*) \| (.*?) \| (.*) \(.*\) \| ([0-9]*) lines?$/', $line, $matches)) {
$this->rev = $matches[1];
$this->author = $matches[2];
$this->date = strtotime($matches[3]);
$size = $matches[4];
} else {
$this->err = $line;
return false;
}
fgets($pipe);
$this->files = array();
while (($line = trim(fgets($pipe))) != '') {
$this->files[] = $line;
}
for ($i = 0; $i != $size; ++$i) {
$this->log = $this->log . chop(fgets($pipe)) . "\n";
}
$this->log = chop($this->log);
fgets($pipe);
return true;
}
function queryDate()
{
return $this->date;
}
function queryRevision()
{
return $this->rev;
}
function queryAuthor()
{
return $this->author;
}
function queryLog()
{
return $this->log;
}
function queryChangedLines()
{
return isset($this->lines) ? ($this->lines) : '';
}
/**
* Given a branch revision number, this function remaps it
* accordingly, and performs a lookup on the file object to
* return the symbolic name(s) of that branch in the tree.
*
* @return hash of symbolic names => branch numbers
*/
function querySymbolicBranches()
{
$symBranches = array();
foreach ($this->branches as $branch) {
$parts = explode('.', $branch);
$last = array_pop($parts);
$parts[] = '0';
$parts[] = $last;
$rev = implode('.', $parts);
if (isset($this->file->branches[$branch])) {
$symBranches[$this->file->branches[$branch]] = $branch;
}
}
return $symBranches;
}
}
/**
* VC_svn Patchset class.
*
* Copyright Anil Madhavapeddy, <anil@recoil.org>
*
* @author Anil Madhavapeddy <anil@recoil.org>
* @package VC
*/
class VC_Patchset_svn extends VC_Patchset {
var $_file;
/**
* Create a patchset object.
*
* @param string $file The filename to get patchsets for.
*/
function VC_Patchset_svn($file)
{
$this->_file = $file;
}
function &getPatchsetObject($rep, $filename, $cache = null)
{
/* The version of the cached data. Increment this whenever the
* internal storage format changes, such that we must
* invalidate prior cached data. */
$cacheVersion = 1;
$cacheId = $rep->sourceroot() . '_n' . $filename . '_f_v' . $cacheVersion;
if ($cache &&
// The file is cached for one hour no matter what, because
// there is no way to determine with svn the time the file
// last changed.
$cache->exists($cacheId, 3600)) {
$psOb = unserialize($cache->get($cacheId, 3600));
$psOb->setRepository($rep);
} else {
$psOb = new VC_Patchset_svn($filename);
$psOb->setRepository($rep);
if (is_a(($result = $psOb->getPatchsets()), 'PEAR_Error')) {
return $result;
}
if ($cache) {
$cache->set($cacheId, serialize($psOb));
}
}
return $psOb;
}
/**
* Populate the object with information about the patchsets that
* this file is involved in.
*
* @return mixed PEAR_Error object on error, or true on success.
*/
function getPatchsets()
{
$fileOb = new VC_File_svn($this->_rep, $this->_file);
if (is_a(($result = $fileOb->getBrowseInfo()), 'PEAR_Error')) {
return $result;
}
$this->_patchsets = array();
foreach ($fileOb->logs as $rev => $log) {
$this->_patchsets[$rev] = array();
$this->_patchsets[$rev]['date'] = $log->queryDate();
$this->_patchsets[$rev]['author'] = $log->queryAuthor();
$this->_patchsets[$rev]['branch'] = '';
$this->_patchsets[$rev]['tag'] = '';
$this->_patchsets[$rev]['log'] = $log->queryLog();
$this->_patchsets[$rev]['members'] = array();
foreach ($log->files as $file) {
$action = substr($file, 0, 1);
$file = preg_replace('/.*?\s(.*?)(\s|$).*/', '\\1', $file);
$to = $rev;
if ($action == 'A') {
$from = 'INITIAL';
} elseif ($action == 'D') {
$from = $to;
$to = '(DEAD)';
} else {
// This technically isn't the previous revision,
// but it works for diffing purposes.
$from = $to - 1;
}
$this->_patchsets[$rev]['members'][] = array('file' => $file,
'from' => $from,
'to' => $to);
}
}
return true;
}
}
|