Show More
@@ -205,14 +205,21 b' class revlog(object):' | |||
|
205 | 205 | self.indexfile = indexfile |
|
206 | 206 | self.datafile = indexfile[:-2] + ".d" |
|
207 | 207 | self.opener = opener |
|
208 | # 3-tuple of (node, rev, text) for a raw revision. | |
|
208 | 209 | self._cache = None |
|
210 | # 2-tuple of (rev, baserev) defining the base revision the delta chain | |
|
211 | # begins at for a revision. | |
|
209 | 212 | self._basecache = None |
|
213 | # 2-tuple of (offset, data) of raw data from the revlog at an offset. | |
|
210 | 214 | self._chunkcache = (0, '') |
|
215 | # How much data to read and cache into the raw revlog data cache. | |
|
211 | 216 | self._chunkcachesize = 65536 |
|
212 | 217 | self._maxchainlen = None |
|
213 | 218 | self._aggressivemergedeltas = False |
|
214 | 219 | self.index = [] |
|
220 | # Mapping of partial identifiers to full nodes. | |
|
215 | 221 | self._pcache = {} |
|
222 | # Mapping of revision integer to full node. | |
|
216 | 223 | self._nodecache = {nullid: nullrev} |
|
217 | 224 | self._nodepos = None |
|
218 | 225 | |
@@ -926,6 +933,10 b' class revlog(object):' | |||
|
926 | 933 | return hash(text, p1, p2) != node |
|
927 | 934 | |
|
928 | 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 | 940 | o, d = self._chunkcache |
|
930 | 941 | # try to add to existing cache |
|
931 | 942 | if o + len(d) == offset and len(d) + len(data) < _chunksize: |
@@ -934,13 +945,15 b' class revlog(object):' | |||
|
934 | 945 | self._chunkcache = offset, data |
|
935 | 946 | |
|
936 | 947 | def _loadchunk(self, offset, length, df=None): |
|
937 |
"""Load a |
|
|
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 | 951 | file handle to read from. |
|
941 | 952 | |
|
942 | 953 | If an existing file handle is passed, it will be seeked and the |
|
943 | 954 | original seek position will NOT be restored. |
|
955 | ||
|
956 | Returns a str or buffer of raw byte data. | |
|
944 | 957 | """ |
|
945 | 958 | if df is not None: |
|
946 | 959 | closehandle = False |
@@ -968,6 +981,16 b' class revlog(object):' | |||
|
968 | 981 | return d |
|
969 | 982 | |
|
970 | 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 | 994 | o, d = self._chunkcache |
|
972 | 995 | l = len(d) |
|
973 | 996 | |
@@ -982,6 +1005,18 b' class revlog(object):' | |||
|
982 | 1005 | return self._loadchunk(offset, length, df=df) |
|
983 | 1006 | |
|
984 | 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 | 1020 | start = self.start(startrev) |
|
986 | 1021 | end = self.end(endrev) |
|
987 | 1022 | if self._inline: |
@@ -991,12 +1026,29 b' class revlog(object):' | |||
|
991 | 1026 | return self._getchunk(start, length, df=df) |
|
992 | 1027 | |
|
993 | 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 | 1037 | return decompress(self._chunkraw(rev, rev, df=df)) |
|
995 | 1038 | |
|
996 | 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 | 1052 | if not revs: |
|
1001 | 1053 | return [] |
|
1002 | 1054 | start = self.start |
@@ -1032,6 +1084,7 b' class revlog(object):' | |||
|
1032 | 1084 | return l |
|
1033 | 1085 | |
|
1034 | 1086 | def _chunkclear(self): |
|
1087 | """Clear the raw chunk cache.""" | |
|
1035 | 1088 | self._chunkcache = (0, '') |
|
1036 | 1089 | |
|
1037 | 1090 | def deltaparent(self, rev): |
General Comments 0
You need to be logged in to leave comments.
Login now