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