Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgChangeset.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 | ee6b467c1a5f |
children | 9517df1ef7ec |
comparison
equal
deleted
inserted
replaced
365:3572fcb06473 | 366:189dc6dc1c3e |
---|---|
114 rv.add(pathHelper.path(name)); | 114 rv.add(pathHelper.path(name)); |
115 } | 115 } |
116 return rv; | 116 return rv; |
117 } | 117 } |
118 | 118 |
119 public List<HgFileRevision> getModifiedFiles() { | 119 public List<HgFileRevision> getModifiedFiles() throws HgInvalidControlFileException { |
120 if (modifiedFiles == null) { | 120 if (modifiedFiles == null) { |
121 initFileChanges(); | 121 initFileChanges(); |
122 } | 122 } |
123 return modifiedFiles; | 123 return modifiedFiles; |
124 } | 124 } |
125 | 125 |
126 public List<HgFileRevision> getAddedFiles() { | 126 public List<HgFileRevision> getAddedFiles() throws HgInvalidControlFileException { |
127 if (addedFiles == null) { | 127 if (addedFiles == null) { |
128 initFileChanges(); | 128 initFileChanges(); |
129 } | 129 } |
130 return addedFiles; | 130 return addedFiles; |
131 } | 131 } |
132 | 132 |
133 public List<Path> getRemovedFiles() { | 133 public List<Path> getRemovedFiles() throws HgInvalidControlFileException { |
134 if (deletedFiles == null) { | 134 if (deletedFiles == null) { |
135 initFileChanges(); | 135 initFileChanges(); |
136 } | 136 } |
137 return deletedFiles; | 137 return deletedFiles; |
138 } | 138 } |
139 | 139 |
140 public boolean isMerge() { | 140 public boolean isMerge() throws HgInvalidControlFileException { |
141 // p1 == -1 and p2 != -1 is legitimate case | 141 // p1 == -1 and p2 != -1 is legitimate case |
142 return !(getFirstParentRevision().isNull() || getSecondParentRevision().isNull()); | 142 return !(getFirstParentRevision().isNull() || getSecondParentRevision().isNull()); |
143 } | 143 } |
144 | 144 |
145 /** | 145 /** |
146 * @return never <code>null</code> | 146 * @return never <code>null</code> |
147 * @throws HgInvalidControlFileException FIXME | |
147 */ | 148 */ |
148 public Nodeid getFirstParentRevision() { | 149 public Nodeid getFirstParentRevision() throws HgInvalidControlFileException { |
149 if (parentHelper != null) { | 150 if (parentHelper != null) { |
150 return parentHelper.safeFirstParent(nodeid); | 151 return parentHelper.safeFirstParent(nodeid); |
151 } | 152 } |
152 // read once for both p1 and p2 | 153 // read once for both p1 and p2 |
153 if (parent1 == null) { | 154 if (parent1 == null) { |
158 return Nodeid.fromBinary(parent1, 0); | 159 return Nodeid.fromBinary(parent1, 0); |
159 } | 160 } |
160 | 161 |
161 /** | 162 /** |
162 * @return never <code>null</code> | 163 * @return never <code>null</code> |
164 * @throws HgInvalidControlFileException FIXME | |
163 */ | 165 */ |
164 public Nodeid getSecondParentRevision() { | 166 public Nodeid getSecondParentRevision() throws HgInvalidControlFileException { |
165 if (parentHelper != null) { | 167 if (parentHelper != null) { |
166 return parentHelper.safeSecondParent(nodeid); | 168 return parentHelper.safeSecondParent(nodeid); |
167 } | 169 } |
168 if (parent2 == null) { | 170 if (parent2 == null) { |
169 parent1 = new byte[20]; | 171 parent1 = new byte[20]; |
182 } catch (CloneNotSupportedException ex) { | 184 } catch (CloneNotSupportedException ex) { |
183 throw new InternalError(ex.toString()); | 185 throw new InternalError(ex.toString()); |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
187 private /*synchronized*/ void initFileChanges() { | 189 private /*synchronized*/ void initFileChanges() throws HgInvalidControlFileException { |
188 ArrayList<Path> deleted = new ArrayList<Path>(); | 190 ArrayList<Path> deleted = new ArrayList<Path>(); |
189 ArrayList<HgFileRevision> modified = new ArrayList<HgFileRevision>(); | 191 ArrayList<HgFileRevision> modified = new ArrayList<HgFileRevision>(); |
190 ArrayList<HgFileRevision> added = new ArrayList<HgFileRevision>(); | 192 ArrayList<HgFileRevision> added = new ArrayList<HgFileRevision>(); |
191 HgStatusCollector.Record r = new HgStatusCollector.Record(); | 193 HgStatusCollector.Record r = new HgStatusCollector.Record(); |
192 statusHelper.change(revNumber, r); | 194 statusHelper.change(revNumber, r); |