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