Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
988c1340
Commit
988c1340
authored
14 years ago
by
Piyush Mishra
Browse files
Options
Downloads
Patches
Plain Diff
Done with DifferenceEngine.php
parent
ee1214ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/DifferenceEngine.php
+89
-10
89 additions, 10 deletions
inc/DifferenceEngine.php
with
89 additions
and
10 deletions
inc/DifferenceEngine.php
+
89
−
10
View file @
988c1340
...
@@ -29,8 +29,14 @@ class _DiffOp {
...
@@ -29,8 +29,14 @@ class _DiffOp {
class
_DiffOp_Copy
extends
_DiffOp
{
class
_DiffOp_Copy
extends
_DiffOp
{
var
$type
=
'copy'
;
var
$type
=
'copy'
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
_DiffOp_Copy
(
$orig
,
$closing
=
false
)
{
function
_DiffOp_Copy
(
$orig
,
$closing
=
false
)
{
$this
->
__construct
(
$orig
,
$closing
);
}
function
__construct
(
$orig
,
$closing
=
false
)
{
if
(
!
is_array
(
$closing
))
if
(
!
is_array
(
$closing
))
$closing
=
$orig
;
$closing
=
$orig
;
$this
->
orig
=
$orig
;
$this
->
orig
=
$orig
;
...
@@ -44,8 +50,14 @@ class _DiffOp_Copy extends _DiffOp {
...
@@ -44,8 +50,14 @@ class _DiffOp_Copy extends _DiffOp {
class
_DiffOp_Delete
extends
_DiffOp
{
class
_DiffOp_Delete
extends
_DiffOp
{
var
$type
=
'delete'
;
var
$type
=
'delete'
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
_DiffOp_Delete
(
$lines
)
{
function
_DiffOp_Delete
(
$lines
)
{
$this
->
__construct
(
$lines
);
}
function
__construct
(
$lines
)
{
$this
->
orig
=
$lines
;
$this
->
orig
=
$lines
;
$this
->
closing
=
false
;
$this
->
closing
=
false
;
}
}
...
@@ -57,8 +69,14 @@ class _DiffOp_Delete extends _DiffOp {
...
@@ -57,8 +69,14 @@ class _DiffOp_Delete extends _DiffOp {
class
_DiffOp_Add
extends
_DiffOp
{
class
_DiffOp_Add
extends
_DiffOp
{
var
$type
=
'add'
;
var
$type
=
'add'
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
_DiffOp_Add
(
$lines
)
{
function
_DiffOp_Add
(
$lines
)
{
$this
->
__construct
(
$lines
);
}
function
__construct
(
$lines
)
{
$this
->
closing
=
$lines
;
$this
->
closing
=
$lines
;
$this
->
orig
=
false
;
$this
->
orig
=
false
;
}
}
...
@@ -70,8 +88,14 @@ class _DiffOp_Add extends _DiffOp {
...
@@ -70,8 +88,14 @@ class _DiffOp_Add extends _DiffOp {
class
_DiffOp_Change
extends
_DiffOp
{
class
_DiffOp_Change
extends
_DiffOp
{
var
$type
=
'change'
;
var
$type
=
'change'
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
_DiffOp_Change
(
$orig
,
$closing
)
{
function
_DiffOp_Change
(
$orig
,
$closing
)
{
$this
->
__construct
(
$orig
,
$closing
);
}
function
__construct
(
$orig
,
$closing
)
{
$this
->
orig
=
$orig
;
$this
->
orig
=
$orig
;
$this
->
closing
=
$closing
;
$this
->
closing
=
$closing
;
}
}
...
@@ -490,6 +514,13 @@ class _DiffEngine {
...
@@ -490,6 +514,13 @@ class _DiffEngine {
class
Diff
{
class
Diff
{
var
$edits
;
var
$edits
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
Diff
(
$from_lines
,
$to_lines
)
{
$this
->
__construct
(
$from_lines
,
$to_lines
);
}
/**
/**
* Constructor.
* Constructor.
...
@@ -499,7 +530,7 @@ class Diff {
...
@@ -499,7 +530,7 @@ class Diff {
* (Typically these are lines from a file.)
* (Typically these are lines from a file.)
* @param $to_lines array An array of strings.
* @param $to_lines array An array of strings.
*/
*/
function
Diff
(
$from_lines
,
$to_lines
)
{
function
__construct
(
$from_lines
,
$to_lines
)
{
$eng
=
new
_DiffEngine
;
$eng
=
new
_DiffEngine
;
$this
->
edits
=
$eng
->
diff
(
$from_lines
,
$to_lines
);
$this
->
edits
=
$eng
->
diff
(
$from_lines
,
$to_lines
);
//$this->_check($from_lines, $to_lines);
//$this->_check($from_lines, $to_lines);
...
@@ -622,6 +653,13 @@ class Diff {
...
@@ -622,6 +653,13 @@ class Diff {
* FIXME: bad name.
* FIXME: bad name.
*/
*/
class
MappedDiff
extends
Diff
{
class
MappedDiff
extends
Diff
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
MappedDiff
(
$from_lines
,
$to_lines
,
$mapped_from_lines
,
$mapped_to_lines
)
{
$this
->
__construct
(
$from_lines
,
$to_lines
,
$mapped_from_lines
,
$mapped_to_lines
);
}
/**
/**
* Constructor.
* Constructor.
*
*
...
@@ -645,12 +683,12 @@ class MappedDiff extends Diff {
...
@@ -645,12 +683,12 @@ class MappedDiff extends Diff {
* @param $mapped_to_lines array This array should
* @param $mapped_to_lines array This array should
* have the same number of elements as $to_lines.
* have the same number of elements as $to_lines.
*/
*/
function
MappedDiff
(
$from_lines
,
$to_lines
,
$mapped_from_lines
,
$mapped_to_lines
)
{
function
__construct
(
$from_lines
,
$to_lines
,
$mapped_from_lines
,
$mapped_to_lines
)
{
assert
(
count
(
$from_lines
)
==
count
(
$mapped_from_lines
));
assert
(
count
(
$from_lines
)
==
count
(
$mapped_from_lines
));
assert
(
count
(
$to_lines
)
==
count
(
$mapped_to_lines
));
assert
(
count
(
$to_lines
)
==
count
(
$mapped_to_lines
));
$this
->
Diff
(
$mapped_from_lines
,
$mapped_to_lines
);
parent
::
__construct
(
$mapped_from_lines
,
$mapped_to_lines
);
$xi
=
$yi
=
0
;
$xi
=
$yi
=
0
;
$ecnt
=
count
(
$this
->
edits
);
$ecnt
=
count
(
$this
->
edits
);
...
@@ -827,7 +865,14 @@ class DiffFormatter {
...
@@ -827,7 +865,14 @@ class DiffFormatter {
define
(
'NBSP'
,
"
\xC2\xA0
"
);
// utf-8 non-breaking space.
define
(
'NBSP'
,
"
\xC2\xA0
"
);
// utf-8 non-breaking space.
class
_HWLDF_WordAccumulator
{
class
_HWLDF_WordAccumulator
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
_HWLDF_WordAccumulator
()
{
function
_HWLDF_WordAccumulator
()
{
$this
->
__construct
();
}
function
__construct
()
{
$this
->
_lines
=
array
();
$this
->
_lines
=
array
();
$this
->
_line
=
''
;
$this
->
_line
=
''
;
$this
->
_group
=
''
;
$this
->
_group
=
''
;
...
@@ -882,11 +927,18 @@ class _HWLDF_WordAccumulator {
...
@@ -882,11 +927,18 @@ class _HWLDF_WordAccumulator {
class
WordLevelDiff
extends
MappedDiff
{
class
WordLevelDiff
extends
MappedDiff
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
WordLevelDiff
(
$orig_lines
,
$closing_lines
)
{
function
WordLevelDiff
(
$orig_lines
,
$closing_lines
)
{
$this
->
__construct
(
$orig_lines
,
$closing_lines
);
}
function
__construct
(
$orig_lines
,
$closing_lines
)
{
list
(
$orig_words
,
$orig_stripped
)
=
$this
->
_split
(
$orig_lines
);
list
(
$orig_words
,
$orig_stripped
)
=
$this
->
_split
(
$orig_lines
);
list
(
$closing_words
,
$closing_stripped
)
=
$this
->
_split
(
$closing_lines
);
list
(
$closing_words
,
$closing_stripped
)
=
$this
->
_split
(
$closing_lines
);
$this
->
MappedDiff
(
$orig_words
,
$closing_words
,
$orig_stripped
,
$closing_stripped
);
parent
::
__construct
(
$orig_words
,
$closing_words
,
$orig_stripped
,
$closing_stripped
);
}
}
function
_split
(
$lines
)
{
function
_split
(
$lines
)
{
...
@@ -924,11 +976,18 @@ class WordLevelDiff extends MappedDiff {
...
@@ -924,11 +976,18 @@ class WordLevelDiff extends MappedDiff {
class
InlineWordLevelDiff
extends
MappedDiff
{
class
InlineWordLevelDiff
extends
MappedDiff
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
InlineWordLevelDiff
(
$orig_lines
,
$closing_lines
)
{
function
InlineWordLevelDiff
(
$orig_lines
,
$closing_lines
)
{
$this
->
__construct
(
$orig_lines
,
$closing_lines
);
}
function
__construct
(
$orig_lines
,
$closing_lines
)
{
list
(
$orig_words
,
$orig_stripped
)
=
$this
->
_split
(
$orig_lines
);
list
(
$orig_words
,
$orig_stripped
)
=
$this
->
_split
(
$orig_lines
);
list
(
$closing_words
,
$closing_stripped
)
=
$this
->
_split
(
$closing_lines
);
list
(
$closing_words
,
$closing_stripped
)
=
$this
->
_split
(
$closing_lines
);
$this
->
MappedDiff
(
$orig_words
,
$closing_words
,
$orig_stripped
,
$closing_stripped
);
parent
::
__construct
(
$orig_words
,
$closing_words
,
$orig_stripped
,
$closing_stripped
);
}
}
function
_split
(
$lines
)
{
function
_split
(
$lines
)
{
...
@@ -965,7 +1024,14 @@ class InlineWordLevelDiff extends MappedDiff {
...
@@ -965,7 +1024,14 @@ class InlineWordLevelDiff extends MappedDiff {
*/
*/
class
UnifiedDiffFormatter
extends
DiffFormatter
{
class
UnifiedDiffFormatter
extends
DiffFormatter
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
UnifiedDiffFormatter
(
$context_lines
=
4
)
{
function
UnifiedDiffFormatter
(
$context_lines
=
4
)
{
$this
->
__construct
(
$context_lines
);
}
function
__construct
(
$context_lines
=
4
)
{
$this
->
leading_context_lines
=
$context_lines
;
$this
->
leading_context_lines
=
$context_lines
;
$this
->
trailing_context_lines
=
$context_lines
;
$this
->
trailing_context_lines
=
$context_lines
;
}
}
...
@@ -996,7 +1062,14 @@ class UnifiedDiffFormatter extends DiffFormatter {
...
@@ -996,7 +1062,14 @@ class UnifiedDiffFormatter extends DiffFormatter {
*/
*/
class
TableDiffFormatter
extends
DiffFormatter
{
class
TableDiffFormatter
extends
DiffFormatter
{
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
TableDiffFormatter
()
{
function
TableDiffFormatter
()
{
$this
->
__construct
();
}
function
__construct
()
{
$this
->
leading_context_lines
=
2
;
$this
->
leading_context_lines
=
2
;
$this
->
trailing_context_lines
=
2
;
$this
->
trailing_context_lines
=
2
;
}
}
...
@@ -1088,8 +1161,14 @@ class TableDiffFormatter extends DiffFormatter {
...
@@ -1088,8 +1161,14 @@ class TableDiffFormatter extends DiffFormatter {
*/
*/
class
InlineDiffFormatter
extends
DiffFormatter
{
class
InlineDiffFormatter
extends
DiffFormatter
{
var
$colspan
=
4
;
var
$colspan
=
4
;
/**
* DONOT USE THIS. Its just to make sure nothing breaks because of the name change.
*/
function
InlineDiffFormatter
()
{
function
InlineDiffFormatter
()
{
$this
->
__construct
();
}
function
__construct
()
{
$this
->
leading_context_lines
=
2
;
$this
->
leading_context_lines
=
2
;
$this
->
trailing_context_lines
=
2
;
$this
->
trailing_context_lines
=
2
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment