##// END OF EJS Templates
revlog: improve documentation...
Gregory Szorc -
r27070:7860366b default
parent child Browse files
Show More
@@ -205,14 +205,21 b' class revlog(object):'
205 self.indexfile = indexfile
205 self.indexfile = indexfile
206 self.datafile = indexfile[:-2] + ".d"
206 self.datafile = indexfile[:-2] + ".d"
207 self.opener = opener
207 self.opener = opener
208 # 3-tuple of (node, rev, text) for a raw revision.
208 self._cache = None
209 self._cache = None
210 # 2-tuple of (rev, baserev) defining the base revision the delta chain
211 # begins at for a revision.
209 self._basecache = None
212 self._basecache = None
213 # 2-tuple of (offset, data) of raw data from the revlog at an offset.
210 self._chunkcache = (0, '')
214 self._chunkcache = (0, '')
215 # How much data to read and cache into the raw revlog data cache.
211 self._chunkcachesize = 65536
216 self._chunkcachesize = 65536
212 self._maxchainlen = None
217 self._maxchainlen = None
213 self._aggressivemergedeltas = False
218 self._aggressivemergedeltas = False
214 self.index = []
219 self.index = []
220 # Mapping of partial identifiers to full nodes.
215 self._pcache = {}
221 self._pcache = {}
222 # Mapping of revision integer to full node.
216 self._nodecache = {nullid: nullrev}
223 self._nodecache = {nullid: nullrev}
217 self._nodepos = None
224 self._nodepos = None
218
225
@@ -926,6 +933,10 b' class revlog(object):'
926 return hash(text, p1, p2) != node
933 return hash(text, p1, p2) != node
927
934
928 def _addchunk(self, offset, data):
935 def _addchunk(self, offset, data):
936 """Add a segment to the revlog cache.
937
938 Accepts an absolute offset and the data that is at that location.
939 """
929 o, d = self._chunkcache
940 o, d = self._chunkcache
930 # try to add to existing cache
941 # try to add to existing cache
931 if o + len(d) == offset and len(d) + len(data) < _chunksize:
942 if o + len(d) == offset and len(d) + len(data) < _chunksize:
@@ -934,13 +945,15 b' class revlog(object):'
934 self._chunkcache = offset, data
945 self._chunkcache = offset, data
935
946
936 def _loadchunk(self, offset, length, df=None):
947 def _loadchunk(self, offset, length, df=None):
937 """Load a chunk/segment from the revlog.
948 """Load a segment of raw data from the revlog.
938
949
939 Accepts absolute offset, length to read, and an optional existing
950 Accepts an absolute offset, length to read, and an optional existing
940 file handle to read from.
951 file handle to read from.
941
952
942 If an existing file handle is passed, it will be seeked and the
953 If an existing file handle is passed, it will be seeked and the
943 original seek position will NOT be restored.
954 original seek position will NOT be restored.
955
956 Returns a str or buffer of raw byte data.
944 """
957 """
945 if df is not None:
958 if df is not None:
946 closehandle = False
959 closehandle = False
@@ -968,6 +981,16 b' class revlog(object):'
968 return d
981 return d
969
982
970 def _getchunk(self, offset, length, df=None):
983 def _getchunk(self, offset, length, df=None):
984 """Obtain a segment of raw data from the revlog.
985
986 Accepts an absolute offset, length of bytes to obtain, and an
987 optional file handle to the already-opened revlog. If the file
988 handle is used, it's original seek position will not be preserved.
989
990 Requests for data may be returned from a cache.
991
992 Returns a str or a buffer instance of raw byte data.
993 """
971 o, d = self._chunkcache
994 o, d = self._chunkcache
972 l = len(d)
995 l = len(d)
973
996
@@ -982,6 +1005,18 b' class revlog(object):'
982 return self._loadchunk(offset, length, df=df)
1005 return self._loadchunk(offset, length, df=df)
983
1006
984 def _chunkraw(self, startrev, endrev, df=None):
1007 def _chunkraw(self, startrev, endrev, df=None):
1008 """Obtain a segment of raw data corresponding to a range of revisions.
1009
1010 Accepts the start and end revisions and an optional already-open
1011 file handle to be used for reading. If the file handle is read, its
1012 seek position will not be preserved.
1013
1014 Requests for data may be satisfied by a cache.
1015
1016 Returns a str or a buffer instance of raw byte data. Callers will
1017 need to call ``self.start(rev)`` and ``self.length()`` to determine
1018 where each revision's data begins and ends.
1019 """
985 start = self.start(startrev)
1020 start = self.start(startrev)
986 end = self.end(endrev)
1021 end = self.end(endrev)
987 if self._inline:
1022 if self._inline:
@@ -991,12 +1026,29 b' class revlog(object):'
991 return self._getchunk(start, length, df=df)
1026 return self._getchunk(start, length, df=df)
992
1027
993 def _chunk(self, rev, df=None):
1028 def _chunk(self, rev, df=None):
1029 """Obtain a single decompressed chunk for a revision.
1030
1031 Accepts an integer revision and an optional already-open file handle
1032 to be used for reading. If used, the seek position of the file will not
1033 be preserved.
1034
1035 Returns a str holding uncompressed data for the requested revision.
1036 """
994 return decompress(self._chunkraw(rev, rev, df=df))
1037 return decompress(self._chunkraw(rev, rev, df=df))
995
1038
996 def _chunks(self, revs, df=None):
1039 def _chunks(self, revs, df=None):
997 '''faster version of [self._chunk(rev) for rev in revs]
1040 """Obtain decompressed chunks for the specified revisions.
998
1041
999 Assumes that revs is in ascending order.'''
1042 Accepts an iterable of numeric revisions that are assumed to be in
1043 ascending order. Also accepts an optional already-open file handle
1044 to be used for reading. If used, the seek position of the file will
1045 not be preserved.
1046
1047 This function is similar to calling ``self._chunk()`` multiple times,
1048 but is faster.
1049
1050 Returns a list with decompressed data for each requested revision.
1051 """
1000 if not revs:
1052 if not revs:
1001 return []
1053 return []
1002 start = self.start
1054 start = self.start
@@ -1032,6 +1084,7 b' class revlog(object):'
1032 return l
1084 return l
1033
1085
1034 def _chunkclear(self):
1086 def _chunkclear(self):
1087 """Clear the raw chunk cache."""
1035 self._chunkcache = (0, '')
1088 self._chunkcache = (0, '')
1036
1089
1037 def deltaparent(self, rev):
1090 def deltaparent(self, rev):
General Comments 0
You need to be logged in to leave comments. Login now