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