Overview

Packages

  • None
  • Vcs

Classes

  • Horde_Vcs
  • Horde_Vcs_Base
  • Horde_Vcs_Cvs
  • Horde_Vcs_Directory_Base
  • Horde_Vcs_Directory_Cvs
  • Horde_Vcs_Directory_Git
  • Horde_Vcs_Directory_Rcs
  • Horde_Vcs_Directory_Svn
  • Horde_Vcs_File_Base
  • Horde_Vcs_File_Cvs
  • Horde_Vcs_File_Git
  • Horde_Vcs_File_Rcs
  • Horde_Vcs_File_Svn
  • Horde_Vcs_Git
  • Horde_Vcs_Log_Base
  • Horde_Vcs_Log_Cvs
  • Horde_Vcs_Log_Git
  • Horde_Vcs_Log_Rcs
  • Horde_Vcs_Log_Svn
  • Horde_Vcs_Patchset
  • Horde_Vcs_Patchset_Base
  • Horde_Vcs_Patchset_Cvs
  • Horde_Vcs_Patchset_Git
  • Horde_Vcs_Patchset_Svn
  • Horde_Vcs_QuickLog_Base
  • Horde_Vcs_QuickLog_Cvs
  • Horde_Vcs_QuickLog_Git
  • Horde_Vcs_QuickLog_Rcs
  • Horde_Vcs_QuickLog_Svn
  • Horde_Vcs_Rcs
  • Horde_Vcs_Svn
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * RCS log class.
  4:  *
  5:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (LGPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  9:  *
 10:  * @author  Jan Schneider <jan@horde.org>
 11:  * @package Vcs
 12:  */
 13: class Horde_Vcs_Log_Rcs extends Horde_Vcs_Log_Base
 14: {
 15:     /**
 16:      * This method parses branches even though RCS doesn't support
 17:      * branches. But rlog from the RCS tools supports them, and displays them
 18:      * even on RCS repositories.
 19:      */
 20:     protected function _init()
 21:     {
 22:         $raw = $this->_file->getAccum();
 23: 
 24:         /* Initialise a simple state machine to parse the output of rlog */
 25:         $state = 'init';
 26:         while (!empty($raw) && $state != 'done') {
 27:             switch ($state) {
 28:             /* Found filename, now looking for the revision number */
 29:             case 'init':
 30:                 $line = array_shift($raw);
 31:                 if (preg_match("/revision (.+)$/", $line, $parts)) {
 32:                     $this->_rev = $parts[1];
 33:                     $state = 'date';
 34:                 }
 35:                 break;
 36: 
 37:             /* Found revision and filename, now looking for date */
 38:             case 'date':
 39:                 $line = array_shift($raw);
 40:                 if (preg_match("|^date:\s+(\d+)[-/](\d+)[-/](\d+)\s+(\d+):(\d+):(\d+).*?;\s+author:\s+(.+);\s+state:\s+(\S+);(\s+lines:\s+\+(\d+)\s\-(\d+))?|", $line, $parts)) {
 41:                     $this->_date = gmmktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]);
 42:                     $this->_author = $parts[7];
 43:                     $this->_state = $parts[8];
 44:                     if (isset($parts[9])) {
 45:                         $this->_lines = '+' . $parts[10] . ' -' . $parts[11];
 46:                         $this->_files[$this->_file->getSourcerootPath()] = array(
 47:                             'added' => $parts[10],
 48:                             'deleted' => $parts[11]
 49:                         );
 50:                     }
 51:                     $state = 'branches';
 52:                 }
 53:                 break;
 54: 
 55:             /* Look for a branch point here - format is 'branches:
 56:              * x.y.z; a.b.c;' */
 57:             case 'branches':
 58:                 /* If we find a branch tag, process and pop it,
 59:                    otherwise leave input stream untouched */
 60:                 if (!empty($raw) &&
 61:                     preg_match("/^branches:\s+(.*)/", $raw[0], $br)) {
 62:                     /* Get the list of branches from the string, and
 63:                      * push valid revisions into the branches array */
 64:                     $brs = preg_split('/;\s*/', $br[1]);
 65:                     foreach ($brs as $brpoint) {
 66:                         if ($this->_rep->isValidRevision($brpoint)) {
 67:                             $this->_branches[] = $brpoint;
 68:                         }
 69:                     }
 70:                     array_shift($raw);
 71:                 }
 72: 
 73:                 $state = 'done';
 74:                 break;
 75:             }
 76:         }
 77: 
 78:         /* Assume the rest of the lines are the log message */
 79:         $this->_log = implode("\n", $raw);
 80:         $this->_tags = $this->_file->getRevisionSymbol($this->_rev);
 81: 
 82:         $this->_setSymbolicBranches();
 83: 
 84:         $branches = $this->_file->getBranches();
 85:         $key = array_keys($branches, $this->_rev);
 86:         $this->_branch = empty($key)
 87:             ? array_keys($branches, $this->_rep->strip($this->_rev, 1))
 88:             : $key;
 89:     }
 90: 
 91:     /**
 92:      * TODO
 93:      *
 94:      * Ignoring branches in this driver.
 95:      */
 96:     public function setBranch($branch)
 97:     {
 98:     }
 99: }
100: 
API documentation generated by ApiGen