yet another patch
Mathieu Arnold
arn_mat@club-internet.fr
Thu, 01 Mar 2001 11:40:34 +0100
Hi
this morning, i needed a human readable view with more than 3 lines of context,
so i added a few things, and a long link with 10 lines of context :
Index: cvs.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/cvs.php,v
retrieving revision 1.82
diff -u -r1.82 cvs.php
--- cvs.php 2001/02/27 07:05:59 1.82
+++ cvs.php 2001/03/01 10:36:59
@@ -168,6 +168,7 @@
if ($prevRevision = $lg->queryPreviousRevision()) {
$changedLines = $lg->lines;
$diffURL = url('diff',$where,array('r1'=>$prevRevision,'r2'=>$rev, 'f'=>'h'));
+ $LongDiffURL = url('diff',$where,array('r1'=>$prevRevision,'r2'=>$rev, 'f'=>'h', 'nl'=>10));
$uniDiffURL = url('diff',$where,array('r1'=>$prevRevision,'r2'=>$rev,'f'=>'u'));
}
Index: diff.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/diff.php,v
retrieving revision 1.25
diff -u -r1.25 diff.php
--- diff.php 2001/03/01 01:26:29 1.25
+++ diff.php 2001/03/01 10:36:59
@@ -48,6 +49,11 @@
$r2 = $tr2;
}
+/* If no line numbers has been specified, then default to 3 */
+
+if (!isset($nl)) {
+ $nl = 3;
+}
/* If no type has been specified, then default to unified */
if (!isset($f)) {
@@ -86,7 +92,7 @@
/* A plain-text diff */
else if ($f != 'h') {
header("Content-Type: text/plain\n\n");
- echo implode("\n",CVSLib_Diff::get($CVS, $fl, $r1, $r2, $type));
+ echo implode("\n",CVSLib_Diff::get($CVS, $fl, $r1, $r2, $type, $nl));
/* Human-Readable diff */
} else {
@@ -101,7 +107,7 @@
/* Retrieve the tree of changes from CVSLib */
$lns = CVSLib_Diff::humanReadable(
- CVSLib_Diff::get($CVS, $fl, $r1, $r2, CVSLIB_DIFF_UNIFIED));
+ CVSLib_Diff::get($CVS, $fl, $r1, $r2, CVSLIB_DIFF_UNIFIED, $nl));
/* TODO: check for errors here (CVSLib_Error returned) - avsm */
/* Is the diff empty? */
if (!sizeof($lns)) {
Index: lib/CVSLib/Diff.php
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/lib/CVSLib/Diff.php,v
retrieving revision 1.13
diff -u -r1.13 Diff.php
--- lib/CVSLib/Diff.php 2001/02/22 21:14:31 1.13
+++ lib/CVSLib/Diff.php 2001/03/01 10:36:59
@@ -24,10 +24,11 @@
* @param rev1 Original revision number to compare from
* @param rev2 New revision number to compare against
* @param type Constant which indicates the type of diff (e.g. unified)
+ * @param nl Number of lines to be used in context and unified diff
* @return false on failure, or a string containing the diff on success
*/
- function get($cvsrep, $file, $rev1, $rev2, $type = CVSLIB_DIFF_CONTEXT) {
+ function get($cvsrep, $file, $rev1, $rev2, $type = CVSLIB_DIFF_CONTEXT, $nl = 3) {
/* Make sure that the file parameter is valid */
if (!is_object($file) || $file->id() != CVSLIB_FILE) {
@@ -48,10 +49,10 @@
$options = '-kk ';
switch ($type) {
case CVSLIB_DIFF_CONTEXT:
- $options = '-p -c';
+ $options = '-p --context='.$nl;
break;
case CVSLIB_DIFF_UNIFIED:
- $options = '-p -u';
+ $options = '-p --unified='.$nl;
break;
case CVSLIB_DIFF_COLUMN:
$options = '--side-by-side --width=120';
Index: templates/diff_rev.inc
===================================================================
RCS file: /home/cvs/cvs/dup/horde/chora/templates/diff_rev.inc,v
retrieving revision 1.13
diff -u -r1.13 diff_rev.inc
--- templates/diff_rev.inc 2001/01/20 00:14:24 1.13
+++ templates/diff_rev.inc 2001/03/01 10:36:59
@@ -21,6 +21,7 @@
Changed since <b><?= $prevRevision ?></b>: <?= $changedLines ?>
<br />
<a href="<?= $diffURL ?>">Diffs to version <?= $prevRevision ?></a>
+(<a href="<?= $LongDiffURL ?>">long</a>)
(<a href="<?= $uniDiffURL ?>">unified</a>)
<br />
<?php endif; ?>
--
Mathieu Arnold