Update JGit to 0.8.4.403-ga424b7a

Change-Id: Ic94df6ecf11200965fc10ac59204f46bd5a2a631
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-09-15 10:02:38 -07:00
parent 8e4aa1f0e1
commit 7f243d5327
4 changed files with 54 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.server.patch;
import org.eclipse.jgit.diff.Sequence; import org.eclipse.jgit.diff.Sequence;
class CharText implements Sequence { class CharText extends Sequence {
private final String content; private final String content;
CharText(Text text, int s, int e) { CharText(Text text, int s, int e) {
@@ -40,11 +40,6 @@ class CharText implements Sequence {
return false; return false;
} }
@Override
public boolean equals(int a, Sequence other, int b) {
return content.charAt(a) == ((CharText) other).content.charAt(b);
}
@Override @Override
public int size() { public int size() {
return content.length(); return content.length();

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2010 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.patch;
import org.eclipse.jgit.diff.SequenceComparator;
class CharTextComparator extends SequenceComparator<CharText> {
@Override
public boolean equals(CharText a, int ai, CharText b, int bi) {
return a.charAt(ai) == b.charAt(bi);
}
@Override
public int hash(CharText seq, int ptr) {
return seq.charAt(ptr);
}
}

View File

@@ -84,9 +84,7 @@ import org.eclipse.jgit.diff.Edit;
import org.eclipse.jgit.diff.EditList; import org.eclipse.jgit.diff.EditList;
import org.eclipse.jgit.diff.MyersDiff; import org.eclipse.jgit.diff.MyersDiff;
import org.eclipse.jgit.diff.RawText; import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.diff.RawTextIgnoreAllWhitespace; import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.diff.RawTextIgnoreTrailingWhitespace;
import org.eclipse.jgit.diff.RawTextIgnoreWhitespaceChange;
import org.eclipse.jgit.diff.ReplaceEdit; import org.eclipse.jgit.diff.ReplaceEdit;
import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@@ -188,20 +186,20 @@ public class PatchListCacheImpl implements PatchListCache {
final Repository repo) throws IOException { final Repository repo) throws IOException {
// TODO(jeffschu) correctly handle merge commits // TODO(jeffschu) correctly handle merge commits
RawText.Factory rawTextFactory; RawTextComparator cmp;
switch (key.getWhitespace()) { switch (key.getWhitespace()) {
case IGNORE_ALL_SPACE: case IGNORE_ALL_SPACE:
rawTextFactory = RawTextIgnoreAllWhitespace.FACTORY; cmp = RawTextComparator.WS_IGNORE_ALL;
break; break;
case IGNORE_SPACE_AT_EOL: case IGNORE_SPACE_AT_EOL:
rawTextFactory = RawTextIgnoreTrailingWhitespace.FACTORY; cmp = RawTextComparator.WS_IGNORE_TRAILING;
break; break;
case IGNORE_SPACE_CHANGE: case IGNORE_SPACE_CHANGE:
rawTextFactory = RawTextIgnoreWhitespaceChange.FACTORY; cmp = RawTextComparator.WS_IGNORE_CHANGE;
break; break;
case IGNORE_NONE: case IGNORE_NONE:
default: default:
rawTextFactory = RawText.FACTORY; cmp = RawTextComparator.DEFAULT;
break; break;
} }
@@ -215,7 +213,7 @@ public class PatchListCacheImpl implements PatchListCache {
// This is a merge commit, compared to its ancestor. // This is a merge commit, compared to its ancestor.
// //
final PatchListEntry[] entries = new PatchListEntry[1]; final PatchListEntry[] entries = new PatchListEntry[1];
entries[0] = newCommitMessage(rawTextFactory, repo, reader, null, b); entries[0] = newCommitMessage(cmp, repo, reader, null, b);
return new PatchList(a, b, computeIntraline, true, entries); return new PatchList(a, b, computeIntraline, true, entries);
} }
@@ -245,13 +243,13 @@ public class PatchListCacheImpl implements PatchListCache {
DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
df.setRepository(repo); df.setRepository(repo);
df.setRawTextFactory(rawTextFactory); df.setDiffComparator(cmp);
df.setDetectRenames(true); df.setDetectRenames(true);
List<DiffEntry> diffEntries = df.scan(aTree, bTree); List<DiffEntry> diffEntries = df.scan(aTree, bTree);
final int cnt = diffEntries.size(); final int cnt = diffEntries.size();
final PatchListEntry[] entries = new PatchListEntry[1 + cnt]; final PatchListEntry[] entries = new PatchListEntry[1 + cnt];
entries[0] = newCommitMessage(rawTextFactory, repo, reader, // entries[0] = newCommitMessage(cmp, repo, reader, //
againstParent ? null : aCommit, b); againstParent ? null : aCommit, b);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
FileHeader fh = df.toFileHeader(diffEntries.get(i)); FileHeader fh = df.toFileHeader(diffEntries.get(i));
@@ -264,7 +262,7 @@ public class PatchListCacheImpl implements PatchListCache {
} }
private PatchListEntry newCommitMessage( private PatchListEntry newCommitMessage(
final RawText.Factory rawTextFactory, final Repository db, final RawTextComparator cmp, final Repository db,
final ObjectReader reader, final RevCommit aCommit, final ObjectReader reader, final RevCommit aCommit,
final RevCommit bCommit) throws IOException { final RevCommit bCommit) throws IOException {
StringBuilder hdr = new StringBuilder(); StringBuilder hdr = new StringBuilder();
@@ -289,9 +287,9 @@ public class PatchListCacheImpl implements PatchListCache {
Text bText = Text.forCommit(db, reader, bCommit); Text bText = Text.forCommit(db, reader, bCommit);
byte[] rawHdr = hdr.toString().getBytes("UTF-8"); byte[] rawHdr = hdr.toString().getBytes("UTF-8");
RawText aRawText = rawTextFactory.create(aText.getContent()); RawText aRawText = new RawText(cmp, aText.getContent());
RawText bRawText = rawTextFactory.create(bText.getContent()); RawText bRawText = new RawText(cmp, bText.getContent());
EditList edits = new MyersDiff(aRawText, bRawText).getEdits(); EditList edits = new MyersDiff(cmp, aRawText, bRawText).getEdits();
FileHeader fh = new FileHeader(rawHdr, edits, PatchType.UNIFIED); FileHeader fh = new FileHeader(rawHdr, edits, PatchType.UNIFIED);
return newEntry(reader, aText, bText, edits, null, null, fh); return newEntry(reader, aText, bText, edits, null, null, fh);
} }
@@ -346,8 +344,9 @@ public class PatchListCacheImpl implements PatchListCache {
CharText a = new CharText(aContent, e.getBeginA(), e.getEndA()); CharText a = new CharText(aContent, e.getBeginA(), e.getEndA());
CharText b = new CharText(bContent, e.getBeginB(), e.getEndB()); CharText b = new CharText(bContent, e.getBeginB(), e.getEndB());
CharTextComparator cmp = new CharTextComparator();
List<Edit> wordEdits = new MyersDiff(a, b).getEdits(); List<Edit> wordEdits = new MyersDiff(cmp, a, b).getEdits();
// Combine edits that are really close together. If they are // Combine edits that are really close together. If they are
// just a few characters apart we tend to get better results // just a few characters apart we tend to get better results
@@ -412,11 +411,11 @@ public class PatchListCacheImpl implements PatchListCache {
// such that the edges of each text is identical. Fix by // such that the edges of each text is identical. Fix by
// by dropping out that incorrectly replaced region. // by dropping out that incorrectly replaced region.
// //
while (ab < ae && bb < be && a.equals(ab, b, bb)) { while (ab < ae && bb < be && cmp.equals(a, ab, b, bb)) {
ab++; ab++;
bb++; bb++;
} }
while (ab < ae && bb < be && a.equals(ae - 1, b, be - 1)) { while (ab < ae && bb < be && cmp.equals(a, ae - 1, b, be - 1)) {
ae--; ae--;
be--; be--;
} }
@@ -434,7 +433,7 @@ public class PatchListCacheImpl implements PatchListCache {
int nb = lf + 1; int nb = lf + 1;
int p = 0; int p = 0;
while (p < ae - ab) { while (p < ae - ab) {
if (a.equals(ab + p, a, ab + p)) if (cmp.equals(a, ab + p, a, ab + p))
p++; p++;
else else
break; break;
@@ -448,12 +447,12 @@ public class PatchListCacheImpl implements PatchListCache {
} }
if (aShift) { if (aShift) {
while (0 < ab && ab < ae && a.charAt(ab - 1) != '\n' while (0 < ab && ab < ae && a.charAt(ab - 1) != '\n'
&& a.equals(ab - 1, a, ae - 1)) { && cmp.equals(a, ab - 1, a, ae - 1)) {
ab--; ab--;
ae--; ae--;
} }
if (!a.isLineStart(ab) || !a.contains(ab, ae, '\n')) { if (!a.isLineStart(ab) || !a.contains(ab, ae, '\n')) {
while (ab < ae && ae < a.size() && a.equals(ab, a, ae)) { while (ab < ae && ae < a.size() && cmp.equals(a, ab, a, ae)) {
ab++; ab++;
ae++; ae++;
if (a.charAt(ae - 1) == '\n') { if (a.charAt(ae - 1) == '\n') {
@@ -470,7 +469,7 @@ public class PatchListCacheImpl implements PatchListCache {
int nb = lf + 1; int nb = lf + 1;
int p = 0; int p = 0;
while (p < be - bb) { while (p < be - bb) {
if (b.equals(bb + p, b, bb + p)) if (cmp.equals(b, bb + p, b, bb + p))
p++; p++;
else else
break; break;
@@ -484,12 +483,12 @@ public class PatchListCacheImpl implements PatchListCache {
} }
if (bShift) { if (bShift) {
while (0 < bb && bb < be && b.charAt(bb - 1) != '\n' while (0 < bb && bb < be && b.charAt(bb - 1) != '\n'
&& b.equals(bb - 1, b, be - 1)) { && cmp.equals(b, bb - 1, b, be - 1)) {
bb--; bb--;
be--; be--;
} }
if (!b.isLineStart(bb) || !b.contains(bb, be, '\n')) { if (!b.isLineStart(bb) || !b.contains(bb, be, '\n')) {
while (bb < be && be < b.size() && b.equals(bb, b, be)) { while (bb < be && be < b.size() && cmp.equals(b, bb, b, be)) {
bb++; bb++;
be++; be++;
if (b.charAt(be - 1) == '\n') { if (b.charAt(be - 1) == '\n') {

View File

@@ -46,7 +46,7 @@ limitations under the License.
</issueManagement> </issueManagement>
<properties> <properties>
<jgitVersion>0.8.4.389-gba984ba</jgitVersion> <jgitVersion>0.8.4.403-ga424b7a</jgitVersion>
<gwtormVersion>1.1.4</gwtormVersion> <gwtormVersion>1.1.4</gwtormVersion>
<gwtjsonrpcVersion>1.2.2</gwtjsonrpcVersion> <gwtjsonrpcVersion>1.2.2</gwtjsonrpcVersion>
<gwtexpuiVersion>1.2.2</gwtexpuiVersion> <gwtexpuiVersion>1.2.2</gwtexpuiVersion>