Indefero

Indefero Commit Details


Date:2011-06-01 17:48:38 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:20c3f14cc88d2245b9ba04ab6dd858e7a2f66f81
Parents: 80313c88c86d1b9a83b4734ddb58959a88879854
Message:git and hg diff views did not show empty context lines, a regression from the commit(s) from issue 633. The diff parser assumed a properly formatted diff that denotes empty context lines with a single space in the first column. This single space however was missing, because the hg and git backends got the diff through PHP's exec() function and this returns already line-splitted output, but - and this is the actual problem - removes trailing whitespace at the end of each line, essentially making " \n" only "\n". When splitting this string now again with PREG_SPLIT_NO_EMPTY the empty line was completely lost in the diff output.

To make it clear that an empty line does not mark a context line now, but
should stop the diff parsing, the Diff parser now also defaults to 'false'
as line type.

This commit fixes issue 688.
Changes:

File differences

NEWS.mdtext
1414
1515
1616
17
1718
1819
1920
- Timeline only displays filter options for items a user has actually access to (issue 655)
- The log, tags and branches parsers for Mercurial are more robust now (issue 663)
- Fix SSH public key parsing issues and improve the check for existing, uploaded keys (issue 679)
- Diff views now show empty context lines for git and hg again (issue 688)
- Let the SVN command line client not store the login credentials we give him as arguments
## Documentation
src/IDF/Diff.php
101101
102102
103103
104
104
105105
106106
107107
$files[$current_file]['chunks'][] = array();
while ($i < $diffsize && ($addlines >= 0 || $dellines >= 0)) {
$linetype = $this->lines[$i] != '' ? $this->lines[$i][0] : ' ';
$linetype = $this->lines[$i] != '' ? $this->lines[$i][0] : false;
switch ($linetype) {
case ' ':
$files[$current_file]['chunks'][$current_chunk][] =
src/IDF/Scm.php
8888
8989
9090
91
91
92
93
94
95
9296
9397
9498
9599
96100
97
98101
99102
100103
104
101105
102
106
107
108
109
110
111
112
113
114
115
116
117
118
103119
104120
105121
106
107122
108123
109124
}
/**
* Run exec and log some information.
* Runs the given command and log some information.
*
* A previous version used plain exec(), but this should not be used
* for various reasons, one being that this command does not preserve
* trailing whitespace, which is essential for proper diff parsing.
*
* @param $caller Calling method
* @param $cmd Command to run
* @param &$out Array of output
* @param &$return Return value
* @return string Last line of the command
*/
public static function exec($caller, $cmd, &$out=null, &$return=null)
{
$return = 1;
Pluf_Log::stime('timer');
$ret = exec($cmd, $out, $return);
$fp = popen($cmd, 'r');
$buf = '';
if ($fp !== false) {
$return = 0;
while (!feof($fp)) {
$buf .= fread($fp, 1024);
}
pclose($fp);
}
$out = preg_split('/\r\n|\r|\n/', $buf);
$elem = count($out);
if ($elem > 0 && $out[$elem-1] === '')
unset($out[$elem-1]);
Pluf_Log::perf(array($caller, $cmd, Pluf_Log::etime('timer', 'total_exec')));
Pluf_Log::debug(array($caller, $cmd, $out));
Pluf_Log::inc('exec_calls');
return $ret;
}
/**

Archive Download the corresponding diff file

Page rendered in 0.08898s using 15 queries.