From 8ee44456b739b26efb52ecba8d06d23606707d91 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 23 Apr 2007 00:29:16 +0000 Subject: [PATCH] Adding support for properties to be the only change in a diff --- diff.php | 61 +++++++++++++++++++++-------------------- includes/class_diff.php | 8 ++++++ 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/diff.php b/diff.php index 32e0837..71de17d 100644 --- a/diff.php +++ b/diff.php @@ -67,40 +67,43 @@ foreach ($diff->fetch() AS $filename => $file) continue; } - foreach ($file['lines'] AS $hunk) + if (is_array($file['lines'])) { - $lines = ''; - - $show['hunk'] = true; - $low = $file['revision']['low']; - $high = $file['revision']['high']; - - $filename = (preg_match('/' . preg_quote($filename, '/') . '$/', $input->in['path']) ? $input->in['path'] : BSFunctions::FetchSourcePath($input->in['path']) . $filename); - $rlow = ConstructLink('view', $input->in['repos'], $filename, $low); - $rhigh = ConstructLink('view', $input->in['repos'], $filename, $high); - eval('$lines .= "' . $template->fetch('diff_line') . '";'); - - foreach ($hunk AS $key => $line) + foreach ($file['lines'] AS $hunk) { - $show['hunk'] = false; - if ($line['act'] == '+') - { - $class = 'diff_add'; - } - else if ($line['act'] == '-') - { - $class = 'diff_del'; - } - else + $lines = ''; + + $show['hunk'] = true; + $low = $file['revision']['low']; + $high = $file['revision']['high']; + + $filename = (preg_match('/' . preg_quote($filename, '/') . '$/', $input->in['path']) ? $input->in['path'] : BSFunctions::FetchSourcePath($input->in['path']) . $filename); + $rlow = ConstructLink('view', $input->in['repos'], $filename, $low); + $rhigh = ConstructLink('view', $input->in['repos'], $filename, $high); + eval('$lines .= "' . $template->fetch('diff_line') . '";'); + + foreach ($hunk AS $key => $line) { - $class = 'diff_norm'; + $show['hunk'] = false; + if ($line['act'] == '+') + { + $class = 'diff_add'; + } + else if ($line['act'] == '-') + { + $class = 'diff_del'; + } + else + { + $class = 'diff_norm'; + } + + $line['line_clean'] = FormatCode($line['line']); + + eval('$lines .= "' . $template->fetch('diff_line') . '";'); } - - $line['line_clean'] = FormatCode($line['line']); - - eval('$lines .= "' . $template->fetch('diff_line') . '";'); + eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";'); } - eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";'); } if (is_array($file['props'])) diff --git a/includes/class_diff.php b/includes/class_diff.php index 9fd43e6..f708341 100644 --- a/includes/class_diff.php +++ b/includes/class_diff.php @@ -89,6 +89,8 @@ class Diff */ public function fetch() { + $this->diff = array(); + for ($i = 0; $i < sizeof($this->raw); $i++) { $line = $this->raw[$i]; @@ -99,6 +101,11 @@ class Diff $this->captureStart = $i; $this->index = $index[1]; } + else if (preg_match('/Property changes on: (.*)/', $line, $index)) + { + $this->index = $index[1]; + $this->_processProperties(array_slice($this->raw, 2)); + } } $this->_processFile(array_slice($this->raw, $this->captureStart)); @@ -120,6 +127,7 @@ class Diff $this->hunkId = 0; $captureStart = 4; + for ($i = 4; $i < sizeof($lines); $i++) { $line = $lines[$i]; -- 2.43.5