diff options
author | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:39 +0100 |
commit | a45bca7c49623341ae971d4e1014ba9de38de982 (patch) | |
tree | a1f033124b14c020e850525a6ea745cb7cb3dbab /phpBB/includes/diff | |
parent | 1f3498c0d6a20a08fe17948b32fc435f85a6eff8 (diff) | |
parent | 6485d66743d55aeba95aed86fcde4a0e555e3104 (diff) | |
download | forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.gz forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.bz2 forums-a45bca7c49623341ae971d4e1014ba9de38de982.tar.xz forums-a45bca7c49623341ae971d4e1014ba9de38de982.zip |
Merge commit 'release-3.0.5-RC1'
Diffstat (limited to 'phpBB/includes/diff')
-rw-r--r-- | phpBB/includes/diff/diff.php | 106 | ||||
-rw-r--r-- | phpBB/includes/diff/engine.php | 2 | ||||
-rw-r--r-- | phpBB/includes/diff/renderer.php | 2 |
3 files changed, 82 insertions, 28 deletions
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index ef018b2d9a..2adc3a3e6e 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -17,7 +17,7 @@ if (!defined('IN_PHPBB')) } /** -* Code from pear.php.net, Text_Diff-1.0.0 package +* Code from pear.php.net, Text_Diff-1.1.0 package * http://pear.php.net/package/Text_Diff/ * * Modified by phpBB Group to meet our coding standards @@ -61,6 +61,48 @@ class diff } /** + * returns the number of new (added) lines in a given diff. + * + * @since Text_Diff 1.1.0 + * + * @return integer The number of new lines + */ + function count_added_lines() + { + $count = 0; + + foreach ($this->_edits as $edit) + { + if (is_a($edit, 'diff_op_add') || is_a($edit, 'diff_op_change')) + { + $count += $edit->nfinal(); + } + } + return $count; + } + + /** + * Returns the number of deleted (removed) lines in a given diff. + * + * @since Text_Diff 1.1.0 + * + * @return integer The number of deleted lines + */ + function count_deleted_lines() + { + $count = 0; + + foreach ($this->_edits as $edit) + { + if (is_a($edit, 'diff_op_delete') || is_a($edit, 'diff_op_change')) + { + $count += $edit->norig(); + } + } + return $count; + } + + /** * Computes a reversed diff. * * Example: @@ -427,33 +469,37 @@ class diff3 extends diff } /** - * Return merged output + * Return number of conflicts + */ + function get_num_conflicts() + { + $conflicts = 0; + + foreach ($this->_edits as $edit) + { + if ($edit->is_conflict()) + { + $conflicts++; + } + } + + return $conflicts; + } + + /** + * Get conflicts content for download. This is generally a merged file, but preserving conflicts and adding explanations to it. + * A user could then go through this file, search for the conflicts and changes the code accordingly. * * @param string $label1 the cvs file version/label from the original set of lines * @param string $label2 the cvs file version/label from the new set of lines * @param string $label_sep the explanation between label1 and label2 - more of a helper for the user - * @param bool $get_conflicts if set to true only the number of conflicts is returned - * @param bool $merge_new if set to true the merged output will have the new file contents on a conflicting merge * * @return mixed the merged output */ - function merged_output($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN', $get_conflicts = false, $merge_new = false) + function get_conflicts_content($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN') { global $user; - if ($get_conflicts) - { - foreach ($this->_edits as $edit) - { - if ($edit->is_conflict()) - { - $this->_conflicting_blocks++; - } - } - - return $this->_conflicting_blocks; - } - $label1 = (!empty($user->lang[$label1])) ? $user->lang[$label1] : $label1; $label2 = (!empty($user->lang[$label2])) ? $user->lang[$label2] : $label2; $label_sep = (!empty($user->lang[$label_sep])) ? $user->lang[$label_sep] : $label_sep; @@ -464,14 +510,12 @@ class diff3 extends diff { if ($edit->is_conflict()) { - if (!$merge_new) - { - $lines = array_merge($lines, array('<<<<<<<' . ($label1 ? ' ' . $label1 : '')), $edit->final1, array('=======' . ($label_sep ? ' ' . $label_sep : '')), $edit->final2, array('>>>>>>>' . ($label2 ? ' ' . $label2 : ''))); - } - else - { - $lines = array_merge($lines, $edit->final1); - } + // Start conflict label + $label_start = array('<<<<<<< ' . $label1); + $label_mid = array('======= ' . $label_sep); + $label_end = array('>>>>>>> ' . $label2); + + $lines = array_merge($lines, $label_start, $edit->final1, $label_mid, $edit->final2, $label_end); $this->_conflicting_blocks++; } else @@ -484,6 +528,16 @@ class diff3 extends diff } /** + * Return merged output (used by the renderer) + * + * @return mixed the merged output + */ + function merged_output() + { + return $this->get_conflicts_content(); + } + + /** * Merge the output and use the new file code for conflicts */ function merged_new_output() diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index d82afb048a..eb0dcce395 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -17,7 +17,7 @@ if (!defined('IN_PHPBB')) } /** -* Code from pear.php.net, Text_Diff-1.0.0 package +* Code from pear.php.net, Text_Diff-1.1.0 package * http://pear.php.net/package/Text_Diff/ (native engine) * * Modified by phpBB Group to meet our coding standards diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php index 2e0ec86e75..02fb6ccc37 100644 --- a/phpBB/includes/diff/renderer.php +++ b/phpBB/includes/diff/renderer.php @@ -17,7 +17,7 @@ if (!defined('IN_PHPBB')) } /** -* Code from pear.php.net, Text_Diff-1.0.0 package +* Code from pear.php.net, Text_Diff-1.1.0 package * http://pear.php.net/package/Text_Diff/ * * Modified by phpBB Group to meet our coding standards |