comparison src/com/tmate/hgkit/ll/Revlog.java @ 49:26e3eeaa3962

branch and user filtering for log operation
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 15 Jan 2011 01:15:38 +0100
parents 4e9b66b07a28
children 9429c7bd1920 576d6e8a09f6
comparison
equal deleted inserted replaced
48:e34f90b9ded1 49:26e3eeaa3962
33 33
34 public int getRevisionCount() { 34 public int getRevisionCount() {
35 return content.revisionCount(); 35 return content.revisionCount();
36 } 36 }
37 37
38 public int getLocalRevisionNumber(Nodeid nid) {
39 int revision = content.findLocalRevisionNumber(nid);
40 if (revision == Integer.MIN_VALUE) {
41 throw new IllegalArgumentException(String.format("%s doesn't represent a revision of %s", nid.toString(), this /*XXX HgDataFile.getPath might be more suitable here*/));
42 }
43 return revision;
44 }
45
38 // Till now, i follow approach that NULL nodeid is never part of revlog 46 // Till now, i follow approach that NULL nodeid is never part of revlog
39 public boolean isKnown(Nodeid nodeid) { 47 public boolean isKnown(Nodeid nodeid) {
40 try { 48 final int rn = content.findLocalRevisionNumber(nodeid);
41 int revision = content.findLocalRevisionNumber(nodeid); 49 if (Integer.MIN_VALUE == rn) {
42 return revision >= 0 && revision < getRevisionCount();
43 } catch (IllegalArgumentException ex) {
44 // FIXME bad way to figure out if nodeid is from this revlog
45 return false; 50 return false;
46 } 51 }
52 if (rn < 0 || rn >= content.revisionCount()) {
53 // Sanity check
54 throw new IllegalStateException();
55 }
56 return true;
47 } 57 }
58
48 /** 59 /**
49 * Access to revision data as is (decompressed, but otherwise unprocessed, i.e. not parsed for e.g. changeset or manifest entries) 60 * Access to revision data as is (decompressed, but otherwise unprocessed, i.e. not parsed for e.g. changeset or manifest entries)
50 * @param nodeid 61 * @param nodeid
51 */ 62 */
52 public byte[] content(Nodeid nodeid) { 63 public byte[] content(Nodeid nodeid) {
53 int revision = content.findLocalRevisionNumber(nodeid); 64 return content(getLocalRevisionNumber(nodeid));
54 return content(revision);
55 } 65 }
56 66
57 /** 67 /**
58 * @param revision - repo-local index of this file change (not a changelog revision number!) 68 * @param revision - repo-local index of this file change (not a changelog revision number!)
59 */ 69 */
138 148
139 // null if none 149 // null if none
140 public Nodeid firstParent(Nodeid nid) { 150 public Nodeid firstParent(Nodeid nid) {
141 return firstParent.get(nid); 151 return firstParent.get(nid);
142 } 152 }
153
154 // never null, Nodeid.NULL if none known
155 public Nodeid safeFirstParent(Nodeid nid) {
156 Nodeid rv = firstParent(nid);
157 return rv == null ? Nodeid.NULL : rv;
158 }
143 159
144 public Nodeid secondParent(Nodeid nid) { 160 public Nodeid secondParent(Nodeid nid) {
145 return secondParent.get(nid); 161 return secondParent.get(nid);
162 }
163
164 public Nodeid safeSecondParent(Nodeid nid) {
165 Nodeid rv = secondParent(nid);
166 return rv == null ? Nodeid.NULL : rv;
146 } 167 }
147 168
148 public boolean appendParentsOf(Nodeid nid, Collection<Nodeid> c) { 169 public boolean appendParentsOf(Nodeid nid, Collection<Nodeid> c) {
149 Nodeid p1 = firstParent(nid); 170 Nodeid p1 = firstParent(nid);
150 boolean modified = false; 171 boolean modified = false;