aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/diff
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-03-22 16:34:26 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-03-22 16:34:26 +0000
commit4cbf6bc703bdadf716197b68a89b3438247ff022 (patch)
tree952f7fe84b9428d10e4d49d535c5108e06d4640a /phpBB/includes/diff
parentfac9c024ff370eb4c34f7a7ffa9048732e5c74c7 (diff)
downloadforums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar
forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.gz
forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.bz2
forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.xz
forums-4cbf6bc703bdadf716197b68a89b3438247ff022.zip
Merge most changes from 3.0.x branch since the 25th december.
(Captcha changes for refreshing captcha image not included) git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/diff')
-rw-r--r--phpBB/includes/diff/diff.php97
-rw-r--r--phpBB/includes/diff/engine.php2
-rw-r--r--phpBB/includes/diff/renderer.php2
3 files changed, 72 insertions, 29 deletions
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php
index 674a3b58b4..c5249ee3c1 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,31 +469,35 @@ 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')
{
- if ($get_conflicts)
- {
- foreach ($this->_edits as $edit)
- {
- if ($edit->is_conflict())
- {
- $this->_conflicting_blocks++;
- }
- }
-
- return $this->_conflicting_blocks;
- }
-
$label1 = (!empty(phpbb::$user->lang[$label1])) ? phpbb::$user->lang[$label1] : $label1;
$label2 = (!empty(phpbb::$user->lang[$label2])) ? phpbb::$user->lang[$label2] : $label2;
$label_sep = (!empty(phpbb::$user->lang[$label_sep])) ? phpbb::$user->lang[$label_sep] : $label_sep;
@@ -462,15 +508,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);
- }
- $this->_conflicting_blocks++;
+ // 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);
}
else
{
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 8194b63da6..2d3ab88a26 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