Indefero

Indefero Commit Details


Date:2010-04-30 17:56:48 (14 years 7 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:15a2bd90b35a629e7f3551fe120efe1c02bbf20d
Parents: c49a8204e00ca385032098120000e2b1647fbaef
Message:Add support for monotone's diff header

Changes:

File differences

src/IDF/Diff.php
5151
5252
5353
54
54
5555
5656
5757
......
7171
7272
7373
74
75
76
77
78
79
80
81
7482
7583
7684
......
133141
134142
135143
144
145
146
147
148
149
136150
137151
138152
......
215229
216230
217231
218
232
219233
220234
221235
222236
223237
224238
225
239
226240
227241
228242
......
250264
251265
252266
253
267
254268
255269
256270
......
259273
260274
261275
262
276
263277
264278
265279
......
283297
284298
285299
286
300
287301
288302
289303
......
305319
306320
307321
308
322
309323
310324
311325
$i = 0; // Used to skip the end of a git patch with --\nversion number
foreach ($this->lines as $line) {
$i++;
if (0 === strpos($line, '--') and isset($this->lines[$i])
if (0 === strpos($line, '--') and isset($this->lines[$i])
and preg_match('/^\d+\.\d+\.\d+\.\d+$/', $this->lines[$i])) {
break;
}
$current_chunk = 0;
$indiff = true;
continue;
} else if (0 === strpos($line, '=========')) {
$current_file = self::getMtnFile($this->lines[$i+1]);
$files[$current_file] = array();
$files[$current_file]['chunks'] = array();
$files[$current_file]['chunks_def'] = array();
$current_chunk = 0;
$indiff = true;
continue;
} else if (0 === strpos($line, 'Index: ')) {
$current_file = self::getSvnFile($line);
$files[$current_file] = array();
return substr(trim($line), 7);
}
public static function getMtnFile($line)
{
preg_match("/^[+-]{3} ([^\t]+)/", $line, $m);
return $m[1];
}
/**
* Return the html version of a parsed diff.
*/
* @param int Number of lines before/after the chunk to be displayed (10)
* @return Pluf_Template_SafeString The table body
*/
public function fileCompare($orig, $chunks, $filename, $context=10)
public function fileCompare($orig, $chunks, $filename, $context=10)
{
$orig_lines = preg_split("/\015\012|\015|\012/", $orig);
$new_chunks = $this->mergeChunks($orig_lines, $chunks, $context);
return $this->renderCompared($new_chunks, $filename);
}
public function mergeChunks($orig_lines, $chunks, $context=10)
public function mergeChunks($orig_lines, $chunks, $context=10)
{
$spans = array();
$new_chunks = array();
for ($lc=$spans[$i][0];$lc<$chunk[0][0];$lc++) {
$exists = false;
foreach ($chunk_lines as $line) {
if ($lc == $line[0]
if ($lc == $line[0]
or ($chunk[0][1]-$chunk[0][0]+$lc) == $line[1]) {
$exists = true;
break;
if (!$exists) {
$orig = isset($orig_lines[$lc-1]) ? $orig_lines[$lc-1] : '';
$n_chunk[] = array(
$lc,
$lc,
$chunk[0][1]-$chunk[0][0]+$lc,
$orig
);
}
if (!$exists) {
$n_chunk[] = array(
$lc,
$lc,
$lline[1]-$lline[0]+$lc,
$orig_lines[$lc-1]
);
foreach ($chunk as $line) {
if ($line[0] > $lline[0] or empty($line[0])) {
$nnew_chunks[$i-1][] = $line;
}
}
}
} else {
$nnew_chunks[] = $chunk;

Archive Download the corresponding diff file

Page rendered in 0.08105s using 13 queries.