]> src.bluestatic.org Git - viewsvn.git/blob - diff.php
Define ISSO_DB_LAYER
[viewsvn.git] / diff.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'diff_line',
24 'diff_hunk',
25 'diff_file',
26 'diff',
27 'file_change',
28 'property'
29 );
30
31 require_once('./global.php');
32
33 $navbar = $viewsvn->paths->construct_breadcrumb($viewsvn->paths->path, false);
34
35 // ###################################################################
36
37 $link['log'] = $viewsvn->paths->out('log.php' . $viewsvn->paths->revstr, $viewsvn->paths->path);
38
39 // ###################################################################
40
41 $revs = $viewsvn->paths->fetch_rev_num(true);
42 $high = $revs['high'];
43 $low = $revs['low'];
44
45 if ($high == 'HEAD')
46 {
47 $high = $viewsvn->svn->common->fetch_head_rev($viewsvn->paths->path);
48 }
49
50 if ($low == 0)
51 {
52 $low = $viewsvn->svn->common->fetch_prev_rev($viewsvn->paths->path, $high);
53 }
54
55 // ###################################################################
56
57 $show['fullchangeset'] = ($viewsvn->paths->is_root_path($viewsvn->paths->path) ? false : true);
58 if ($show['fullchangeset'])
59 {
60 $link['changeset'] = $viewsvn->paths->out('diff.php' . $viewsvn->paths->fetch_rev_str(true, $high, $low), $viewsvn->paths->repos . '/');
61 }
62
63 $log = $viewsvn->svn->common->fetch_log($viewsvn->paths->path, $high);
64
65 $log['message_clean'] = $viewsvn->svn->format_log_message($log['message']);
66
67 $files = $viewsvn->svn->common->construct_file_changes($log['files'], $viewsvn->paths->repos, $high);
68
69 // ###################################################################
70
71 $diff = new SVNDiff($viewsvn->paths->repos, $viewsvn->paths->relpath, $low, $high);
72
73 $isdir = (bool)$viewsvn->svn->common->isdir($viewsvn->paths->path);
74
75 $changes = '';
76
77 foreach ($diff->fetch() AS $filename => $file)
78 {
79 $hunktpl = '';
80 $proplist = '';
81
82 if (!$filename)
83 {
84 continue;
85 }
86
87 $props = $file['props'];
88 $show['props'] = (bool)$props;
89 unset($file['props']);
90
91 foreach ($file AS $hunk)
92 {
93 $lines = '';
94 foreach ($hunk AS $key => $line)
95 {
96 $show['hunk'] = false;
97 if ($key == 'hunk' AND isset($line['old']))
98 {
99 $filepath = ($isdir ? $viewsvn->paths->path . $filename : $viewsvn->paths->path);
100 $rlow = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $low), $filepath);
101 $rhigh = $viewsvn->paths->out('view.php' . $viewsvn->paths->fetch_rev_str(false, $high), $filepath);
102 $show['hunk'] = true;
103 }
104 else
105 {
106 if ($line['act'] == '+')
107 {
108 $class = 'diff_add';
109 }
110 else if ($line['act'] == '-')
111 {
112 $class = 'diff_del';
113 }
114 else
115 {
116 $class = 'diff_norm';
117 }
118
119 $line['line_clean'] = $viewsvn->svn->format($line['line']);
120 }
121
122 eval('$lines .= "' . $template->fetch('diff_line') . '";');
123 }
124 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
125 }
126
127 foreach ($props AS $name => $values)
128 {
129 // modified
130 if (isset($values['add']) AND isset($values['del']))
131 {
132 $data = sprintf($lang->string('Property <strong>%1$s</strong> changed from <em>%2$s</em> to <em>%3$s</em>'), $name, $values['del'], $values['add']);
133 }
134 // added
135 else if (isset($values['add']))
136 {
137 $data = sprintf($lang->string('Property <strong>%1$s</strong> set to <em>%2$s</em>'), $name, $values['add']);
138 }
139 // removed
140 else if (isset($values['del']))
141 {
142 $data = sprintf($lang->string('Property <strong>%1$s</strong> deleted'), $name);
143 }
144 eval('$proplist .= "' . $template->fetch('property') . '";');
145 }
146
147 eval('$changes .= "' . $template->fetch('diff_file') . '";');
148 }
149
150 // ###################################################################
151
152 //echo('$template->flush("' . $template->fetch('diff') . '");');
153 eval('$template->flush("' . $template->fetch('diff') . '");');
154
155 /*=====================================================================*\
156 || ###################################################################
157 || # $HeadURL$
158 || # $Id$
159 || ###################################################################
160 \*=====================================================================*/
161 ?>