Show More
@@ -11,9 +11,8 b' from demandload import demandload' | |||
|
11 | 11 | demandload(globals(), "os time util") |
|
12 | 12 | |
|
13 | 13 | class changelog(revlog): |
|
14 |
def __init__(self, opener |
|
|
15 |
revlog.__init__(self, opener, "00changelog.i", "00changelog.d" |
|
|
16 | local=local) | |
|
14 | def __init__(self, opener): | |
|
15 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d") | |
|
17 | 16 | |
|
18 | 17 | def extract(self, text): |
|
19 | 18 | if not text: |
@@ -11,11 +11,10 b' from demandload import *' | |||
|
11 | 11 | demandload(globals(), "bdiff") |
|
12 | 12 | |
|
13 | 13 | class filelog(revlog): |
|
14 |
def __init__(self, opener, path |
|
|
14 | def __init__(self, opener, path): | |
|
15 | 15 | revlog.__init__(self, opener, |
|
16 | 16 | os.path.join("data", self.encodedir(path + ".i")), |
|
17 |
os.path.join("data", self.encodedir(path + ".d")) |
|
|
18 | local=local) | |
|
17 | os.path.join("data", self.encodedir(path + ".d"))) | |
|
19 | 18 | |
|
20 | 19 | # This avoids a collision between a file named foo and a dir named |
|
21 | 20 | # foo.i or foo.d |
@@ -30,8 +30,8 b' class localrepository(object):' | |||
|
30 | 30 | self.ui = ui |
|
31 | 31 | self.opener = util.opener(self.path) |
|
32 | 32 | self.wopener = util.opener(self.root) |
|
33 |
self.manifest = manifest.manifest(self.opener |
|
|
34 |
self.changelog = changelog.changelog(self.opener |
|
|
33 | self.manifest = manifest.manifest(self.opener) | |
|
34 | self.changelog = changelog.changelog(self.opener) | |
|
35 | 35 | self.tagscache = None |
|
36 | 36 | self.nodetagscache = None |
|
37 | 37 | self.encodepats = None |
@@ -161,7 +161,7 b' class localrepository(object):' | |||
|
161 | 161 | |
|
162 | 162 | def file(self, f): |
|
163 | 163 | if f[0] == '/': f = f[1:] |
|
164 |
return filelog.filelog(self.opener, f |
|
|
164 | return filelog.filelog(self.opener, f) | |
|
165 | 165 | |
|
166 | 166 | def getcwd(self): |
|
167 | 167 | return self.dirstate.getcwd() |
@@ -12,11 +12,10 b' from demandload import *' | |||
|
12 | 12 | demandload(globals(), "bisect array") |
|
13 | 13 | |
|
14 | 14 | class manifest(revlog): |
|
15 |
def __init__(self, opener |
|
|
15 | def __init__(self, opener): | |
|
16 | 16 | self.mapcache = None |
|
17 | 17 | self.listcache = None |
|
18 |
revlog.__init__(self, opener, "00manifest.i", "00manifest.d" |
|
|
19 | local=local) | |
|
18 | revlog.__init__(self, opener, "00manifest.i", "00manifest.d") | |
|
20 | 19 | |
|
21 | 20 | def read(self, node): |
|
22 | 21 | if node == nullid: return {} # don't upset local cache |
@@ -177,7 +177,7 b' class revlog(object):' | |||
|
177 | 177 | remove data, and can use some simple techniques to avoid the need |
|
178 | 178 | for locking while reading. |
|
179 | 179 | """ |
|
180 |
def __init__(self, opener, indexfile, datafile |
|
|
180 | def __init__(self, opener, indexfile, datafile): | |
|
181 | 181 | """ |
|
182 | 182 | create a revlog object |
|
183 | 183 | |
@@ -188,7 +188,6 b' class revlog(object):' | |||
|
188 | 188 | self.datafile = datafile |
|
189 | 189 | self.opener = opener |
|
190 | 190 | self.cache = None |
|
191 | self.local = local # XXX only needed because statichttp | |
|
192 | 191 | |
|
193 | 192 | try: |
|
194 | 193 | i = self.opener(self.indexfile).read() |
@@ -651,7 +650,7 b' class revlog(object):' | |||
|
651 | 650 | #print "next x" |
|
652 | 651 | gx = x.next() |
|
653 | 652 | |
|
654 | def group(self, nodelist, lookup, infocollect=None): | |
|
653 | def group(self, nodelist, lookup, infocollect = None): | |
|
655 | 654 | """calculate a delta group |
|
656 | 655 | |
|
657 | 656 | Given a list of changeset revs, return a set of deltas and |
@@ -661,6 +660,7 b' class revlog(object):' | |||
|
661 | 660 | changesets. parent is parent[0] |
|
662 | 661 | """ |
|
663 | 662 | revs = [self.rev(n) for n in nodelist] |
|
663 | needed = dict.fromkeys(revs, 1) | |
|
664 | 664 | |
|
665 | 665 | # if we don't have any revisions touched by these changesets, bail |
|
666 | 666 | if not revs: |
@@ -671,70 +671,59 b' class revlog(object):' | |||
|
671 | 671 | p = self.parents(self.node(revs[0]))[0] |
|
672 | 672 | revs.insert(0, self.rev(p)) |
|
673 | 673 | |
|
674 | if self.local: | |
|
675 | mm = self.opener(self.datafile) | |
|
676 | def chunk(r): | |
|
677 | o = self.start(r) | |
|
678 | l = self.length(r) | |
|
679 | mm.seek(o) | |
|
680 | return decompress(mm.read(l)) | |
|
681 | else: | |
|
682 | # XXX: statichttp workaround | |
|
683 | needed = dict.fromkeys(revs[1:], 1) | |
|
684 | # for each delta that isn't contiguous in the log, we need to | |
|
685 | # reconstruct the base, reconstruct the result, and then | |
|
686 | # calculate the delta. We also need to do this where we've | |
|
687 | # stored a full version and not a delta | |
|
688 | for i in xrange(0, len(revs) - 1): | |
|
689 | a, b = revs[i], revs[i + 1] | |
|
690 | if a + 1 != b or self.base(b) == b: | |
|
691 | for j in xrange(self.base(a), a + 1): | |
|
692 | needed[j] = 1 | |
|
693 | for j in xrange(self.base(b), b + 1): | |
|
694 | needed[j] = 1 | |
|
674 | # for each delta that isn't contiguous in the log, we need to | |
|
675 | # reconstruct the base, reconstruct the result, and then | |
|
676 | # calculate the delta. We also need to do this where we've | |
|
677 | # stored a full version and not a delta | |
|
678 | for i in xrange(0, len(revs) - 1): | |
|
679 | a, b = revs[i], revs[i + 1] | |
|
680 | if a + 1 != b or self.base(b) == b: | |
|
681 | for j in xrange(self.base(a), a + 1): | |
|
682 | needed[j] = 1 | |
|
683 | for j in xrange(self.base(b), b + 1): | |
|
684 | needed[j] = 1 | |
|
695 | 685 | |
|
696 |
|
|
|
697 |
|
|
|
698 |
|
|
|
699 |
|
|
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
|
703 |
|
|
|
704 |
|
|
|
705 |
|
|
|
706 |
|
|
|
707 |
|
|
|
708 |
|
|
|
709 |
|
|
|
710 |
|
|
|
711 |
|
|
|
712 |
|
|
|
713 |
|
|
|
714 |
|
|
|
686 | # calculate spans to retrieve from datafile | |
|
687 | needed = needed.keys() | |
|
688 | needed.sort() | |
|
689 | spans = [] | |
|
690 | oo = -1 | |
|
691 | ol = 0 | |
|
692 | for n in needed: | |
|
693 | if n < 0: continue | |
|
694 | o = self.start(n) | |
|
695 | l = self.length(n) | |
|
696 | if oo + ol == o: # can we merge with the previous? | |
|
697 | nl = spans[-1][2] | |
|
698 | nl.append((n, l)) | |
|
699 | ol += l | |
|
700 | spans[-1] = (oo, ol, nl) | |
|
701 | else: | |
|
702 | oo = o | |
|
703 | ol = l | |
|
704 | spans.append((oo, ol, [(n, l)])) | |
|
715 | 705 | |
|
716 |
|
|
|
717 |
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
|
706 | # read spans in, divide up chunks | |
|
707 | chunks = {} | |
|
708 | for span in spans: | |
|
709 | # we reopen the file for each span to make http happy for now | |
|
710 | f = self.opener(self.datafile) | |
|
711 | f.seek(span[0]) | |
|
712 | data = f.read(span[1]) | |
|
723 | 713 | |
|
724 |
|
|
|
725 |
|
|
|
726 |
|
|
|
727 |
|
|
|
728 |
|
|
|
729 | def chunk(r): | |
|
730 | return chunks[r] | |
|
714 | # divide up the span | |
|
715 | pos = 0 | |
|
716 | for r, l in span[2]: | |
|
717 | chunks[r] = decompress(data[pos: pos + l]) | |
|
718 | pos += l | |
|
731 | 719 | |
|
732 | 720 | # helper to reconstruct intermediate versions |
|
733 | 721 | def construct(text, base, rev): |
|
734 |
bins = [chunk |
|
|
722 | bins = [chunks[r] for r in xrange(base + 1, rev + 1)] | |
|
735 | 723 | return mdiff.patches(text, bins) |
|
736 | 724 | |
|
737 | 725 | # build deltas |
|
726 | deltas = [] | |
|
738 | 727 | for d in xrange(0, len(revs) - 1): |
|
739 | 728 | a, b = revs[d], revs[d + 1] |
|
740 | 729 | n = self.node(b) |
@@ -746,7 +735,7 b' class revlog(object):' | |||
|
746 | 735 | if a + 1 != b or self.base(b) == b: |
|
747 | 736 | if a >= 0: |
|
748 | 737 | base = self.base(a) |
|
749 |
ta = chunk |
|
|
738 | ta = chunks[self.base(a)] | |
|
750 | 739 | ta = construct(ta, base, a) |
|
751 | 740 | else: |
|
752 | 741 | ta = "" |
@@ -756,11 +745,11 b' class revlog(object):' | |||
|
756 | 745 | base = a |
|
757 | 746 | tb = ta |
|
758 | 747 | else: |
|
759 |
tb = chunk |
|
|
748 | tb = chunks[self.base(b)] | |
|
760 | 749 | tb = construct(tb, base, b) |
|
761 | 750 | d = self.diff(ta, tb) |
|
762 | 751 | else: |
|
763 |
d = chunk |
|
|
752 | d = chunks[b] | |
|
764 | 753 | |
|
765 | 754 | p = self.parents(n) |
|
766 | 755 | meta = n + p[0] + p[1] + lookup(n) |
@@ -31,12 +31,10 b' class statichttprepository(localrepo.loc' | |||
|
31 | 31 | self.path = (path + "/.hg") |
|
32 | 32 | self.ui = ui |
|
33 | 33 | self.opener = opener(self.path) |
|
34 |
self.manifest = manifest.manifest(self.opener |
|
|
35 |
self.changelog = changelog.changelog(self.opener |
|
|
34 | self.manifest = manifest.manifest(self.opener) | |
|
35 | self.changelog = changelog.changelog(self.opener) | |
|
36 | 36 | self.tagscache = None |
|
37 | 37 | self.nodetagscache = None |
|
38 | self.encodepats = None | |
|
39 | self.decodepats = None | |
|
40 | 38 | |
|
41 | 39 | def dev(self): |
|
42 | 40 | return -1 |
General Comments 0
You need to be logged in to leave comments.
Login now