Indefero

Indefero Commit Details


Date:2009-02-02 13:55:45 (15 years 10 months ago)
Author:Loic d'Anterroches
Branch:dev, 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:d594b3412a2ef95089c7955325c4571cca80d8ed
Parents: 269f1db8160974a87719f144c125f1e6d6351b49
Message:Fixed issue 129, code review crashes on git diff files.

The diff parser tries now to skip the header and possible footer.
Changes:

File differences

src/IDF/Diff.php
4747
4848
4949
50
51
5052
53
54
55
56
57
5158
5259
5360
5461
5562
5663
64
5765
5866
5967
......
6169
6270
6371
72
6473
6574
6675
......
6877
6978
7079
80
81
82
83
7184
7285
7386
$lline = 0;
$rline = 0;
$files = array();
$indiff = false; // Used to skip the headers in the git patches
$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])
and preg_match('/^\d+\.\d+\.\d+\.\d+$/', $this->lines[$i])) {
break;
}
if (0 === strpos($line, 'diff --git a')) {
$current_file = self::getFile($line);
$files[$current_file] = array();
$files[$current_file]['chunks'] = array();
$files[$current_file]['chunks_def'] = array();
$current_chunk = 0;
$indiff = true;
continue;
} else if (preg_match('#^diff -r [^\s]+ -r [^\s]+ (.+)$#', $line, $matches)) {
$current_file = $matches[1];
$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]['chunks'] = array();
$files[$current_file]['chunks_def'] = array();
$current_chunk = 0;
$indiff = true;
continue;
}
if (!$indiff) {
continue;
}
if (0 === strpos($line, '@@ ')) {
src/IDF/Tests/0001-Some-configuration-variables-have-been-added-in-orde.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From ec6cb8b19ee3a08f48625181d6a74744b3950e90 Mon Sep 17 00:00:00 2001
From: Manuel Eidenberger <eidenberger@...>
Date: Mon, 2 Feb 2009 15:11:23 +0100
Subject: [PATCH] Some configuration variables have been added in order to manually set svn and svnlook binarie paths (see issue 123)
---
src/IDF/Scm/Svn.php | 24 ++++++++++++------------
src/IDF/conf/idf.php-dist | 8 ++++++++
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/IDF/Scm/Svn.php b/src/IDF/Scm/Svn.php
index e2f7a61..e1359c7 100644
--- a/src/IDF/Scm/Svn.php
+++ b/src/IDF/Scm/Svn.php
@@ -108,7 +108,7 @@ class IDF_Scm_Svn
}
// Else, test the path on revision
- $cmd = sprintf('svn info --xml --username=%s --password=%s %s@%s',
+ $cmd = sprintf(Pluf::f('svn_path').' info --xml --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($this->repo.'/'.$path),
@@ -190,7 +190,7 @@ class IDF_Scm_Svn
*/
private function getCommitMessage($file, $rev='HEAD')
{
- $cmd = sprintf('svn log --xml --limit 1 --username=%s --password=%s %s@%s',
+ $cmd = sprintf(Pluf::f('svn_path').' log --xml --limit 1 --username=%s --password=%s %s@%s',
escapeshellarg($this->username),
escapeshellarg($this->password),
escapeshellarg($file),
diff --git a/src/IDF/conf/idf.php-dist b/src/IDF/conf/idf.php-dist
index 8aca31f..abb4ecd 100644
--- a/src/IDF/conf/idf.php-dist
+++ b/src/IDF/conf/idf.php-dist
@@ -208,4 +208,12 @@ $cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git',
# variables not being set correctly. Note the trailing space.
# $cfg['idf_exec_cmd_prefix'] = '/usr/bin/env -i ';
+# Path to svn and svnlook binaries. In some cases, it is sometimes
+# necessary to define absolut path to these two binaries, for example:
+# $cfg['svn_path'] = 'svn';
+# $cfg['svnlook_path'] = 'svnlook_path';
+# This is only necessary if svn and svnlook binaries are not set in $PATH
+$cfg['svn_path'] = 'svn';
+$cfg['svnlook_path'] = 'svnlook';
+
return $cfg;
--
1.5.4.3
src/IDF/Tests/TestDiff.php
6969
7070
7171
72
72
73
74
75
76
77
78
79
80
7381
7482
$lline = end($lchunk);
$this->assertEqual(array('', '166', '{/if}{/block}'),
$lline);
//print_r($diff->mergeChunks($orig_lines, $def, 10));
}
public function testDiffWithHeaders()
{
$diff_content = file_get_contents(dirname(__FILE__).'/0001-Some-configuration-variables-have-been-added-in-orde.patch');
$diff = new IDF_Diff($diff_content);
$diff->parse();
$this->assertEqual(2, count($diff->files));
$this->assertEqual(12, count($diff->files['src/IDF/conf/idf.php-dist']['chunks'][0]));
}
}

Archive Download the corresponding diff file

Page rendered in 0.08323s using 14 queries.