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