Class MergeBlocks
java.lang.Object
fr.paris.lutece.plugins.wiki.service.merge.MergeBlocks
Runs a JGit line-based three-way merge between a base, an "ours" and a "theirs" content
and reshapes the resulting chunks into a flat list of MergeBlock objects suitable for
UI rendering. The intent is to keep the JGit dependency local to this class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<MergeBlock>Computes the merge blocks for a three-way merge.static booleancontainsConflictMarker(String content) Detects whether a content string still carries a leftover conflict marker (i.e.static Stringflatten(List<MergeBlock> blocks) Flattens a list of merge blocks into the merged content, joining CONTEXT lines and keeping only the "ours" side of CONFLICT blocks.static booleanhasConflict(List<MergeBlock> blocks) Checks whether the computed merge contains at least one CONFLICT block.static int[]Computes line-level additions and deletions between two contents, mirroring the way agit diffwould count+and-lines.
-
Method Details
-
stats
Computes line-level additions and deletions between two contents, mirroring the way agit diffwould count+and-lines.- Parameters:
base- the content before the change (may be null)head- the content after the change (may be null)- Returns:
- a two-element array:
[additions, deletions]
-
containsConflictMarker
Detects whether a content string still carries a leftover conflict marker (i.e. the "<<<<<<<" opening line emitted by the underlying three-way merge). Used to refuse a reviewer's resolution that wasn't fully cleaned up.- Parameters:
content- the content to inspect (may be null)- Returns:
- true when at least one conflict marker is still present
-
compute
Computes the merge blocks for a three-way merge.- Parameters:
base- the common ancestor contentours- the current revision contenttheirs- the proposed content- Returns:
- the ordered list of CONTEXT and CONFLICT blocks
-
hasConflict
Checks whether the computed merge contains at least one CONFLICT block.- Parameters:
blocks- the parsed merge blocks- Returns:
- true when a conflict was detected
-
flatten
Flattens a list of merge blocks into the merged content, joining CONTEXT lines and keeping only the "ours" side of CONFLICT blocks. Used when no conflict is present to produce the auto-merged content.- Parameters:
blocks- the parsed merge blocks- Returns:
- the flattened content
-