Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 366:189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 16 Dec 2011 04:43:18 +0100 |
parents | 5f9073eabf06 |
children | 2fadf8695f8a |
comparison
equal
deleted
inserted
replaced
365:3572fcb06473 | 366:189dc6dc1c3e |
---|---|
257 csetTransform = null; | 257 csetTransform = null; |
258 progressHelper.done(); | 258 progressHelper.done(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 public void execute(HgChangesetTreeHandler handler) throws CancelledException { | 262 public void execute(HgChangesetTreeHandler handler) throws CancelledException, HgException { |
263 if (handler == null) { | 263 if (handler == null) { |
264 throw new IllegalArgumentException(); | 264 throw new IllegalArgumentException(); |
265 } | 265 } |
266 if (csetTransform != null) { | 266 if (csetTransform != null) { |
267 throw new ConcurrentModificationException(); | 267 throw new ConcurrentModificationException(); |
289 p2 = completeHistory[parent2]; | 289 p2 = completeHistory[parent2]; |
290 } | 290 } |
291 completeHistory[revisionNumber] = new HistoryNode(commitRevisions[revisionNumber], revision, p1, p2); | 291 completeHistory[revisionNumber] = new HistoryNode(commitRevisions[revisionNumber], revision, p1, p2); |
292 } | 292 } |
293 | 293 |
294 HistoryNode[] go(HgDataFile fileNode) { | 294 HistoryNode[] go(HgDataFile fileNode) throws HgInvalidControlFileException { |
295 completeHistory = new HistoryNode[fileNode.getRevisionCount()]; | 295 completeHistory = new HistoryNode[fileNode.getRevisionCount()]; |
296 commitRevisions = new int[completeHistory.length]; | 296 commitRevisions = new int[completeHistory.length]; |
297 fileNode.walk(0, TIP, this); | 297 fileNode.walk(0, TIP, this); |
298 return completeHistory; | 298 return completeHistory; |
299 } | 299 } |
356 } | 356 } |
357 count++; | 357 count++; |
358 csetTransform.next(revisionNumber, nodeid, cset); | 358 csetTransform.next(revisionNumber, nodeid, cset); |
359 } | 359 } |
360 | 360 |
361 private HgChangelog.ParentWalker getParentHelper(boolean create) { | 361 private HgChangelog.ParentWalker getParentHelper(boolean create) throws HgInvalidControlFileException { |
362 if (parentHelper == null && create) { | 362 if (parentHelper == null && create) { |
363 parentHelper = repo.getChangelog().new ParentWalker(); | 363 parentHelper = repo.getChangelog().new ParentWalker(); |
364 parentHelper.init(); | 364 parentHelper.init(); |
365 } | 365 } |
366 return parentHelper; | 366 return parentHelper; |
449 | 449 |
450 public Nodeid fileRevision() { | 450 public Nodeid fileRevision() { |
451 return historyNode.fileRevision; | 451 return historyNode.fileRevision; |
452 } | 452 } |
453 | 453 |
454 public HgChangeset changeset() { | 454 public HgChangeset changeset() throws HgException { |
455 return get(historyNode.changeset)[0]; | 455 return get(historyNode.changeset)[0]; |
456 } | 456 } |
457 | 457 |
458 public Pair<HgChangeset, HgChangeset> parents() { | 458 public Pair<HgChangeset, HgChangeset> parents() throws HgException { |
459 if (parents != null) { | 459 if (parents != null) { |
460 return parents; | 460 return parents; |
461 } | 461 } |
462 HistoryNode p; | 462 HistoryNode p; |
463 final int p1, p2; | 463 final int p1, p2; |
473 } | 473 } |
474 HgChangeset[] r = get(p1, p2); | 474 HgChangeset[] r = get(p1, p2); |
475 return parents = new Pair<HgChangeset, HgChangeset>(r[0], r[1]); | 475 return parents = new Pair<HgChangeset, HgChangeset>(r[0], r[1]); |
476 } | 476 } |
477 | 477 |
478 public Collection<HgChangeset> children() { | 478 public Collection<HgChangeset> children() throws HgException { |
479 if (children != null) { | 479 if (children != null) { |
480 return children; | 480 return children; |
481 } | 481 } |
482 if (historyNode.children == null) { | 482 if (historyNode.children == null) { |
483 children = Collections.emptyList(); | 483 children = Collections.emptyList(); |
494 | 494 |
495 void populate(HgChangeset cs) { | 495 void populate(HgChangeset cs) { |
496 cachedChangesets.put(cs.getRevision(), cs); | 496 cachedChangesets.put(cs.getRevision(), cs); |
497 } | 497 } |
498 | 498 |
499 private HgChangeset[] get(int... changelogRevisionNumber) { | 499 private HgChangeset[] get(int... changelogRevisionNumber) throws HgInvalidControlFileException { |
500 HgChangeset[] rv = new HgChangeset[changelogRevisionNumber.length]; | 500 HgChangeset[] rv = new HgChangeset[changelogRevisionNumber.length]; |
501 IntVector misses = new IntVector(changelogRevisionNumber.length, -1); | 501 IntVector misses = new IntVector(changelogRevisionNumber.length, -1); |
502 for (int i = 0; i < changelogRevisionNumber.length; i++) { | 502 for (int i = 0; i < changelogRevisionNumber.length; i++) { |
503 if (changelogRevisionNumber[i] == -1) { | 503 if (changelogRevisionNumber[i] == -1) { |
504 rv[i] = null; | 504 rv[i] = null; |
535 } | 535 } |
536 return rv; | 536 return rv; |
537 } | 537 } |
538 | 538 |
539 // init only when needed | 539 // init only when needed |
540 void initTransform() { | 540 void initTransform() throws HgInvalidControlFileException { |
541 if (transform == null) { | 541 if (transform == null) { |
542 transform = new ChangesetTransformer.Transformation(new HgStatusCollector(repo)/*XXX try to reuse from context?*/, getParentHelper(false)); | 542 transform = new ChangesetTransformer.Transformation(new HgStatusCollector(repo)/*XXX try to reuse from context?*/, getParentHelper(false)); |
543 } | 543 } |
544 } | 544 } |
545 | 545 |