Adding support for properties to be the only change in a diff
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 23 Apr 2007 00:29:16 +0000 (00:29 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 23 Apr 2007 00:29:16 +0000 (00:29 +0000)
diff.php
includes/class_diff.php

index 32e0837a855f710628cb4b979ea97e6c8a9f210e..71de17d1a3512fd893fe351a9a30d058b2aa884f 100644 (file)
--- 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']))
index 9fd43e62d0e5a8d262d97c4575fce25ce0645184..f7083413ba6eb4e41a738918478426ec59a858ab 100644 (file)
@@ -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];