Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce05cbf

Browse files
committed
1 parentf71275d commitce05cbf

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*-
2+
* #%L
3+
* java-diff-utils
4+
* %%
5+
* Copyright (C) 2009 - 2017 java-diff-utils
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
* #L%
19+
*/
20+
packagecom.github.difflib.patch;
21+
22+
importjava.util.List;
23+
24+
/**
25+
*
26+
* @author tw
27+
*/
28+
@FunctionalInterface
29+
publicinterfaceConflictOutput<T> {
30+
31+
publicvoidprocessConflict(VerifyChunkverifyChunk,AbstractDelta<T>delta,List<T>result)throwsPatchFailedException;
32+
}

‎java-diff-utils/src/main/java/com/github/difflib/patch/Patch.java‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
importjava.util.ListIterator;
3030

3131
/**
32-
* Describes the patch holding all deltas between the original and revised texts.
33-
*
32+
* Describes the patch holding all deltas between the original and revised
33+
* texts.
34+
*
3435
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
3536
* @param <T> The type of the compared elements in the 'lines'.
3637
*/
@@ -57,10 +58,25 @@ public List<T> applyTo(List<T> target) throws PatchFailedException {
5758
ListIterator<AbstractDelta<T>>it =getDeltas().listIterator(deltas.size());
5859
while (it.hasPrevious()) {
5960
AbstractDelta<T>delta =it.previous();
60-
delta.verifyAntApplyTo(result);
61+
VerifyChunkvalid =delta.verifyAntApplyTo(result);
62+
if (valid !=VerifyChunk.OK) {
63+
64+
}
6165
}
6266
returnresult;
6367
}
68+
69+
privateConflictOutput<T>conflictOutput = (VerifyChunkverifyChunk,AbstractDelta<T>delta,List<T>result) -> {
70+
thrownewPatchFailedException("could not apply patch due to " +verifyChunk.toString());
71+
};
72+
73+
/**
74+
* Alter normal conflict output behaviour to e.g. inclide some conflict statements in the result, like git does it.
75+
*/
76+
publicPatchwithConflictOutput(ConflictOutput<T>conflictOutput) {
77+
this.conflictOutput =conflictOutput;
78+
returnthis;
79+
}
6480

6581
/**
6682
* Restore the text to original. Opposite to applyTo() method.
@@ -114,14 +130,14 @@ public static <T> Patch<T> generate(List<T> original, List<T> revised, List<Chan
114130
Patch<T>patch =newPatch<>(_changes.size());
115131
intstartOriginal =0;
116132
intstartRevised =0;
117-
133+
118134
List<Change>changes =_changes;
119-
135+
120136
if (includeEquals) {
121137
changes =newArrayList<Change>(_changes);
122138
Collections.sort(changes,comparing(d ->d.startOriginal));
123139
}
124-
140+
125141
for (Changechange :changes) {
126142

127143
if (includeEquals &&startOriginal <change.startOriginal) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp