comparison src/org/tmatesoft/hg/repo/HgBundle.java @ 274:9fb50c04f03c

Use Nodeid.isNull check instead of NULL.equals
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 25 Aug 2011 03:57:39 +0200
parents 44a34baabea0
children 981f9f50bb6c
comparison
equal deleted inserted replaced
273:8f872bd7ddd2 274:9fb50c04f03c
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.repo; 17 package org.tmatesoft.hg.repo;
18 18
19 import static org.tmatesoft.hg.core.Nodeid.NULL;
20
21 import java.io.File; 19 import java.io.File;
22 import java.io.IOException; 20 import java.io.IOException;
23 import java.util.LinkedList; 21 import java.util.LinkedList;
24 import java.util.List; 22 import java.util.List;
25 23
139 public boolean element(GroupElement ge) { 137 public boolean element(GroupElement ge) {
140 emptyChangelog = false; 138 emptyChangelog = false;
141 HgChangelog changelog = hgRepo.getChangelog(); 139 HgChangelog changelog = hgRepo.getChangelog();
142 try { 140 try {
143 if (prevRevContent == null) { 141 if (prevRevContent == null) {
144 if (NULL.equals(ge.firstParent()) && NULL.equals(ge.secondParent())) { 142 if (ge.firstParent().isNull() && ge.secondParent().isNull()) {
145 prevRevContent = new ByteArrayDataAccess(new byte[0]); 143 prevRevContent = new ByteArrayDataAccess(new byte[0]);
146 } else { 144 } else {
147 final Nodeid base = ge.firstParent(); 145 final Nodeid base = ge.firstParent();
148 if (!changelog.isKnown(base) /*only first parent, that's Bundle contract*/) { 146 if (!changelog.isKnown(base) /*only first parent, that's Bundle contract*/) {
149 throw new IllegalStateException(String.format("Revision %s needs a parent %s, which is missing in the supplied repo %s", ge.node().shortNotation(), base.shortNotation(), hgRepo.toString())); 147 throw new IllegalStateException(String.format("Revision %s needs a parent %s, which is missing in the supplied repo %s", ge.node().shortNotation(), base.shortNotation(), hgRepo.toString()));
387 assert fourNodeids != null && fourNodeids.length == 80; 385 assert fourNodeids != null && fourNodeids.length == 80;
388 header = fourNodeids; 386 header = fourNodeids;
389 dataAccess = rawDataAccess; 387 dataAccess = rawDataAccess;
390 } 388 }
391 389
390 // non-null
392 public Nodeid node() { 391 public Nodeid node() {
393 return Nodeid.fromBinary(header, 0); 392 return Nodeid.fromBinary(header, 0);
394 } 393 }
395 394
395 // non-null
396 public Nodeid firstParent() { 396 public Nodeid firstParent() {
397 return Nodeid.fromBinary(header, 20); 397 return Nodeid.fromBinary(header, 20);
398 } 398 }
399 399
400 // non-null
400 public Nodeid secondParent() { 401 public Nodeid secondParent() {
401 return Nodeid.fromBinary(header, 40); 402 return Nodeid.fromBinary(header, 40);
402 } 403 }
403 404
405 // non-null
404 public Nodeid cset() { // cs seems to be changeset 406 public Nodeid cset() { // cs seems to be changeset
405 return Nodeid.fromBinary(header, 60); 407 return Nodeid.fromBinary(header, 60);
406 } 408 }
407 409
408 public DataAccess rawData() { 410 public DataAccess rawData() {