Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.3

Request #5373 Engine that handles existing diffs/patches
Submitted: 2005-09-12 21:07 UTC
From: o dot persson at gmail dot com Assigned: yunosh
Status: Closed Package: Text_Diff
PHP Version: 5.1.0 OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 20 - 12 = ?

 
 [2005-09-12 21:07 UTC] o dot persson at gmail dot com
Description: ------------ Would be really nice to be able to pass an existing diff and take benefit from the rendering functionality offered by this package. I use this myself to parse the output from svn diff. This is the dummy engine I use -- this could probably be solved in a better way. To use this class, ATM you need to explicitly instantiate the class: <?php $diff = file_get_contents('Text/Diff.php.patch'); $renderer = new Text_Diff_Renderer_inline(); $engine = new Text_Diff_Engine_string_diff($diff); echo $renderer->render($engine); ?> Test script: --------------- class Text_Diff_Engine_string_diff extends Text_Diff { function __construct($diff, $dummy = false) { if ($dummy == false) $this->_edits = $this->diff($diff); } function diff($diff, $dummy = null) { $diff = explode("\n", $diff); $edits = array(); foreach ($diff as $line) { switch ($line[0]) { case ' ': $edits[] = &new Text_Diff_Op_copy(array(substr($line, 1))); break; case '+': $edits[] = &new Text_Diff_Op_add(array(substr($line, 1))); break; case '-': $edits[] = &new Text_Diff_Op_delete(array(substr($line, 1))); break; } } return $edits; } }

Comments

 [2005-10-24 16:37 UTC] yunosh
This engine only deals with unified diffs at the moment. Any chance you can extend it to at least support context diffs and perhaps automatically detect the diff format?
 [2005-12-16 11:16 UTC] yunosh
Hello?
 [2005-12-27 22:34 UTC] yunosh
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.