aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/diff
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-01-12 16:58:47 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-01-12 16:58:47 +0000
commit189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391 (patch)
tree928bd59f2380baa077a8684a80cdfd94bbf5b1b0 /phpBB/includes/diff
parent507d8b03851f6aa429766a6e0dd3b2926dc8e5e7 (diff)
downloadforums-189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391.tar
forums-189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391.tar.gz
forums-189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391.tar.bz2
forums-189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391.tar.xz
forums-189e7cdf45feb3f146ce059e5c2bcc6ccd0a7391.zip
- Allow download of conflicting file for later reference in automatic updater
- Default difference view is now 'inline' instead of 'side by side' - Added new option for merging differences to conflicting files in automatic updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9252 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/diff')
-rw-r--r--phpBB/includes/diff/diff.php57
-rw-r--r--phpBB/includes/diff/renderer.php2
2 files changed, 30 insertions, 29 deletions
diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php
index bc99ebdd85..70a4166b9c 100644
--- a/phpBB/includes/diff/diff.php
+++ b/phpBB/includes/diff/diff.php
@@ -107,7 +107,7 @@ class diff
*
* Example:
* <code>
- * $diff = new diff($lines1, $lines2);
+ * $diff = &new diff($lines1, $lines2);
* $rev = $diff->reverse();
* </code>
*
@@ -469,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;
@@ -506,15 +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);
- }
- $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
{
@@ -821,4 +822,4 @@ class diff3_block_builder
}
}
-?> \ No newline at end of file
+?>
diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php
index 02fb6ccc37..9144e0ab82 100644
--- a/phpBB/includes/diff/renderer.php
+++ b/phpBB/includes/diff/renderer.php
@@ -857,4 +857,4 @@ class diff_renderer_side_by_side extends diff_renderer
}
-?> \ No newline at end of file
+?>