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  


 [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] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-16 11:16 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-27 22:34 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!