258 if not ret: |
258 if not ret: |
259 self.p.loadindex(i) |
259 self.p.loadindex(i) |
260 ret = self.p.index[i] |
260 ret = self.p.index[i] |
261 if isinstance(ret, str): |
261 if isinstance(ret, str): |
262 ret = struct.unpack(indexformatng, ret) |
262 ret = struct.unpack(indexformatng, ret) |
263 yield ret[-1] |
263 yield ret[7] |
264 def __getitem__(self, key): |
264 def __getitem__(self, key): |
265 try: |
265 try: |
266 return self.p.map[key] |
266 return self.p.map[key] |
267 except KeyError: |
267 except KeyError: |
268 try: |
268 try: |
473 def _inline(self): return self.version & REVLOGNGINLINEDATA |
473 def _inline(self): return self.version & REVLOGNGINLINEDATA |
474 |
474 |
475 def tip(self): return self.node(len(self.index) - 1) |
475 def tip(self): return self.node(len(self.index) - 1) |
476 def count(self): return len(self.index) |
476 def count(self): return len(self.index) |
477 def node(self, rev): |
477 def node(self, rev): |
478 return rev == nullrev and nullid or self.index[rev][-1] |
478 return rev == nullrev and nullid or self.index[rev][7] |
479 def rev(self, node): |
479 def rev(self, node): |
480 try: |
480 try: |
481 return self.nodemap[node] |
481 return self.nodemap[node] |
482 except KeyError: |
482 except KeyError: |
483 raise LookupError(_('%s: no node %s') % (self.indexfile, hex(node))) |
483 raise LookupError(_('%s: no node %s') % (self.indexfile, hex(node))) |
484 def linkrev(self, node): |
484 def linkrev(self, node): |
485 return (node == nullid) and nullrev or self.index[self.rev(node)][-4] |
485 return (node == nullid) and nullrev or self.index[self.rev(node)][4] |
486 def parents(self, node): |
486 def parents(self, node): |
487 if node == nullid: return (nullid, nullid) |
487 if node == nullid: return (nullid, nullid) |
488 r = self.rev(node) |
488 r = self.rev(node) |
489 d = self.index[r][-3:-1] |
489 d = self.index[r][5:7] |
490 return (self.node(d[0]), self.node(d[1])) |
490 return (self.node(d[0]), self.node(d[1])) |
491 def parentrevs(self, rev): |
491 def parentrevs(self, rev): |
492 if rev == nullrev: |
492 if rev == nullrev: |
493 return (nullrev, nullrev) |
493 return (nullrev, nullrev) |
494 d = self.index[rev][-3:-1] |
494 d = self.index[rev][5:7] |
495 return d |
495 return d |
496 def start(self, rev): |
496 def start(self, rev): |
497 if rev == nullrev: |
497 if rev == nullrev: |
498 return 0 |
498 return 0 |
499 return getoffset(self.index[rev][0]) |
499 return getoffset(self.index[rev][0]) |
538 return self.index[rev][1] |
538 return self.index[rev][1] |
539 def base(self, rev): |
539 def base(self, rev): |
540 if (rev == nullrev): |
540 if (rev == nullrev): |
541 return nullrev |
541 return nullrev |
542 else: |
542 else: |
543 return self.index[rev][-5] |
543 return self.index[rev][3] |
544 |
544 |
545 def reachable(self, node, stop=None): |
545 def reachable(self, node, stop=None): |
546 """return a hash of all nodes ancestral to a given node, including |
546 """return a hash of all nodes ancestral to a given node, including |
547 the node itself, stopping when stop is matched""" |
547 the node itself, stopping when stop is matched""" |
548 reachable = {} |
548 reachable = {} |
1227 |
1227 |
1228 # When stripping away a revision, we need to make sure it |
1228 # When stripping away a revision, we need to make sure it |
1229 # does not actually belong to an older changeset. |
1229 # does not actually belong to an older changeset. |
1230 # The minlink parameter defines the oldest revision |
1230 # The minlink parameter defines the oldest revision |
1231 # we're allowed to strip away. |
1231 # we're allowed to strip away. |
1232 while minlink > self.index[rev][-4]: |
1232 while minlink > self.index[rev][4]: |
1233 rev += 1 |
1233 rev += 1 |
1234 if rev >= self.count(): |
1234 if rev >= self.count(): |
1235 return |
1235 return |
1236 |
1236 |
1237 # first truncate the files on disk |
1237 # first truncate the files on disk |