Merge "Distinguish between error and timeout in intraline diff error message"

This commit is contained in:
Shawn Pearce
2013-04-22 17:48:34 +00:00
committed by Gerrit Code Review
6 changed files with 26 additions and 5 deletions

View File

@@ -648,8 +648,11 @@ cache.diff_intraline.timeout::
Maximum number of milliseconds to wait for intraline difference data Maximum number of milliseconds to wait for intraline difference data
before giving up and disabling it for a particular file pair. This is before giving up and disabling it for a particular file pair. This is
a work around for an infinite loop bug in the intraline difference a work around for an infinite loop bug in the intraline difference
implementation. If computation takes longer than the timeout the implementation.
worker thread is terminated and no intraline difference is displayed. +
If computation takes longer than the timeout, the worker thread is
terminated, an error message is shown, and no intraline difference is
displayed for the file pair.
+ +
Values should use common unit suffixes to express their setting: Values should use common unit suffixes to express their setting:
+ +

View File

@@ -53,6 +53,7 @@ public class PatchScript {
protected boolean hugeFile; protected boolean hugeFile;
protected boolean intralineDifference; protected boolean intralineDifference;
protected boolean intralineFailure; protected boolean intralineFailure;
protected boolean intralineTimeout;
public PatchScript(final Change.Key ck, final ChangeType ct, final String on, public PatchScript(final Change.Key ck, final ChangeType ct, final String on,
final String nn, final FileMode om, final FileMode nm, final String nn, final FileMode om, final FileMode nm,
@@ -60,7 +61,7 @@ public class PatchScript {
final SparseFileContent ca, final SparseFileContent cb, final SparseFileContent ca, final SparseFileContent cb,
final List<Edit> e, final DisplayMethod ma, final DisplayMethod mb, final List<Edit> e, final DisplayMethod ma, final DisplayMethod mb,
final CommentDetail cd, final List<Patch> hist, final boolean hf, final CommentDetail cd, final List<Patch> hist, final boolean hf,
final boolean id, final boolean idf) { final boolean id, final boolean idf, final boolean idt) {
changeId = ck; changeId = ck;
changeType = ct; changeType = ct;
oldName = on; oldName = on;
@@ -79,6 +80,7 @@ public class PatchScript {
hugeFile = hf; hugeFile = hf;
intralineDifference = id; intralineDifference = id;
intralineFailure = idf; intralineFailure = idf;
intralineTimeout = idt;
} }
protected PatchScript() { protected PatchScript() {
@@ -152,6 +154,10 @@ public class PatchScript {
return intralineFailure; return intralineFailure;
} }
public boolean hasIntralineTimeout() {
return intralineTimeout;
}
public boolean isExpandAllComments() { public boolean isExpandAllComments() {
return diffPrefs.isExpandAllComments(); return diffPrefs.isExpandAllComments();
} }

View File

@@ -36,6 +36,7 @@ public interface PatchConstants extends Constants {
String patchHistoryTitle(); String patchHistoryTitle();
String disabledOnLargeFiles(); String disabledOnLargeFiles();
String intralineFailure(); String intralineFailure();
String intralineTimeout();
String illegalNumberOfColumns(); String illegalNumberOfColumns();
String upToChange(); String upToChange();

View File

@@ -18,6 +18,7 @@ patchHistoryTitle = Patch History
patchSet = Patch Set patchSet = Patch Set
disabledOnLargeFiles = Disabled on very large source files. disabledOnLargeFiles = Disabled on very large source files.
intralineFailure = Intraline difference not available due to server error. intralineFailure = Intraline difference not available due to server error.
intralineTimeout = Intraline difference not available due to timeout.
illegalNumberOfColumns = The number of columns cannot be zero or negative illegalNumberOfColumns = The number of columns cannot be zero or negative
upToChange = Up to change upToChange = Up to change

View File

@@ -125,6 +125,7 @@ public abstract class PatchScreen extends Screen implements
private HandlerRegistration regNavigation; private HandlerRegistration regNavigation;
private HandlerRegistration regAction; private HandlerRegistration regAction;
private boolean intralineFailure; private boolean intralineFailure;
private boolean intralineTimeout;
/** /**
* How this patch should be displayed in the patch screen. * How this patch should be displayed in the patch screen.
@@ -493,6 +494,7 @@ public abstract class PatchScreen extends Screen implements
} }
intralineFailure = isFirst && script.hasIntralineFailure(); intralineFailure = isFirst && script.hasIntralineFailure();
intralineTimeout = isFirst && script.hasIntralineTimeout();
} }
@Override @Override
@@ -501,6 +503,9 @@ public abstract class PatchScreen extends Screen implements
if (intralineFailure) { if (intralineFailure) {
intralineFailure = false; intralineFailure = false;
new ErrorDialog(PatchUtil.C.intralineFailure()).show(); new ErrorDialog(PatchUtil.C.intralineFailure()).show();
} else if (intralineTimeout) {
intralineTimeout = false;
new ErrorDialog(PatchUtil.C.intralineTimeout()).show();
} }
if (topView != null && prefs.get().isRetainHeader()) { if (topView != null && prefs.get().isRetainHeader()) {
setTopView(topView); setTopView(topView);

View File

@@ -133,6 +133,7 @@ class PatchScriptBuilder {
throws IOException { throws IOException {
boolean intralineDifferenceIsPossible = true; boolean intralineDifferenceIsPossible = true;
boolean intralineFailure = false; boolean intralineFailure = false;
boolean intralineTimeout = false;
a.path = oldName(content); a.path = oldName(content);
b.path = newName(content); b.path = newName(content);
@@ -160,10 +161,14 @@ class PatchScriptBuilder {
break; break;
case ERROR: case ERROR:
case TIMEOUT:
intralineDifferenceIsPossible = false; intralineDifferenceIsPossible = false;
intralineFailure = true; intralineFailure = true;
break; break;
case TIMEOUT:
intralineDifferenceIsPossible = false;
intralineTimeout = true;
break;
} }
} else { } else {
intralineDifferenceIsPossible = false; intralineDifferenceIsPossible = false;
@@ -212,7 +217,7 @@ class PatchScriptBuilder {
content.getOldName(), content.getNewName(), a.fileMode, b.fileMode, content.getOldName(), content.getNewName(), a.fileMode, b.fileMode,
content.getHeaderLines(), diffPrefs, a.dst, b.dst, edits, content.getHeaderLines(), diffPrefs, a.dst, b.dst, edits,
a.displayMethod, b.displayMethod, comments, history, hugeFile, a.displayMethod, b.displayMethod, comments, history, hugeFile,
intralineDifferenceIsPossible, intralineFailure); intralineDifferenceIsPossible, intralineFailure, intralineTimeout);
} }
private static boolean isModify(PatchListEntry content) { private static boolean isModify(PatchListEntry content) {