Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/RevisionSet.java @ 648:690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 25 Jun 2013 20:48:37 +0200 |
parents | |
children | e79cf9a8130b |
rev | line source |
---|---|
648
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.Collection; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.Collections; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.HashSet; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.Set; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import org.tmatesoft.hg.core.Nodeid; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 /** |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 * Unmodifiable collection of revisions with handy set operations |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 * |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 * @author Artem Tikhomirov |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 * @author TMate Software Ltd. |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 */ |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 public final class RevisionSet { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 private final Set<Nodeid> elements; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 public RevisionSet(Collection<Nodeid> revisions) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 this(revisions == null ? new HashSet<Nodeid>() : new HashSet<Nodeid>(revisions)); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 private RevisionSet(HashSet<Nodeid> revisions) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 if (revisions.isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 elements = Collections.<Nodeid>emptySet(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 } else { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 elements = revisions; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 public RevisionSet roots() { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 throw Internals.notImplemented(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 public RevisionSet heads() { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 throw Internals.notImplemented(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public RevisionSet intersect(RevisionSet other) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 if (isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 return this; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 if (other.isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 return other; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 HashSet<Nodeid> copy = new HashSet<Nodeid>(elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 copy.retainAll(other.elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 return copy.size() == elements.size() ? this : new RevisionSet(copy); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 public RevisionSet subtract(RevisionSet other) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 if (isEmpty() || other.isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 return this; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 HashSet<Nodeid> copy = new HashSet<Nodeid>(elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 copy.removeAll(other.elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 return copy.size() == elements.size() ? this : new RevisionSet(copy); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 public RevisionSet union(RevisionSet other) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 if (isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 return other; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 if (other.isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 return this; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 HashSet<Nodeid> copy = new HashSet<Nodeid>(elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 copy.addAll(other.elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 return new RevisionSet(copy); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 /** |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 * A ^ B := (A\B).union(B\A) |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 * A ^ B := A.union(B) \ A.intersect(B) |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 */ |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 public RevisionSet symmetricDifference(RevisionSet other) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 if (isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 return this; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 if (other.isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 return other; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 HashSet<Nodeid> copyA = new HashSet<Nodeid>(elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
101 HashSet<Nodeid> copyB = new HashSet<Nodeid>(other.elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 copyA.removeAll(other.elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 copyB.removeAll(elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 copyA.addAll(copyB); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 return new RevisionSet(copyA); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 public boolean isEmpty() { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 return elements.isEmpty(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 @Override |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 public String toString() { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 StringBuilder sb = new StringBuilder(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 sb.append('<'); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 if (!isEmpty()) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
117 sb.append(elements.size()); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
118 sb.append(':'); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 for (Nodeid n : elements) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 sb.append(n.shortNotation()); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 sb.append(','); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 if (sb.length() > 1) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 sb.setCharAt(sb.length() - 1, '>'); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 } else { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 sb.append('>'); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 return sb.toString(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 @Override |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 public boolean equals(Object obj) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 if (false == obj instanceof RevisionSet) { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 return false; |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 return elements.equals(((RevisionSet) obj).elements); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 @Override |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 public int hashCode() { |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 return elements.hashCode(); |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 } |
690e71d29bf6
Introduced RevisionSet to ease update of phase roots on push
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
144 } |