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

Commitf292c97

Browse files
committed
fixes#79
open#85
1 parent7620f91 commitf292c97

File tree

7 files changed

+110
-17
lines changed

7 files changed

+110
-17
lines changed

‎java-diff-utils/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<groupId>org.apache.maven.plugins</groupId>
5656
<artifactId>maven-surefire-plugin</artifactId>
5757
<configuration>
58+
<trimStackTrace>false</trimStackTrace>
5859
<systemPropertyVariables>
5960
<java.util.logging.config.file>target/test-classes/logging.properties</java.util.logging.config.file>
6061
</systemPropertyVariables>

‎java-diff-utils/src/main/java/com/github/difflib/text/DiffRowGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ public Builder processDiffs(Function<String, String> processDiffs) {
506506
/**
507507
* Set the column width of generated lines of original and revised texts.
508508
*
509-
* @param width the width to set. Making it < 0 doesn'thave any sense. Default 80.@return
510-
* builder with configured ignoreBlankLines parameter
509+
* @param width the width to set. Making it < 0 doesn'tmake any sense. Default 80.
510+
*@returnbuilder with configof column width
511511
*/
512512
publicBuildercolumnWidth(intwidth) {
513513
if (width >=0) {

‎java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public final class UnifiedDiffFile {
2929
privateStringtoFile;
3030
privateStringtoTimestamp;
3131
privateStringindex;
32+
privateStringnewFileMode;
3233
privatePatch<String>patch =newPatch<>();
3334

3435
publicStringgetDiffCommand() {
@@ -92,4 +93,12 @@ public static UnifiedDiffFile from(String fromFile, String toFile, Patch<String>
9293
file.patch =patch;
9394
returnfile;
9495
}
96+
97+
publicvoidsetNewFileMode(StringnewFileMode) {
98+
this.newFileMode =newFileMode;
99+
}
100+
101+
publicStringgetNewFileMode() {
102+
returnnewFileMode;
103+
}
95104
}

‎java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public final class UnifiedDiffReader {
4949
privatefinalUnifiedDiffLineFROM_FILE =newUnifiedDiffLine(true,"^---\\s",this::processFromFile);
5050
privatefinalUnifiedDiffLineTO_FILE =newUnifiedDiffLine(true,"^\\+\\+\\+\\s",this::processToFile);
5151

52+
privatefinalUnifiedDiffLineNEW_FILE_MODE =newUnifiedDiffLine(true,"^new\\sfile\\smode\\s(\\d+)",this::processNewFileMode);
53+
5254
privatefinalUnifiedDiffLineCHUNK =newUnifiedDiffLine(false,UNIFIED_DIFF_CHUNK_REGEXP,this::processChunk);
5355
privatefinalUnifiedDiffLineLINE_NORMAL =newUnifiedDiffLine("^\\s",this::processNormalLine);
5456
privatefinalUnifiedDiffLineLINE_DEL =newUnifiedDiffLine("^-",this::processDelLine);
@@ -72,7 +74,8 @@ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
7274
line =READER.readLine();
7375
LOG.log(Level.FINE,"parsing line {0}",line);
7476
if (DIFF_COMMAND.validLine(line) ||INDEX.validLine(line)
75-
||FROM_FILE.validLine(line) ||TO_FILE.validLine(line)) {
77+
||FROM_FILE.validLine(line) ||TO_FILE.validLine(line)
78+
||NEW_FILE_MODE.validLine(line)) {
7679
break;
7780
}else {
7881
headerTxt +=line +"\n";
@@ -85,26 +88,28 @@ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
8588
while (line !=null) {
8689
if (!CHUNK.validLine(line)) {
8790
initFileIfNecessary();
88-
while (!CHUNK.validLine(line)) {
89-
if (processLine(line,DIFF_COMMAND,INDEX,FROM_FILE,TO_FILE) ==false) {
91+
while (line !=null &&!CHUNK.validLine(line)) {
92+
if (processLine(line,DIFF_COMMAND,INDEX,FROM_FILE,TO_FILE,NEW_FILE_MODE) ==false) {
9093
thrownewUnifiedDiffParserException("expected file start line not found");
9194
}
9295
line =READER.readLine();
9396
}
9497
}
95-
processLine(line,CHUNK);
96-
while ((line =READER.readLine()) !=null) {
97-
if (processLine(line,LINE_NORMAL,LINE_ADD,LINE_DEL) ==false) {
98-
thrownewUnifiedDiffParserException("expected data line not found");
99-
}
100-
if ((originalTxt.size() ==old_size &&revisedTxt.size() ==new_size)
101-
|| (old_size==0 &&new_size==0 &&originalTxt.size() ==this.old_ln
98+
if (line !=null) {
99+
processLine(line,CHUNK);
100+
while ((line =READER.readLine()) !=null) {
101+
if (processLine(line,LINE_NORMAL,LINE_ADD,LINE_DEL) ==false) {
102+
thrownewUnifiedDiffParserException("expected data line not found");
103+
}
104+
if ((originalTxt.size() ==old_size &&revisedTxt.size() ==new_size)
105+
|| (old_size ==0 &&new_size ==0 &&originalTxt.size() ==this.old_ln
102106
&&revisedTxt.size() ==this.new_ln)) {
103-
finalizeChunk();
104-
break;
107+
finalizeChunk();
108+
break;
109+
}
105110
}
111+
line =READER.readLine();
106112
}
107-
line =READER.readLine();
108113
if (line ==null ||line.startsWith("--")) {
109114
break;
110115
}
@@ -137,6 +142,9 @@ public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOExceptio
137142
}
138143

139144
privatebooleanprocessLine(Stringline,UnifiedDiffLine...rules)throwsUnifiedDiffParserException {
145+
if (line ==null) {
146+
returnfalse;
147+
}
140148
for (UnifiedDiffLinerule :rules) {
141149
if (rule.processLine(line)) {
142150
LOG.fine(" >>> processed rule " +rule.toString());
@@ -239,6 +247,11 @@ private void processToFile(MatchResult match, String line) {
239247
actualFile.setToTimestamp(extractTimestamp(line));
240248
}
241249

250+
privatevoidprocessNewFileMode(MatchResultmatch,Stringline) {
251+
//initFileIfNecessary();
252+
actualFile.setNewFileMode(match.group(1));
253+
}
254+
242255
privateStringextractFileName(String_line) {
243256
Matchermatcher =TIMESTAMP_REGEXP.matcher(_line);
244257
Stringline =_line;

‎java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,4 +579,23 @@ public void testProblemTooManyDiffRowsIssue65_NoInlineDiff() {
579579

580580
assertThat(diffRows).hasSize(2);
581581
}
582+
583+
@Test
584+
publicvoidtestLinefeedInStandardTagsWithLineWidthIssue81() {
585+
List<String>original =Arrays.asList(("American bobtail jaguar. American bobtail bombay but turkish angora and tomcat.\n"
586+
+"Russian blue leopard. Lion. Tabby scottish fold for russian blue, so savannah yet lynx. Tomcat singapura, cheetah.\n"
587+
+"Bengal tiger panther but singapura but bombay munchkin for cougar.").split("\n"));
588+
List<String>revised =Arrays.asList(("bobtail jaguar. American bobtail turkish angora and tomcat.\n"
589+
+"Russian blue leopard. Lion. Tabby scottish folded for russian blue, so savannah yettie? lynx. Tomcat singapura, cheetah.\n"
590+
+"Bengal tiger panther but singapura but bombay munchkin for cougar. And more.").split("\n"));
591+
592+
DiffRowGeneratorgenerator =DiffRowGenerator.create()
593+
.showInlineDiffs(true)
594+
.ignoreWhiteSpaces(true)
595+
.columnWidth(100)
596+
.build();
597+
List<DiffRow>deltas =generator.generateDiffRows(original,revised);
598+
599+
System.out.println(deltas);
600+
}
582601
}

‎java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
importjava.util.regex.Pattern;
2222
importstaticorg.assertj.core.api.Assertions.assertThat;
2323
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
24+
importstaticorg.junit.jupiter.api.Assertions.assertNull;
2425
importstaticorg.junit.jupiter.api.Assertions.assertTrue;
2526
importorg.junit.jupiter.api.Test;
2627

@@ -166,10 +167,29 @@ public void testParseIssue79() throws IOException {
166167
assertThat(diff.getFiles().size()).isEqualTo(1);
167168

168169
UnifiedDiffFilefile1 =diff.getFiles().get(0);
169-
assertThat(file1.getFromFile()).isEqualTo("Main.java");
170-
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);
170+
assertThat(file1.getFromFile()).isEqualTo("test/Issue.java");
171+
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(0);
171172

172173
assertThat(diff.getTail()).isNull();
173174
assertThat(diff.getHeader()).isNull();
174175
}
176+
177+
@Test
178+
publicvoidtestParseIssue85()throwsIOException {
179+
UnifiedDiffdiff =UnifiedDiffReader.parseUnifiedDiff(
180+
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue85.diff"));
181+
182+
assertThat(diff.getFiles().size()).isEqualTo(1);
183+
184+
assertEquals(1,diff.getFiles().size());
185+
186+
finalUnifiedDiffFilefile1 =diff.getFiles().get(0);
187+
assertEquals("diff -r 83e41b73d115 -r a4438263b228 tests/test-check-pyflakes.t",
188+
file1.getDiffCommand());
189+
assertEquals("tests/test-check-pyflakes.t",file1.getFromFile());
190+
assertEquals("tests/test-check-pyflakes.t",file1.getToFile());
191+
assertEquals(1,file1.getPatch().getDeltas().size());
192+
193+
assertNull(diff.getTail());
194+
}
175195
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# HG changeset patch
2+
# User Anton Shestakov <av6@dwimlabs.net>
3+
# Date 1591442367 -28800
4+
# Node ID a4438263b228dd3e2983d59095c6180b1411f0e8
5+
# Parent 83e41b73d115e3717943c2e5a83d36d05670384c
6+
tests: skip pyflakes for mercurial/thirdparty/
7+
8+
The current version of pyflakes (2.2.0) correctly detects one issue:
9+
10+
mercurial/thirdparty/selectors2.py:335:40 '...'.format(...) has unused arguments at position(s): 1
11+
12+
But we're not interested in fixing lint errors in third-party code, so we need
13+
to exclude at least selectors2.py. And in the discussion for this patch it was
14+
decided to just skip the entire thirdparty directory.
15+
16+
Differential Revision: https://phab.mercurial-scm.org/D8619
17+
18+
diff -r 83e41b73d115 -r a4438263b228 tests/test-check-pyflakes.t
19+
--- a/tests/test-check-pyflakes.tTue Jun 09 17:13:26 2020 -0400
20+
+++ b/tests/test-check-pyflakes.tSat Jun 06 19:19:27 2020 +0800
21+
@@ -16,9 +16,7 @@
22+
$ testrepohg locate 'set:**.py or grep("^#!.*python")' \
23+
> -X hgext/fsmonitor/pywatchman \
24+
> -X mercurial/pycompat.py -X contrib/python-zstandard \
25+
- > -X mercurial/thirdparty/cbor \
26+
- > -X mercurial/thirdparty/concurrent \
27+
- > -X mercurial/thirdparty/zope \
28+
+ > -X mercurial/thirdparty \
29+
> 2>/dev/null \
30+
> | xargs $PYTHON -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
31+
contrib/perf.py:*:* undefined name 'xrange' (glob) (?)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp