mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
- 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
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -857,4 +857,4 @@ class diff_renderer_side_by_side extends diff_renderer
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user