##// END OF EJS Templates
filelog: remove proxies to revlog...
Gregory Szorc -
r39319:71575a1e default
parent child Browse files
Show More
@@ -1,268 +1,227
1 1 # filelog.py - file history class for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 from . import (
11 11 error,
12 12 repository,
13 13 revlog,
14 14 )
15 15 from .utils import (
16 16 interfaceutil,
17 17 )
18 18
19 19 @interfaceutil.implementer(repository.ifilestorage)
20 20 class filelog(object):
21 21 def __init__(self, opener, path):
22 22 self._revlog = revlog.revlog(opener,
23 23 '/'.join(('data', path + '.i')),
24 24 censorable=True)
25 25 # full name of the user visible file, relative to the repository root
26 26 self.filename = path
27 27 self.index = self._revlog.index
28 28 self.version = self._revlog.version
29 29 self._generaldelta = self._revlog._generaldelta
30 30
31 31 def __len__(self):
32 32 return len(self._revlog)
33 33
34 34 def __iter__(self):
35 35 return self._revlog.__iter__()
36 36
37 37 def revs(self, start=0, stop=None):
38 38 return self._revlog.revs(start=start, stop=stop)
39 39
40 40 def parents(self, node):
41 41 return self._revlog.parents(node)
42 42
43 43 def parentrevs(self, rev):
44 44 return self._revlog.parentrevs(rev)
45 45
46 46 def rev(self, node):
47 47 return self._revlog.rev(node)
48 48
49 49 def node(self, rev):
50 50 return self._revlog.node(rev)
51 51
52 52 def lookup(self, node):
53 53 return self._revlog.lookup(node)
54 54
55 55 def linkrev(self, rev):
56 56 return self._revlog.linkrev(rev)
57 57
58 58 def flags(self, rev):
59 59 return self._revlog.flags(rev)
60 60
61 61 def commonancestorsheads(self, node1, node2):
62 62 return self._revlog.commonancestorsheads(node1, node2)
63 63
64 64 def descendants(self, revs):
65 65 return self._revlog.descendants(revs)
66 66
67 67 def headrevs(self):
68 68 return self._revlog.headrevs()
69 69
70 70 def heads(self, start=None, stop=None):
71 71 return self._revlog.heads(start, stop)
72 72
73 73 def children(self, node):
74 74 return self._revlog.children(node)
75 75
76 76 def deltaparent(self, rev):
77 77 return self._revlog.deltaparent(rev)
78 78
79 79 def iscensored(self, rev):
80 80 return self._revlog.iscensored(rev)
81 81
82 82 def rawsize(self, rev):
83 83 return self._revlog.rawsize(rev)
84 84
85 85 def checkhash(self, text, node, p1=None, p2=None, rev=None):
86 86 return self._revlog.checkhash(text, node, p1=p1, p2=p2, rev=rev)
87 87
88 88 def revision(self, node, _df=None, raw=False):
89 89 return self._revlog.revision(node, _df=_df, raw=raw)
90 90
91 91 def revdiff(self, rev1, rev2):
92 92 return self._revlog.revdiff(rev1, rev2)
93 93
94 94 def emitrevisiondeltas(self, requests):
95 95 return self._revlog.emitrevisiondeltas(requests)
96 96
97 97 def addrevision(self, revisiondata, transaction, linkrev, p1, p2,
98 98 node=None, flags=revlog.REVIDX_DEFAULT_FLAGS,
99 99 cachedelta=None):
100 100 return self._revlog.addrevision(revisiondata, transaction, linkrev,
101 101 p1, p2, node=node, flags=flags,
102 102 cachedelta=cachedelta)
103 103
104 104 def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None):
105 105 return self._revlog.addgroup(deltas, linkmapper, transaction,
106 106 addrevisioncb=addrevisioncb)
107 107
108 108 def getstrippoint(self, minlink):
109 109 return self._revlog.getstrippoint(minlink)
110 110
111 111 def strip(self, minlink, transaction):
112 112 return self._revlog.strip(minlink, transaction)
113 113
114 114 def files(self):
115 115 return self._revlog.files()
116 116
117 117 def checksize(self):
118 118 return self._revlog.checksize()
119 119
120 120 def read(self, node):
121 121 t = self.revision(node)
122 122 if not t.startswith('\1\n'):
123 123 return t
124 124 s = t.index('\1\n', 2)
125 125 return t[s + 2:]
126 126
127 127 def add(self, text, meta, transaction, link, p1=None, p2=None):
128 128 if meta or text.startswith('\1\n'):
129 129 text = revlog.packmeta(meta, text)
130 130 return self.addrevision(text, transaction, link, p1, p2)
131 131
132 132 def renamed(self, node):
133 133 if self.parents(node)[0] != revlog.nullid:
134 134 return False
135 135 t = self.revision(node)
136 136 m = revlog.parsemeta(t)[0]
137 137 # copy and copyrev occur in pairs. In rare cases due to bugs,
138 138 # one can occur without the other.
139 139 if m and "copy" in m and "copyrev" in m:
140 140 return (m["copy"], revlog.bin(m["copyrev"]))
141 141 return False
142 142
143 143 def size(self, rev):
144 144 """return the size of a given revision"""
145 145
146 146 # for revisions with renames, we have to go the slow way
147 147 node = self.node(rev)
148 148 if self.renamed(node):
149 149 return len(self.read(node))
150 150 if self.iscensored(rev):
151 151 return 0
152 152
153 153 # XXX if self.read(node).startswith("\1\n"), this returns (size+4)
154 154 return self._revlog.size(rev)
155 155
156 156 def cmp(self, node, text):
157 157 """compare text with a given file revision
158 158
159 159 returns True if text is different than what is stored.
160 160 """
161 161
162 162 t = text
163 163 if text.startswith('\1\n'):
164 164 t = '\1\n\1\n' + text
165 165
166 166 samehashes = not self._revlog.cmp(node, t)
167 167 if samehashes:
168 168 return False
169 169
170 170 # censored files compare against the empty file
171 171 if self.iscensored(self.rev(node)):
172 172 return text != ''
173 173
174 174 # renaming a file produces a different hash, even if the data
175 175 # remains unchanged. Check if it's the case (slow):
176 176 if self.renamed(node):
177 177 t2 = self.read(node)
178 178 return t2 != text
179 179
180 180 return True
181 181
182 182 @property
183 183 def filename(self):
184 184 return self._revlog.filename
185 185
186 186 @filename.setter
187 187 def filename(self, value):
188 188 self._revlog.filename = value
189 189
190 190 # TODO these aren't part of the interface and aren't internal methods.
191 191 # Callers should be fixed to not use them.
192 192 @property
193 193 def indexfile(self):
194 194 return self._revlog.indexfile
195 195
196 196 @indexfile.setter
197 197 def indexfile(self, value):
198 198 self._revlog.indexfile = value
199 199
200 200 @property
201 201 def datafile(self):
202 202 return self._revlog.datafile
203 203
204 204 @property
205 205 def opener(self):
206 206 return self._revlog.opener
207 207
208 @property
209 def _lazydeltabase(self):
210 return self._revlog._lazydeltabase
211
212 @_lazydeltabase.setter
213 def _lazydeltabase(self, value):
214 self._revlog._lazydeltabase = value
215
216 @property
217 def _deltabothparents(self):
218 return self._revlog._deltabothparents
219
220 @_deltabothparents.setter
221 def _deltabothparents(self, value):
222 self._revlog._deltabothparents = value
223
224 @property
225 def _inline(self):
226 return self._revlog._inline
227
228 @property
229 def _withsparseread(self):
230 return getattr(self._revlog, '_withsparseread', False)
231
232 @property
233 def _srmingapsize(self):
234 return self._revlog._srmingapsize
235
236 @property
237 def _srdensitythreshold(self):
238 return self._revlog._srdensitythreshold
239
240 def _deltachain(self, rev, stoprev=None):
241 return self._revlog._deltachain(rev, stoprev)
242
243 def chainbase(self, rev):
244 return self._revlog.chainbase(rev)
245
246 def chainlen(self, rev):
247 return self._revlog.chainlen(rev)
248
249 208 def clone(self, tr, destrevlog, **kwargs):
250 209 if not isinstance(destrevlog, filelog):
251 210 raise error.ProgrammingError('expected filelog to clone()')
252 211
253 212 return self._revlog.clone(tr, destrevlog._revlog, **kwargs)
254 213
255 214 def start(self, rev):
256 215 return self._revlog.start(rev)
257 216
258 217 def end(self, rev):
259 218 return self._revlog.end(rev)
260 219
261 220 def length(self, rev):
262 221 return self._revlog.length(rev)
263 222
264 223 def compress(self, data):
265 224 return self._revlog.compress(data)
266 225
267 226 def _addrevision(self, *args, **kwargs):
268 227 return self._revlog._addrevision(*args, **kwargs)
General Comments 0
You need to be logged in to leave comments. Login now