# HG changeset patch # User Artem Tikhomirov # Date 1344519918 -7200 # Node ID cdd53e5884aea44561cebd3ce1fc23b9f4e642a1 # Parent ae4d6604debd1510f876e1401fb1e16fd2dd3a38 Do not add anything to exception message in case no details are known diff -r ae4d6604debd -r cdd53e5884ae src/org/tmatesoft/hg/internal/ExceptionInfo.java --- a/src/org/tmatesoft/hg/internal/ExceptionInfo.java Wed Aug 08 14:41:44 2012 +0200 +++ b/src/org/tmatesoft/hg/internal/ExceptionInfo.java Thu Aug 09 15:45:18 2012 +0200 @@ -121,35 +121,35 @@ sb.append(';'); sb.append(' '); } - sb.append("rev:"); - boolean needNodeid = true; - if (isRevisionIndexSet()) { - if (rangeLeftBoundary != BAD_REVISION || rangeRightBoundary != BAD_REVISION) { - String sr; - switch (getRevisionIndex()) { - case BAD_REVISION: - sr = "UNKNOWN"; break; - case TIP: - sr = "TIP"; break; - case WORKING_COPY: - sr = "WORKING-COPY"; break; - case NO_REVISION: - sr = "NO REVISION"; break; - default: - sr = String.valueOf(getRevisionIndex()); - } - sb.append(String.format("%s is not from [%d..%d]", sr, rangeLeftBoundary, rangeRightBoundary)); - } else { - sb.append(getRevisionIndex()); - if (isRevisionSet()) { - sb.append(':'); - sb.append(getRevision().shortNotation()); - needNodeid = false; + if (isRevisionIndexSet() || isRevisionSet()) { + if (isRevisionIndexSet()) { + if (rangeLeftBoundary != BAD_REVISION || rangeRightBoundary != BAD_REVISION) { + String sr; + switch (getRevisionIndex()) { + case BAD_REVISION: + sr = "UNKNOWN"; break; + case TIP: + sr = "TIP"; break; + case WORKING_COPY: + sr = "WORKING-COPY"; break; + case NO_REVISION: + sr = "NO REVISION"; break; + default: + sr = String.valueOf(getRevisionIndex()); + } + sb.append(String.format("%s is not from [%d..%d]", sr, rangeLeftBoundary, rangeRightBoundary)); + } else { + sb.append("rev:"); + sb.append(getRevisionIndex()); + if (isRevisionSet()) { + sb.append(':'); + // fall-through to get revision appended + } } } - } - if (isRevisionSet() && needNodeid) { - sb.append(getRevision().shortNotation()); + if (isRevisionSet()) { + sb.append(getRevision().shortNotation()); + } } if (localFile != null) { sb.append(';'); diff -r ae4d6604debd -r cdd53e5884ae src/org/tmatesoft/hg/repo/HgRuntimeException.java --- a/src/org/tmatesoft/hg/repo/HgRuntimeException.java Wed Aug 08 14:41:44 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgRuntimeException.java Thu Aug 09 15:45:18 2012 +0200 @@ -90,11 +90,12 @@ @Override public String toString() { - StringBuilder sb = new StringBuilder(super.toString()); - sb.append(' '); - sb.append('('); + String base = super.toString(); + StringBuilder sb = new StringBuilder(); details.appendDetails(sb); - sb.append(')'); - return sb.toString(); + if (sb.length() == 0) { + return base; + } + return new StringBuilder(base).append(' ').append('(').append(sb).append(')').toString(); } }