Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 511:122e0600799f
Respect multiple joins/forks in a history of a single file
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 14 Dec 2012 15:39:49 +0100 |
parents | 90093ee56c0d |
children | 5dcb4581c8ef |
comparison
equal
deleted
inserted
replaced
510:90093ee56c0d | 511:122e0600799f |
---|---|
22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
23 import java.util.Arrays; | 23 import java.util.Arrays; |
24 import java.util.Calendar; | 24 import java.util.Calendar; |
25 import java.util.Collection; | 25 import java.util.Collection; |
26 import java.util.Collections; | 26 import java.util.Collections; |
27 import java.util.Comparator; | |
27 import java.util.ConcurrentModificationException; | 28 import java.util.ConcurrentModificationException; |
28 import java.util.Iterator; | 29 import java.util.Iterator; |
29 import java.util.LinkedList; | 30 import java.util.LinkedList; |
30 import java.util.List; | 31 import java.util.List; |
31 import java.util.ListIterator; | 32 import java.util.ListIterator; |
539 LinkedList<HistoryNode> queue = new LinkedList<HistoryNode>(); | 540 LinkedList<HistoryNode> queue = new LinkedList<HistoryNode>(); |
540 // look for ancestors of the selected history node | 541 // look for ancestors of the selected history node |
541 queue.add(completeHistory[lastRevisionIndex]); | 542 queue.add(completeHistory[lastRevisionIndex]); |
542 do { | 543 do { |
543 HistoryNode withFileChange = queue.removeFirst(); | 544 HistoryNode withFileChange = queue.removeFirst(); |
545 if (strippedHistoryList.contains(withFileChange)) { | |
546 // fork point for the change that was later merged (and we traced | |
547 // both lines of development by now. | |
548 continue; | |
549 } | |
544 if (withFileChange.children != null) { | 550 if (withFileChange.children != null) { |
545 withFileChange.children.retainAll(strippedHistoryList); | 551 withFileChange.children.retainAll(strippedHistoryList); |
546 } | 552 } |
547 strippedHistoryList.addFirst(withFileChange); | 553 strippedHistoryList.addFirst(withFileChange); |
548 if (withFileChange.parent1 != null) { | 554 if (withFileChange.parent1 != null) { |
550 } | 556 } |
551 if (withFileChange.parent2 != null) { | 557 if (withFileChange.parent2 != null) { |
552 queue.addLast(withFileChange.parent2); | 558 queue.addLast(withFileChange.parent2); |
553 } | 559 } |
554 } while (!queue.isEmpty()); | 560 } while (!queue.isEmpty()); |
561 Collections.sort(strippedHistoryList, new Comparator<HistoryNode>() { | |
562 | |
563 public int compare(HistoryNode o1, HistoryNode o2) { | |
564 return o1.changeset - o2.changeset; | |
565 } | |
566 }); | |
555 completeHistory = null; | 567 completeHistory = null; |
556 commitRevisions = null; | 568 commitRevisions = null; |
557 // collected values are no longer valid - shall | 569 // collected values are no longer valid - shall |
558 // strip off elements for missing HistoryNodes, but it's easier just to re-create the array | 570 // strip off elements for missing HistoryNodes, but it's easier just to re-create the array |
559 // from resultHistory later, once (and if) needed | 571 // from resultHistory later, once (and if) needed |
663 // for the last element in history empty children are by construction: | 675 // for the last element in history empty children are by construction: |
664 // we don't iterate further than last element of interest in TreeBuildInspector#go | 676 // we don't iterate further than last element of interest in TreeBuildInspector#go |
665 assert children == null || children.isEmpty(); | 677 assert children == null || children.isEmpty(); |
666 child.parent1 = this; | 678 child.parent1 = this; |
667 addChild(child); | 679 addChild(child); |
680 } | |
681 | |
682 public String toString() { | |
683 return String.format("<cset:%d, parents: %s, %s>", changeset, parent1 == null ? "-" : String.valueOf(parent1.changeset), parent2 == null ? "-" : String.valueOf(parent2.changeset)); | |
668 } | 684 } |
669 } | 685 } |
670 | 686 |
671 private class ElementImpl implements HgChangesetTreeHandler.TreeElement, HgChangelog.Inspector { | 687 private class ElementImpl implements HgChangesetTreeHandler.TreeElement, HgChangelog.Inspector { |
672 private HistoryNode historyNode; | 688 private HistoryNode historyNode; |