From 7d64fd7f1086c1b5f9a5335067c56c9589f3435e Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 20 Dec 2005 23:46:03 +0000 Subject: [PATCH] Got most of the property stuff working --- diff.php | 18 +++++++++++++++- includes/svnlib.php | 37 +++++++++++++++++++++++++++++++++ templates/default/diff_file.tpl | 7 +++++++ templates/default/main.css | 21 +++++++++++++++++++ templates/default/property.tpl | 1 + 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 templates/default/property.tpl diff --git a/diff.php b/diff.php index 038fbc9..034c541 100644 --- a/diff.php +++ b/diff.php @@ -24,7 +24,8 @@ $fetchtemplates = array( 'diff_hunk', 'diff_file', 'diff', - 'file_change' + 'file_change', + 'property' ); require_once('./global.php'); @@ -76,6 +77,16 @@ $changes = ''; foreach ($diff->fetch() AS $filename => $file) { $hunktpl = ''; + $proplist = ''; + + if (!$filename) + { + continue; + } + + $props = $file['props']; + $show['props'] = (bool)$props; + unset($file['props']); foreach ($file AS $hunk) { @@ -113,6 +124,11 @@ foreach ($diff->fetch() AS $filename => $file) eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";'); } + foreach ($props AS $name => $value) + { + eval('$proplist .= "' . $template->fetch('property') . '";'); + } + eval('$changes .= "' . $template->fetch('diff_file') . '";'); } diff --git a/includes/svnlib.php b/includes/svnlib.php index b2db369..5c6ed9f 100644 --- a/includes/svnlib.php +++ b/includes/svnlib.php @@ -866,6 +866,7 @@ class SVNDiff $chunk = 0; $indexcounter = null; + $curprop = ''; $delstack = array(); @@ -873,12 +874,48 @@ class SVNDiff { if (preg_match('#^@@ \-([0-9]*),([0-9]*) \+([0-9]*),([0-9]*) @@$#', $line, $bits)) { + $property = false; $delstack = array(); $this->diff["$index"][ ++$chunk ]['hunk'] = array('old' => array('line' => $bits[1], 'count' => $bits[2]), 'new' => array('line' => $bits[3], 'count' => $bits[4])); $lines['old'] = $this->diff["$index"]["$chunk"]['hunk']['old']['line'] - 1; $lines['new'] = $this->diff["$index"]["$chunk"]['hunk']['new']['line'] - 1; continue; } + else if (preg_match('#^Property changes on: (.*?)$#', $line, $bits)) + { + $property = true; + $index = $bits[1]; + $this->diff["$index"]['props'] = array(); + continue; + } + + if ($property) + { + if (preg_match('#^__*_$#', trim($line))) + { + $viewsvn->debug("skipping: $line"); + continue; + } + + if (preg_match('#Name: (.*?)$#', $line, $matches)) + { + $curprop = $matches[1]; + $viewsvn->debug("prop: $curprop"); + continue; + } + else + { + if (preg_match('#^\s+?\+(.*)#', $line, $matches)) + { + $this->diff["$index"]['props']["$curprop"] .= $matches[1]; + } + else if (!preg_match('#^\s+[\+\- ](.*)#', $line) AND trim($line) != '') + { + $this->diff["$index"]['props']["$curprop"] .= "\n" . $line; + } + continue; + } + } if ($indexcounter <= 3 AND $indexcounter !== null) { diff --git a/templates/default/diff_file.tpl b/templates/default/diff_file.tpl index e2b2cdd..6182880 100644 --- a/templates/default/diff_file.tpl +++ b/templates/default/diff_file.tpl @@ -1,4 +1,11 @@
$filename
+ +
+
    +$proplist +
+
+
$hunktpl
\ No newline at end of file diff --git a/templates/default/main.css b/templates/default/main.css index 1d3672c..c854ad3 100644 --- a/templates/default/main.css +++ b/templates/default/main.css @@ -100,6 +100,27 @@ a:hover padding: 2px; } +.propbox +{ + background-color: rgb(239, 239, 239); + + border-color: rgb(153, 153, 153); + border-width: 1px 1px 1px 1px; + border-style: dashed; +} + + .propbox ul + { + margin: 5px; + padding-left: 15px; + } + + .propbox li + { + margin: 0px; + padding: 0px; + } + .list li { list-style-image: url(bullet.gif); diff --git a/templates/default/property.tpl b/templates/default/property.tpl new file mode 100644 index 0000000..55de201 --- /dev/null +++ b/templates/default/property.tpl @@ -0,0 +1 @@ +
  • Property $name set to $value
  • -- 2.43.5