Rewrite the diff parser and reduce the memory footprint.

The diff parser code was rewritten for clarity and speed and now handles
a couple of ugly cornercases, like SVN's property change output and single
change chunks, much better. Since the path parsing was unified as well,
the SCM interface gained a new method `getPathStripLevel()` which determines
how many path components need to be shoven off a file name for the SCM
to form a valid path in the workspace (similar to patch(1)'s --strip option).
Fixes issue 627. Automated tests follow.
This commit is contained in:
Patrick Georgi
2011-03-16 23:50:41 +01:00
committed by Thomas Keller
parent 6fb9b72e22
commit baa88412b9
7 changed files with 105 additions and 147 deletions

View File

@@ -32,29 +32,6 @@ class IDF_Tests_TestDiff extends UnitTestCase
parent::__construct('Test the diff parser.');
}
public function testGetFile()
{
$lines = array(
'diff --git a/src/IDF/Form/Register.php b/src/IDF/Form/Register.php',
'diff --git a/src/IDF/Form/RegisterConfirmation.php b/src/IDF/Form/RegisterConfirmation.php',
'diff --git a/src/IDF/Form/RegisterInputKey.php b/src/IDF/Form/RegisterInputKey.php',
'diff --git a/src/IDF/Views.php b/src/IDF/Views.php',
'diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php',
);
$files = array(
'src/IDF/Form/Register.php',
'src/IDF/Form/RegisterConfirmation.php',
'src/IDF/Form/RegisterInputKey.php',
'src/IDF/Views.php',
'src/IDF/conf/views.php',
);
$i = 0;
foreach ($lines as $line) {
$this->assertEqual($files[$i], IDF_Diff::getFile($line));
$i++;
}
}
public function testBinaryDiff()
{
$diff_content = file_get_contents(dirname(__FILE__).'/test-diff.diff');
@@ -90,4 +67,4 @@ class IDF_Tests_TestDiff extends UnitTestCase
$diff->files['src/IDF/Scm/Git.php']['chunks'][1][2]);
$this->assertEqual(7, count($diff->files['src/IDF/Scm/Git.php']['chunks'][1]));
}
}
}