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