##// END OF EJS Templates
Make the appendfile class inline-data index friendly...
mason@suse.com -
r2075:343aeefb default
parent child Browse files
Show More
@@ -42,9 +42,19 class appendfile(object):
42 42 # seek and read can be fast.
43 43 self.fpsize = os.fstat(fp.fileno()).st_size
44 44
45 def seek(self, offset):
45 def end(self):
46 self.tmpfp.flush() # make sure the stat is correct
47 return self.fpsize + os.fstat(self.tmpfp.fileno()).st_size
48
49 def seek(self, offset, whence=0):
46 50 '''virtual file offset spans real file and temp file.'''
51 if whence == 0:
47 52 self.offset = offset
53 elif whence == 1:
54 self.offset += offset
55 elif whence == 2:
56 self.offset = self.end() + offset
57
48 58 if self.offset < self.fpsize:
49 59 self.realfp.seek(self.offset)
50 60 else:
@@ -103,8 +113,16 class sharedfile(object):
103 113 self.fp = fp
104 114 self.offset = 0
105 115
106 def seek(self, offset):
116 def tell(self):
117 return self.offset
118
119 def seek(self, offset, whence=0):
120 if whence == 0:
107 121 self.offset = offset
122 elif whence == 1:
123 self.offset += offset
124 elif whence == 2:
125 self.offset = self.fp.end() + offset
108 126
109 127 def read(self, count=-1):
110 128 try:
@@ -143,7 +161,7 class appendopener(object):
143 161 '''open file. return same cached appendfile object for every
144 162 later call.'''
145 163
146 assert mode in 'ra'
164 assert mode in 'ra+'
147 165 fp = self.fps.get(name)
148 166 if fp is None:
149 167 fp = appendfile(self.realopener(name, 'a+'))
@@ -165,8 +183,12 class appendchangelog(changelog.changelo
165 183 def __init__(self, opener):
166 184 appendopener.__init__(self, opener)
167 185 changelog.changelog.__init__(self, self)
186 def checkinlinesize(self, fp, tr):
187 return
168 188
169 189 class appendmanifest(manifest.manifest, appendopener):
170 190 def __init__(self, opener):
171 191 appendopener.__init__(self, opener)
172 192 manifest.manifest.__init__(self, self)
193 def checkinlinesize(self, fp, tr):
194 return
@@ -168,6 +168,7 class localrepository(object):
168 168 try:
169 169 return self.changelog.lookup(key)
170 170 except:
171 raise
171 172 raise repo.RepoError(_("unknown revision '%s'") % key)
172 173
173 174 def dev(self):
@@ -1456,6 +1457,8 class localrepository(object):
1456 1457 # make changelog and manifest see real files again
1457 1458 self.changelog = changelog.changelog(self.opener)
1458 1459 self.manifest = manifest.manifest(self.opener)
1460 self.changelog.checkinlinesize(tr)
1461 self.changelog.checkinlinesize(tr)
1459 1462
1460 1463 newheads = len(self.changelog.heads())
1461 1464 heads = ""
@@ -675,9 +675,11 class revlog(object):
675 675 self.cache = (node, rev, text)
676 676 return text
677 677
678 def checkinlinesize(self, fp, tr):
678 def checkinlinesize(self, tr, fp=None):
679 679 if not self.inlinedata():
680 680 return
681 if not fp:
682 fp = self.opener(self.indexfile, 'r')
681 683 size = fp.tell()
682 684 if size < 131072:
683 685 return
@@ -786,7 +788,7 class revlog(object):
786 788 if self.inlinedata():
787 789 f.write(data[0])
788 790 f.write(data[1])
789 self.checkinlinesize(f, transaction)
791 self.checkinlinesize(transaction, f)
790 792
791 793 self.cache = (node, n, text)
792 794 return node
@@ -966,7 +968,7 class revlog(object):
966 968 if self.inlinedata():
967 969 ifh.write(struct.pack(self.indexformat, *e))
968 970 ifh.write(cdelta)
969 self.checkinlinesize(ifh, transaction)
971 self.checkinlinesize(transaction, ifh)
970 972 if not self.inlinedata():
971 973 dfh = self.opener(self.datafile, "a")
972 974 ifh = self.opener(self.indexfile, "a")
General Comments 0
You need to be logged in to leave comments. Login now