Remove the extra path part
[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 = $controller->construct_breadcrumb();
34
35 // ###################################################################
36
37 $link['log'] = $controller->href_compound('log.php');
38
39 // ###################################################################
40
41 $revs = Paths::fetch_rev_num(true);
42 $high = $revs['high'];
43 $low = $revs['low'];
44
45 if ($high == 'HEAD')
46 {
47 $high = $controller->cachev->fetch_head_revision();
48 }
49
50 if ($low == 0)
51 {
52 $low = $controller->cachev->fetch_prev_revision($high);
53 $low = $low['revision'];
54 }
55
56 // ###################################################################
57
58 $show['fullchangeset'] = (Paths::is_root_path($controller->path) ? false : true);
59 if ($show['fullchangeset'])
60 {
61 $link['changeset'] = $controller->href_struct('diff.php' . Paths::fetch_rev_str(true, $high, $low), $controller->repos . '/');
62 }
63
64 $log = $controller->cachev->fetch_revision($high);
65
66 $log['message_clean'] = SVNCommon::format_log_message($log['message']);
67 $log['date'] = SVNCommon::format_date_string($log['dateline']);
68
69 $files = SVNCommon::construct_file_changes($log['files'], $controller->repos, $high);
70
71 // ###################################################################
72
73 $diff = new SVNDiff($controller, $low, $high);
74
75 $isdir = (bool)$controller->cachev->isdir();
76
77 $changes = '';
78
79 foreach ($diff->fetch() AS $filename => $file)
80 {
81 $hunktpl = '';
82 $proplist = '';
83
84 if (!$filename)
85 {
86 continue;
87 }
88
89 $props = $file['props'];
90 $show['props'] = (bool)$props;
91 unset($file['props']);
92
93 foreach ($file AS $hunk)
94 {
95 $lines = '';
96 foreach ($hunk AS $key => $line)
97 {
98 $show['hunk'] = false;
99 if ($key == 'hunk' AND isset($line['old']))
100 {
101 $filepath = ($isdir ? $controller->path . $filename : $controller->path);
102 $rlow = $controller->href_struct('view.php' . Paths::fetch_rev_str(false, $low), $filepath);
103 $rhigh = $controller->href_struct('view.php' . Paths::fetch_rev_str(false, $high), $filepath);
104 $show['hunk'] = true;
105 }
106 else
107 {
108 if ($line['act'] == '+')
109 {
110 $class = 'diff_add';
111 }
112 else if ($line['act'] == '-')
113 {
114 $class = 'diff_del';
115 }
116 else
117 {
118 $class = 'diff_norm';
119 }
120
121 $line['line_clean'] = SVNCommon::format($line['line']);
122 }
123
124 eval('$lines .= "' . $template->fetch('diff_line') . '";');
125 }
126 eval('$hunktpl .= "' . $template->fetch('diff_hunk') . '";');
127 }
128
129 foreach ($props AS $name => $values)
130 {
131 // modified
132 if (isset($values['add']) AND isset($values['del']))
133 {
134 $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']);
135 }
136 // added
137 else if (isset($values['add']))
138 {
139 $data = sprintf($lang->string('Property <strong>%1$s</strong> set to <em>%2$s</em>'), $name, $values['add']);
140 }
141 // removed
142 else if (isset($values['del']))
143 {
144 $data = sprintf($lang->string('Property <strong>%1$s</strong> deleted'), $name);
145 }
146 eval('$proplist .= "' . $template->fetch('property') . '";');
147 }
148
149 eval('$changes .= "' . $template->fetch('diff_file') . '";');
150 }
151
152 // ###################################################################
153
154 //echo('$template->flush("' . $template->fetch('diff') . '");');
155 eval('$template->flush("' . $template->fetch('diff') . '");');
156
157 /*=====================================================================*\
158 || ###################################################################
159 || # $HeadURL$
160 || # $Id$
161 || ###################################################################
162 \*=====================================================================*/
163 ?>