comparison src/org/tmatesoft/hg/internal/RevisionSet.java @ 650:3b275cc2d2aa

Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 28 Jun 2013 19:27:26 +0200
parents e79cf9a8130b
children 6e98d34eaca8
comparison
equal deleted inserted replaced
649:e79cf9a8130b 650:3b275cc2d2aa
90 } 90 }
91 return copy.size() == elements.size() ? this : new RevisionSet(copy); 91 return copy.size() == elements.size() ? this : new RevisionSet(copy);
92 } 92 }
93 93
94 /** 94 /**
95 * Immediate parents of the supplied children set found in this one. 95 * Any ancestor of an element from the supplied children set found in this one.
96 */ 96 */
97 public RevisionSet parentsOf(RevisionSet children, HgParentChildMap<HgChangelog> parentHelper) { 97 public RevisionSet ancestors(RevisionSet children, HgParentChildMap<HgChangelog> parentHelper) {
98 if (isEmpty()) { 98 if (isEmpty()) {
99 return this; 99 return this;
100 } 100 }
101 if (children.isEmpty()) { 101 if (children.isEmpty()) {
102 return children; 102 return children;
103 } 103 }
104 RevisionSet chRoots = children.roots(parentHelper); 104 RevisionSet chRoots = children.roots(parentHelper);
105 HashSet<Nodeid> parents = new HashSet<Nodeid>(); 105 HashSet<Nodeid> ancestors = new HashSet<Nodeid>();
106 for (Nodeid n : chRoots.elements) { 106 Set<Nodeid> childrenToCheck = chRoots.elements;
107 Nodeid p1 = parentHelper.firstParent(n); 107 while (!childrenToCheck.isEmpty()) {
108 Nodeid p2 = parentHelper.secondParent(n); 108 HashSet<Nodeid> nextRound = new HashSet<Nodeid>();
109 if (p1 != null && elements.contains(p1)) { 109 for (Nodeid n : childrenToCheck) {
110 parents.add(p1); 110 Nodeid p1 = parentHelper.firstParent(n);
111 } 111 Nodeid p2 = parentHelper.secondParent(n);
112 if (p2 != null && elements.contains(p2)) { 112 if (p1 != null && elements.contains(p1)) {
113 parents.add(p2); 113 nextRound.add(p1);
114 } 114 }
115 } 115 if (p2 != null && elements.contains(p2)) {
116 return new RevisionSet(parents); 116 nextRound.add(p2);
117 }
118 }
119 ancestors.addAll(nextRound);
120 childrenToCheck = nextRound;
121 }
122 return new RevisionSet(ancestors);
123 }
124
125 /**
126 * Revisions that are both direct and indirect children of elements of this revision set
127 * as known in supplied parent-child map
128 */
129 public RevisionSet children(HgParentChildMap<HgChangelog> parentHelper) {
130 if (isEmpty()) {
131 return this;
132 }
133 List<Nodeid> children = parentHelper.childrenOf(elements);
134 return new RevisionSet(new HashSet<Nodeid>(children));
117 } 135 }
118 136
119 public RevisionSet intersect(RevisionSet other) { 137 public RevisionSet intersect(RevisionSet other) {
120 if (isEmpty()) { 138 if (isEmpty()) {
121 return this; 139 return this;