annotate mercurial/bundlerepo.py @ 2257:8dafccbcede9

indent: fix alignment
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 11 May 2006 11:24:28 +0200
parents 4b71f37cbdb7
children f116ddea537f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
1 """
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
2 bundlerepo.py - repository class for viewing uncompressed bundles
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
3
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
4 This provides a read-only repository interface to bundles as if
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
5 they were part of the actual repository.
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
6
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
7 Copyright 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org>
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
8
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
9 This software may be used and distributed according to the terms
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
10 of the GNU General Public License, incorporated herein by reference.
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
11 """
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
12
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
13 from node import *
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
14 from i18n import gettext as _
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
15 from demandload import demandload
1981
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
16 demandload(globals(), "changegroup util os struct")
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
17
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
18 import localrepo, changelog, manifest, filelog, revlog
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
19
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
20 class bundlerevlog(revlog.revlog):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
21 def __init__(self, opener, indexfile, datafile, bundlefile,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
22 linkmapper=None):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
23 # How it works:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
24 # to retrieve a revision, we need to know the offset of
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
25 # the revision in the bundlefile (an opened file).
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
26 #
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
27 # We store this offset in the index (start), to differentiate a
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
28 # rev in the bundle and from a rev in the revlog, we check
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
29 # len(index[r]). If the tuple is bigger than 7, it is a bundle
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
30 # (it is bigger since we store the node to which the delta is)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
31 #
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
32 revlog.revlog.__init__(self, opener, indexfile, datafile)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
33 self.bundlefile = bundlefile
2074
01ee43dda681 Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents: 1981
diff changeset
34 self.basemap = {}
1981
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
35 def chunkpositer():
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
36 for chunk in changegroup.chunkiter(bundlefile):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
37 pos = bundlefile.tell()
1981
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
38 yield chunk, pos - len(chunk)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
39 n = self.count()
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
40 prev = None
1981
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
41 for chunk, start in chunkpositer():
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
42 size = len(chunk)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
43 if size < 80:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
44 raise util.Abort("invalid changegroup")
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
45 start += 80
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
46 size -= 80
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
47 node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80])
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
48 if node in self.nodemap:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
49 prev = node
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
50 continue
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
51 for p in (p1, p2):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
52 if not p in self.nodemap:
2256
4b71f37cbdb7 fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2176
diff changeset
53 raise revlog.RevlogError(_("unknown parent %s") % short(p1))
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
54 if linkmapper is None:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
55 link = n
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
56 else:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
57 link = linkmapper(cs)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
58
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
59 if not prev:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
60 prev = p1
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
61 # start, size, base is not used, link, p1, p2, delta ref
2101
c6c019fd5db1 Make bundlerepo use proper index format for revlogng
Chris Mason <mason@suse.com>
parents: 2074
diff changeset
62 if self.version == 0:
c6c019fd5db1 Make bundlerepo use proper index format for revlogng
Chris Mason <mason@suse.com>
parents: 2074
diff changeset
63 e = (start, size, None, link, p1, p2, node)
c6c019fd5db1 Make bundlerepo use proper index format for revlogng
Chris Mason <mason@suse.com>
parents: 2074
diff changeset
64 else:
c6c019fd5db1 Make bundlerepo use proper index format for revlogng
Chris Mason <mason@suse.com>
parents: 2074
diff changeset
65 e = (self.offset_type(start, 0), size, -1, None, link,
c6c019fd5db1 Make bundlerepo use proper index format for revlogng
Chris Mason <mason@suse.com>
parents: 2074
diff changeset
66 self.rev(p1), self.rev(p2), node)
2074
01ee43dda681 Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents: 1981
diff changeset
67 self.basemap[n] = prev
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
68 self.index.append(e)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
69 self.nodemap[node] = n
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
70 prev = node
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
71 n += 1
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
72
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
73 def bundle(self, rev):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
74 """is rev from the bundle"""
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
75 if rev < 0:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
76 return False
2074
01ee43dda681 Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents: 1981
diff changeset
77 return rev in self.basemap
01ee43dda681 Fix bundle repos to use an index tuple consistent with revlogng
mason@suse.com
parents: 1981
diff changeset
78 def bundlebase(self, rev): return self.basemap[rev]
2256
4b71f37cbdb7 fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2176
diff changeset
79 def chunk(self, rev, df=None, cachelen=4096):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
80 # Warning: in case of bundle, the diff is against bundlebase,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
81 # not against rev - 1
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
82 # XXX: could use some caching
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
83 if not self.bundle(rev):
2256
4b71f37cbdb7 fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2176
diff changeset
84 return revlog.revlog.chunk(self, rev, df, cachelen)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
85 self.bundlefile.seek(self.start(rev))
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
86 return self.bundlefile.read(self.length(rev))
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
87
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
88 def revdiff(self, rev1, rev2):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
89 """return or calculate a delta between two revisions"""
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
90 if self.bundle(rev1) and self.bundle(rev2):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
91 # hot path for bundle
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
92 revb = self.rev(self.bundlebase(rev2))
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
93 if revb == rev1:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
94 return self.chunk(rev2)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
95 elif not self.bundle(rev1) and not self.bundle(rev2):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
96 return revlog.revlog.chunk(self, rev1, rev2)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
97
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
98 return self.diff(self.revision(self.node(rev1)),
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
99 self.revision(self.node(rev2)))
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
100
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
101 def revision(self, node):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
102 """return an uncompressed revision of a given"""
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
103 if node == nullid: return ""
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
104
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
105 text = None
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
106 chain = []
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
107 iter_node = node
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
108 rev = self.rev(iter_node)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
109 # reconstruct the revision if it is from a changegroup
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
110 while self.bundle(rev):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
111 if self.cache and self.cache[0] == iter_node:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
112 text = self.cache[2]
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
113 break
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
114 chain.append(rev)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
115 iter_node = self.bundlebase(rev)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
116 rev = self.rev(iter_node)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
117 if text is None:
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
118 text = revlog.revlog.revision(self, iter_node)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
119
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
120 while chain:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
121 delta = self.chunk(chain.pop())
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
122 text = self.patches(text, [delta])
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
123
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
124 p1, p2 = self.parents(node)
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
125 if node != revlog.hash(text, p1, p2):
2256
4b71f37cbdb7 fix errors spotted by pychecker (mostly scope problems)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2176
diff changeset
126 raise revlog.RevlogError(_("integrity check failed on %s:%d")
2257
8dafccbcede9 indent: fix alignment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2256
diff changeset
127 % (self.datafile, self.rev(node)))
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
128
2129
e5f5c21f4169 cached data was wrong: rev is different from self.rev(node) in bundlerepo.py
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2101
diff changeset
129 self.cache = (node, self.rev(node), text)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
130 return text
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
131
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
132 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
133 raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
134 def addgroup(self, revs, linkmapper, transaction, unique=0):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
135 raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
136 def strip(self, rev, minlink):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
137 raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
138 def checksize(self):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
139 raise NotImplementedError
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
140
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
141 class bundlechangelog(bundlerevlog, changelog.changelog):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
142 def __init__(self, opener, bundlefile):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
143 changelog.changelog.__init__(self, opener)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
144 bundlerevlog.__init__(self, opener, "00changelog.i", "00changelog.d",
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
145 bundlefile)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
146
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
147 class bundlemanifest(bundlerevlog, manifest.manifest):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
148 def __init__(self, opener, bundlefile, linkmapper):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
149 manifest.manifest.__init__(self, opener)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
150 bundlerevlog.__init__(self, opener, self.indexfile, self.datafile,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
151 bundlefile, linkmapper)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
152
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
153 class bundlefilelog(bundlerevlog, filelog.filelog):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
154 def __init__(self, opener, path, bundlefile, linkmapper):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
155 filelog.filelog.__init__(self, opener, path)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
156 bundlerevlog.__init__(self, opener, self.indexfile, self.datafile,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
157 bundlefile, linkmapper)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
158
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
159 class bundlerepository(localrepo.localrepository):
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
160 def __init__(self, ui, path, bundlename):
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
161 localrepo.localrepository.__init__(self, ui, path)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
162 f = open(bundlename, "rb")
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
163 self.bundlefile = f
1980
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
164 header = self.bundlefile.read(6)
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
165 if not header.startswith("HG"):
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
166 raise util.Abort(_("%s: not a Mercurial bundle file") % bundlename)
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
167 elif not header.startswith("HG10"):
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
168 raise util.Abort(_("%s: unknown bundle version") % bundlename)
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
169 elif header == "HG10BZ":
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
170 raise util.Abort(_("%s: compressed bundle not supported")
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
171 % bundlename)
1980
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
172 elif header == "HG10UN":
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
173 # uncompressed bundle supported
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
174 pass
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
175 else:
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
176 raise util.Abort(_("%s: unknown bundle compression type")
dfb796786337 use HG10UN header for uncompressed bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1971
diff changeset
177 % bundlename)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
178 self.changelog = bundlechangelog(self.opener, self.bundlefile)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
179 self.manifest = bundlemanifest(self.opener, self.bundlefile,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
180 self.changelog.rev)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
181 # dict with the mapping 'filename' -> position in the bundle
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
182 self.bundlefilespos = {}
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
183 while 1:
1981
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
184 f = changegroup.getchunk(self.bundlefile)
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
185 if not f:
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
186 break
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
187 self.bundlefilespos[f] = self.bundlefile.tell()
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
188 for c in changegroup.chunkiter(self.bundlefile):
736b6c96bbbc make incoming work via ssh (issue139); move chunk code into separate module.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1980
diff changeset
189 pass
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
190
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
191 def dev(self):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
192 return -1
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
193
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
194 def file(self, f):
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
195 if f[0] == '/':
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
196 f = f[1:]
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
197 if f in self.bundlefilespos:
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
198 self.bundlefile.seek(self.bundlefilespos[f])
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
199 return bundlefilelog(self.opener, f, self.bundlefile,
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
200 self.changelog.rev)
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
201 else:
1946
9fee186f7f0d bundlerepo: remove relative import, fix a comment
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1942
diff changeset
202 return filelog.filelog(self.opener, f)
1942
9da45de3118d add bundlerepo.py: a read-only repo that can use uncompressed bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff changeset
203
1971
915b81a35e46 imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1946
diff changeset
204 def close(self):
915b81a35e46 imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1946
diff changeset
205 """Close assigned bundle file immediately."""
915b81a35e46 imported patch /home/thomas/fix-incoming-abortion4.patch
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1946
diff changeset
206 self.bundlefile.close()