Mercurial > hg
comparison mercurial/revlog.py @ 1749:d457fec76ab0
fix warnings from pychecker (unused variables and shadowing)
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 19 Feb 2006 19:43:03 +0100 |
parents | 8959700c2b19 |
children | 2e0a288ca93e |
comparison
equal
deleted
inserted
replaced
1748:2428e6d66f06 | 1749:d457fec76ab0 |
---|---|
622 # traverse ancestors in order of decreasing distance from root | 622 # traverse ancestors in order of decreasing distance from root |
623 def ancestors(node): | 623 def ancestors(node): |
624 # we store negative distances because heap returns smallest member | 624 # we store negative distances because heap returns smallest member |
625 h = [(-dist[node], node)] | 625 h = [(-dist[node], node)] |
626 seen = {} | 626 seen = {} |
627 earliest = self.count() | |
628 while h: | 627 while h: |
629 d, n = heapq.heappop(h) | 628 d, n = heapq.heappop(h) |
630 if n not in seen: | 629 if n not in seen: |
631 seen[n] = 1 | 630 seen[n] = 1 |
632 r = self.rev(n) | |
633 yield (-d, n) | 631 yield (-d, n) |
634 for p in self.parents(n): | 632 for p in self.parents(n): |
635 heapq.heappush(h, (-dist[p], p)) | 633 heapq.heappush(h, (-dist[p], p)) |
636 | 634 |
637 def generations(node): | 635 def generations(node): |
688 | 686 |
689 # add the parent of the first rev | 687 # add the parent of the first rev |
690 p = self.parents(self.node(revs[0]))[0] | 688 p = self.parents(self.node(revs[0]))[0] |
691 revs.insert(0, self.rev(p)) | 689 revs.insert(0, self.rev(p)) |
692 | 690 |
693 # helper to reconstruct intermediate versions | |
694 def construct(text, base, rev): | |
695 bins = [self.chunk(r) for r in xrange(base + 1, rev + 1)] | |
696 return mdiff.patches(text, bins) | |
697 | |
698 # build deltas | 691 # build deltas |
699 for d in xrange(0, len(revs) - 1): | 692 for d in xrange(0, len(revs) - 1): |
700 a, b = revs[d], revs[d + 1] | 693 a, b = revs[d], revs[d + 1] |
701 na = self.node(a) | 694 na = self.node(a) |
702 nb = self.node(b) | 695 nb = self.node(b) |
736 node = nullid | 729 node = nullid |
737 | 730 |
738 base = prev = -1 | 731 base = prev = -1 |
739 start = end = measure = 0 | 732 start = end = measure = 0 |
740 if r: | 733 if r: |
741 start = self.start(self.base(t)) | 734 base = self.base(t) |
735 start = self.start(base) | |
742 end = self.end(t) | 736 end = self.end(t) |
743 measure = self.length(self.base(t)) | 737 measure = self.length(base) |
744 base = self.base(t) | |
745 prev = self.tip() | 738 prev = self.tip() |
746 | 739 |
747 transaction.add(self.datafile, end) | 740 transaction.add(self.datafile, end) |
748 transaction.add(self.indexfile, r * struct.calcsize(indexformat)) | 741 transaction.add(self.indexfile, r * struct.calcsize(indexformat)) |
749 dfh = self.opener(self.datafile, "a") | 742 dfh = self.opener(self.datafile, "a") |
791 chk = self.addrevision(text, transaction, link, p1, p2) | 784 chk = self.addrevision(text, transaction, link, p1, p2) |
792 if chk != node: | 785 if chk != node: |
793 raise RevlogError(_("consistency error adding group")) | 786 raise RevlogError(_("consistency error adding group")) |
794 measure = len(text) | 787 measure = len(text) |
795 else: | 788 else: |
796 e = (end, len(cdelta), self.base(t), link, p1, p2, node) | 789 e = (end, len(cdelta), base, link, p1, p2, node) |
797 self.index.append(e) | 790 self.index.append(e) |
798 self.nodemap[node] = r | 791 self.nodemap[node] = r |
799 dfh.write(cdelta) | 792 dfh.write(cdelta) |
800 ifh.write(struct.pack(indexformat, *e)) | 793 ifh.write(struct.pack(indexformat, *e)) |
801 | 794 |
802 t, r, chain, prev = r, r + 1, node, node | 795 t, r, chain, prev = r, r + 1, node, node |
803 start = self.start(self.base(t)) | 796 base = self.base(t) |
797 start = self.start(base) | |
804 end = self.end(t) | 798 end = self.end(t) |
805 | 799 |
806 dfh.close() | 800 dfh.close() |
807 ifh.close() | 801 ifh.close() |
808 return node | 802 return node |