##// END OF EJS Templates
revlog.py: factorization and fixes for rev < 0 (nullid)
Benoit Boissinot -
r1941:75188237 default
parent child Browse files
Show More
@@ -254,10 +254,14 b' class revlog(object):'
254 254 if node == nullid: return (nullid, nullid)
255 255 return self.index[self.rev(node)][4:6]
256 256
257 def start(self, rev): return self.index[rev][0]
258 def length(self, rev): return self.index[rev][1]
257 def start(self, rev): return (rev < 0) and -1 or self.index[rev][0]
258 def length(self, rev):
259 if rev < 0:
260 return 0
261 else:
262 return self.index[rev][1]
259 263 def end(self, rev): return self.start(rev) + self.length(rev)
260 def base(self, rev): return self.index[rev][2]
264 def base(self, rev): return (rev < 0) and rev or self.index[rev][2]
261 265
262 266 def reachable(self, rev, stop=None):
263 267 reachable = {}
@@ -528,12 +532,17 b' class revlog(object):'
528 532 def delta(self, node):
529 533 """return or calculate a delta between a node and its predecessor"""
530 534 r = self.rev(node)
531 b = self.base(r)
532 if r == b:
533 return self.diff(self.revision(self.node(r - 1)),
534 self.revision(node))
535 return self.revdiff(r - 1, r)
536
537 def revdiff(self, rev1, rev2):
538 """return or calculate a delta between two revisions"""
539 b1 = self.base(rev1)
540 b2 = self.base(rev2)
541 if b1 == b2 and rev1 + 1 == rev2:
542 return self.chunk(rev2)
535 543 else:
536 return self.chunk(r)
544 return self.diff(self.revision(self.node(rev1)),
545 self.revision(self.node(rev2)))
537 546
538 547 def revision(self, node):
539 548 """return an uncompressed revision of a given"""
@@ -556,7 +565,7 b' class revlog(object):'
556 565 for r in xrange(base + 1, rev + 1):
557 566 bins.append(self.chunk(r))
558 567
559 text = mdiff.patches(text, bins)
568 text = self.patches(text, bins)
560 569
561 570 p1, p2 = self.parents(node)
562 571 if node != hash(text, p1, p2):
@@ -709,20 +718,12 b' class revlog(object):'
709 718 # build deltas
710 719 for d in xrange(0, len(revs) - 1):
711 720 a, b = revs[d], revs[d + 1]
712 na = self.node(a)
713 721 nb = self.node(b)
714 722
715 723 if infocollect is not None:
716 724 infocollect(nb)
717 725
718 # do we need to construct a new delta?
719 if a + 1 != b or self.base(b) == b:
720 ta = self.revision(na)
721 tb = self.revision(nb)
722 d = self.diff(ta, tb)
723 else:
724 d = self.chunk(b)
725
726 d = self.revdiff(a, b)
726 727 p = self.parents(nb)
727 728 meta = nb + p[0] + p[1] + lookup(nb)
728 729 l = struct.pack(">l", len(meta) + len(d) + 4)
General Comments 0
You need to be logged in to leave comments. Login now