Chora/VCS fixes merged from CVS HEAD.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 6 Jan 2009 18:58:05 +0000 (11:58 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 6 Jan 2009 18:58:05 +0000 (11:58 -0700)
chora/annotate.php
chora/browse.php
chora/diff.php
chora/history.php
chora/templates/annotate/line.inc
chora/templates/diff/hr/header.inc
chora/templates/directory/file.inc
chora/templates/log/rev.inc
framework/Vcs/lib/Horde/Vcs/Git.php

index 5508f4b..9f76e0a 100644 (file)
@@ -14,6 +14,7 @@ require_once 'Horde/Text/Filter.php';
 
 /* Spawn the file object. */
 $fl = $VC->getFileObject($where, $cache);
+$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
 
 /* Retrieve the desired revision from the GET variable. */
index c24b1fd..8e9878b 100644 (file)
@@ -16,6 +16,8 @@ if (!$atdir && !$VC->isFile($fullname)) {
     Chora::fatal(sprintf(_("$s: no such file or directory"), $where), '404 Not Found');
 }
 
+$rev_ob = $VC->getRevisionObject();
+
 if ($atdir) {
     Chora::checkError($dir = $VC->queryDir($where));
 
@@ -47,12 +49,12 @@ if ($atdir) {
         'author' => Horde_Vcs::SORT_AUTHOR
     );
 
-    foreach (array('age', 'rev', 'name', 'author') as $u) {
-        $arg = array('sbt' => $umap[$u]);
-        if ($acts['sbt'] == $umap[$u]) {
+    foreach ($umap as $key => $val) {
+        $arg = array('sbt' => $val);
+        if ($acts['sbt'] == $val) {
             $arg['ord'] = !$acts['ord'];
         }
-        $url[$u] = Chora::url('', $where . '/', $arg);
+        $url[$key] = Chora::url('', $where . '/', $arg);
     }
 
     /* Print out the directory header. */
@@ -130,7 +132,6 @@ if ($atdir) {
 
 /* Showing a file. */
 $fl = $VC->getFileObject($where, $cache);
-$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
 $title = sprintf(_("Revisions for %s"), $where);
 $onb = Util::getFormData('onb', 0);
index 072db81..91ec239 100644 (file)
@@ -13,6 +13,7 @@ require_once dirname(__FILE__) . '/lib/base.php';
 
 /* Spawn the repository and file objects */
 $fl = $VC->getFileObject($where, $cache);
+$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
 
 /* Initialise the form variables correctly. */
@@ -65,8 +66,10 @@ if ($type != 'colored') {
 }
 
 /* Human-Readable diff. */
+$abbrev_r1 = $rev_ob->abbrev($r1);
+$abbrev_r2 = $rev_ob->abbrev($r2);
 $title = sprintf(_("Diff for %s between version %s and %s"),
-                 Text::htmlallspaces($where), $r1, $r2);
+                 Text::htmlallspaces($where), $abbrev_r1, $abbrev_r2);
 
 /* Format log entries. */
 $log = &$fl->logs;
index 1ec1878..2a58ab7 100644 (file)
@@ -19,6 +19,7 @@ if (is_a($VC, 'VC_svn')) {
 
 /* Spawn the file object. */
 $fl = $VC->getFileObject($where, $cache);
+$rev_ob = $VC->getRevisionObject();
 Chora::checkError($fl);
 
 /* $trunk contains an array of trunk revisions. */
@@ -38,7 +39,7 @@ foreach ($fl->branches as $rev => $sym) {
  * array.  Otherwise, add it to an array in $branches[$branch]. */
 foreach ($fl->logs as $log) {
     $rev = $log->queryRevision();
-    $baseRev = VC_Revision::strip($rev, 1);
+    $baseRev = $rev_ob->strip($rev, 1);
     $branchFound = false;
     foreach ($fl->branches as $branch => $name) {
         if ($branch == $baseRev) {
@@ -48,7 +49,7 @@ foreach ($fl->logs as $log) {
     }
     /* If its not a branch, then add it to the trunk. */
     /* TODO: this silently drops vendor branches atm! - avsm. */
-    if (!$branchFound && VC_Revision::sizeof($rev) == 2) {
+    if (!$branchFound && $rev_ob->sizeof($rev) == 2) {
         array_unshift($trunk, $rev);
     }
 }
@@ -96,7 +97,7 @@ function populateGrid($row, $col)
         $brrev = $brkeys[$a];
         $brcont = $branches[$brrev];
         /* Check to see if current point matches a branch point. */
-        if (!strcmp($rev, VC_Revision::strip($brrev, 1))) {
+        if (!strcmp($rev, $rev_ob->strip($brrev, 1))) {
             /* If it does, figure out how many rows we have to add. */
             $numRows = sizeof($brcont);
             /* Check rows in columns to the right, until one is
@@ -182,7 +183,7 @@ foreach ($grid as $row) {
         /* Otherwise, this cell has content; determine what it is. */
         $rev = $row[$i];
 
-        if ($VC->isValidRevision($rev) && (VC_Revision::sizeof($rev) % 2)) {
+        if ($VC->isValidRevision($rev) && ($rev_ob->sizeof($rev) % 2)) {
             /* This is a branch point, so put the info out. */
             $bg = isset($branchColours[$rev]) ? $branchColours[$rev] : '#e9e9e9';
             $symname = $fl->branches[$rev];
@@ -191,13 +192,13 @@ foreach ($grid as $row) {
         } elseif (preg_match('|^:|', $rev)) {
             /* This is a continuation cell, so render it with the
              * branch colour. */
-            $bgbr = VC_Revision::strip(preg_replace('|^\:|', '', $rev), 1);
+            $bgbr = $rev_ob->strip(preg_replace('|^\:|', '', $rev), 1);
             $bg = isset($branchColours[$bgbr]) ? $branchColours[$bgbr] : '#e9e9e9';
             require CHORA_TEMPLATES . '/history/blank.inc';
 
         } elseif ($VC->isValidRevision($rev)) {
             /* This cell contains a revision, so render it. */
-            $bgbr = VC_Revision::strip($rev, 1);
+            $bgbr = $rev_ob->strip($rev, 1);
             $bg = isset($branchColours[$bgbr]) ? $branchColours[$bgbr] : '#e9e9e9';
             $log = $fl->logs[$rev];
             $author = Chora::showAuthorName($log->queryAuthor());
index 795a775..d6da97b 100644 (file)
@@ -1,7 +1,7 @@
  <tr id="l<?php echo $lineno ?>">
   <td class="rightAlign"><?php echo $lineno ?></td>
   <td class="author"><?php echo $author ?></td>
-  <td class="rev"><a id="rev_<?php echo $rev . '_' . $i ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>"><?php echo $rev ?></a></td>
-  <td class="rev"><?php if ($prev): ?><a id="prev_<?php echo $prev . '_' . $i ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>"><?php echo $prev ?></a><?php else: ?>&nbsp;<?php endif; ?></td>
+  <td class="rev"><a id="rev_<?php echo $rev . '_' . $i ?>" href="<?php echo Chora::url('co', $where, array('r' => $rev)) ?>" title="<?php echo $rev ?>"><?php echo $rev_ob->abbrev($rev) ?></a></td>
+  <td class="rev"><?php if ($prev): ?><a id="prev_<?php echo $prev . '_' . $i ?>" href="<?php echo Chora::url('annotate', $where, array('rev' => $prev)) . '#l' . $lineno ?>" title="<?php echo $prev ?>"><?php echo $rev_ob->abbrev($prev) ?></a><?php else: ?>&nbsp;<?php endif; ?></td>
   <td class="item<?php echo $style ?>"><tt><?php echo (trim($line) != '') ? $line : '&nbsp;' ?></tt></td>
  </tr>
index 6e64100..f64c6f8 100644 (file)
@@ -45,7 +45,7 @@
    <?php if (!empty($val['branchName'])): ?><li><?php echo _("Branch:") ?> <strong><a href="<?php echo Chora::url('', $where, array('onb' => $val['branchRev'])) ?>"><?php echo $val['branchName'] ?></a></strong></li><?php endif; ?>
    <?php if (!empty($val['tags'])): ?><li class="tags"><?php echo _("Tags:") ?> <?php echo implode(', ', $val['tags']) ?></li><?php endif; ?>
   </ul>
-  <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>"><?php echo $val['rev'] ?></a>: <?php echo $val['msg'] ?>
+  <a href="<?php echo Chora::url('co', $where, array('r' => $val['rev'])) ?>" title="<?php echo $val['rev'] ?>"><?php echo $rev_ob->abbrev($val['rev']) ?></a>: <?php echo $val['msg'] ?>
   <div class="diffclear"></div>
  </div>
 <?php endforeach; ?>
@@ -53,8 +53,8 @@
 <?php endif; ?>
 <thead>
 <tr>
- <th><a href="<?php echo Chora::url('co', $where, array('r' => $r1)) ?>"><?php printf(_("Version %s"), $r1) ?></a></th>
- <th><a href="<?php echo Chora::url('co', $where, array('r' => $r2)) ?>"><?php printf(_("Version %s"), $r2) ?></a></th>
+ <th><a href="<?php echo Chora::url('co', $where, array('r' => $r1)) ?>" title="<?php echo $r1 ?>"><?php printf(_("Version %s"), $abbrev_r1) ?></a></th>
+ <th><a href="<?php echo Chora::url('co', $where, array('r' => $r2)) ?>" title="<?php echo $r2 ?>"><?php printf(_("Version %s"), $abbrev_r2) ?></a></th>
 </tr>
 </thead>
 <tbody>
index fb6728b..3ab7c28 100644 (file)
   <td>
    <strong>
 <?php if ($conf['filename_linkto'] == 'revlog'): ?>
-   <a href="<?php echo Chora::url('co', $fileName, array('r' => $head)) ?>">
+    <a href="<?php echo Chora::url('co', $fileName, array('r' => $head)) ?>" title="<?php echo $head ?>">
 <?php else: ?>
-   <a href="<?php echo $url ?>">
+    <a href="<?php echo $url ?>" title="<?php echo $head ?>">
 <?php endif; ?>
-<?php echo $head ?></a></strong>
+<?php echo $rev_ob->abbrev($head) ?></a></strong>
   </td>
 <?php else: ?>
   <td>
@@ -31,7 +31,7 @@
 <?php endif; ?>
    <?php echo $name ?>
   </td>
-  <td><strong><?php echo $head ?></strong></td>
+  <td><strong><?php echo $rev_ob->abbrev($head) ?></strong></td>
 <?php endif; ?>
   <td><?php echo $author ?></td>
   <td sortval="<?php echo (int)$date ?>">
index f9c605a..3d013c0 100644 (file)
@@ -5,7 +5,7 @@
   <?php endif ?>
   <a href="<?php echo Chora::url('diff', $where, array('r1' => 0, 'r2' => $rev)) ?>" class="sdiff" title="<?php echo _("Show changes to the selected revision") ?>" onclick="revlog_sdiff(this);"><?php echo Horde::img('diff.png') ?></a>
  </td>
- <td><a href="<?php echo $textUrl ?>"><?php echo $rev . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
+ <td><a href="<?php echo $textUrl ?>" title="<?php echo $rev ?>"><?php echo $rev_ob->abbrev($rev) . '</a>'; if ($branchName) echo ' <span class="branch">' . Horde::link(Chora::url('', $where, array('onb' => $branchRev))) . htmlspecialchars($branchName) . '</a></span>'; if (!empty($lg->lines)) echo ' <small>(' . sprintf('%s lines', $lg->lines) . ')</small>'; ?></td>
  <td class="ago" sortval="<?php echo (int)$lg->date ?>"><a title="<?php echo $readableDate ?>"><?php echo $commitDate ?></a></td>
  <td class="author"><?php echo $author ?></td>
  <td class="log">
index 3a30379..961167b 100644 (file)
@@ -82,15 +82,12 @@ class Horde_Vcs_Annotate_git extends Horde_Vcs_Annotate
 
         while (!feof($pipe)) {
             $line = rtrim(fgets($pipe, 4096));
-            if (!$line) {
-                continue;
-            }
 
-            if ($line[0] == "\t") {
+            if (!$line || ($line[0] == "\t")) {
                 $lines[] = array(
                     'author' => $db[$curr_rev]['author'] . ' ' . $db[$curr_rev]['author-mail'],
                     'date' => $db[$curr_rev]['author-time'],
-                    'line' => substr($line, 1),
+                    'line' => $line ? substr($line, 1) : '',
                     'lineno' => $line_num++,
                     'rev' => $curr_rev
                 );
@@ -107,7 +104,10 @@ class Horde_Vcs_Annotate_git extends Horde_Vcs_Annotate
                         break;
                     }
                 } else {
-                    list($curr_rev, , $line_num, $lines_group) = explode(' ', $line);
+                    $curr_line = explode(' ', $line);
+                    $curr_rev = $curr_line[0];
+                    $line_num = $curr_line[2];
+                    $lines_group = isset($curr_line[3]) ? $curr_line[3] : 1;
                 }
             }
         }