Mercurial > jhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 86:ee4458416579 | 87:25f2e5d1cd8b |
|---|---|
| 177 } | 177 } |
| 178 | 178 |
| 179 // | 179 // |
| 180 int lastStart = breakIndex3 + 1; | 180 int lastStart = breakIndex3 + 1; |
| 181 int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); | 181 int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); |
| 182 ArrayList<String> _files = new ArrayList<String>(5); | 182 ArrayList<String> _files = null; |
| 183 while (breakIndex4 != -1 && breakIndex4 + 1 < bufferEndIndex) { | 183 if (breakIndex4 > lastStart) { |
| 184 _files.add(new String(data, lastStart, breakIndex4 - lastStart)); | 184 // if breakIndex4 == lastStart, we already found \n\n and hence there are no files (e.g. merge revision) |
| 185 lastStart = breakIndex4 + 1; | 185 _files = new ArrayList<String>(5); |
| 186 if (data[breakIndex4 + 1] == lineBreak) { | 186 while (breakIndex4 != -1 && breakIndex4 + 1 < bufferEndIndex) { |
| 187 // found \n\n | 187 _files.add(new String(data, lastStart, breakIndex4 - lastStart)); |
| 188 break; | 188 lastStart = breakIndex4 + 1; |
| 189 } else { | 189 if (data[breakIndex4 + 1] == lineBreak) { |
| 190 breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); | 190 // found \n\n |
| 191 } | 191 break; |
| 192 } | 192 } else { |
| 193 if (breakIndex4 == -1 || breakIndex4 >= bufferEndIndex) { | 193 breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); |
| 194 throw new IllegalArgumentException("Bad Changeset data"); | 194 } |
| 195 } | |
| 196 if (breakIndex4 == -1 || breakIndex4 >= bufferEndIndex) { | |
| 197 throw new IllegalArgumentException("Bad Changeset data"); | |
| 198 } | |
| 199 } else { | |
| 200 breakIndex4--; | |
| 195 } | 201 } |
| 196 String _comment; | 202 String _comment; |
| 197 try { | 203 try { |
| 198 _comment = new String(data, breakIndex4+2, bufferEndIndex - breakIndex4 - 2, "UTF-8"); | 204 _comment = new String(data, breakIndex4+2, bufferEndIndex - breakIndex4 - 2, "UTF-8"); |
| 199 } catch (UnsupportedEncodingException ex) { | 205 } catch (UnsupportedEncodingException ex) { |
| 203 // change this instance at once, don't leave it partially changes in case of error | 209 // change this instance at once, don't leave it partially changes in case of error |
| 204 this.manifest = _nodeid; | 210 this.manifest = _nodeid; |
| 205 this.user = _user; | 211 this.user = _user; |
| 206 this.time = _time; | 212 this.time = _time; |
| 207 this.timezone = _timezone; | 213 this.timezone = _timezone; |
| 208 this.files = Collections.unmodifiableList(_files); | 214 this.files = _files == null ? Collections.<String>emptyList() : Collections.unmodifiableList(_files); |
| 209 this.comment = _comment; | 215 this.comment = _comment; |
| 210 this.extras = _extrasMap; | 216 this.extras = _extrasMap; |
| 211 } | 217 } |
| 212 | 218 |
| 213 private static int indexOf(byte[] src, byte what, int startOffset, int endIndex) { | 219 private static int indexOf(byte[] src, byte what, int startOffset, int endIndex) { |
