Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/Changeset.java @ 87:25f2e5d1cd8b
Fix IAE when changeset has no files listed (merged revision)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 26 Jan 2011 01:07:26 +0100 |
parents | 6f1b88693d48 |
children | a3a2e5deb320 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/Changeset.java Wed Jan 26 01:06:37 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/Changeset.java Wed Jan 26 01:07:26 2011 +0100 @@ -179,19 +179,25 @@ // int lastStart = breakIndex3 + 1; int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); - ArrayList<String> _files = new ArrayList<String>(5); - while (breakIndex4 != -1 && breakIndex4 + 1 < bufferEndIndex) { - _files.add(new String(data, lastStart, breakIndex4 - lastStart)); - lastStart = breakIndex4 + 1; - if (data[breakIndex4 + 1] == lineBreak) { - // found \n\n - break; - } else { - breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); + ArrayList<String> _files = null; + if (breakIndex4 > lastStart) { + // if breakIndex4 == lastStart, we already found \n\n and hence there are no files (e.g. merge revision) + _files = new ArrayList<String>(5); + while (breakIndex4 != -1 && breakIndex4 + 1 < bufferEndIndex) { + _files.add(new String(data, lastStart, breakIndex4 - lastStart)); + lastStart = breakIndex4 + 1; + if (data[breakIndex4 + 1] == lineBreak) { + // found \n\n + break; + } else { + breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); + } } - } - if (breakIndex4 == -1 || breakIndex4 >= bufferEndIndex) { - throw new IllegalArgumentException("Bad Changeset data"); + if (breakIndex4 == -1 || breakIndex4 >= bufferEndIndex) { + throw new IllegalArgumentException("Bad Changeset data"); + } + } else { + breakIndex4--; } String _comment; try { @@ -205,7 +211,7 @@ this.user = _user; this.time = _time; this.timezone = _timezone; - this.files = Collections.unmodifiableList(_files); + this.files = _files == null ? Collections.<String>emptyList() : Collections.unmodifiableList(_files); this.comment = _comment; this.extras = _extrasMap; }