Show More
@@ -193,10 +193,7 b' class localrepository(repo.repository):' | |||
|
193 | 193 | |
|
194 | 194 | @storecache('obsstore') |
|
195 | 195 | def obsstore(self): |
|
196 | store = obsolete.obsstore() | |
|
197 | data = self.sopener.tryread('obsstore') | |
|
198 | if data: | |
|
199 | store.loadmarkers(data) | |
|
196 | store = obsolete.obsstore(self.sopener) | |
|
200 | 197 | return store |
|
201 | 198 | |
|
202 | 199 | @storecache('00changelog.i') |
@@ -990,16 +987,8 b' class localrepository(repo.repository):' | |||
|
990 | 987 | self.store.write() |
|
991 | 988 | if '_phasecache' in vars(self): |
|
992 | 989 | self._phasecache.write() |
|
993 |
if 'obsstore' in vars(self) |
|
|
994 | # XXX: transaction logic should be used here. But for | |
|
995 | # now rewriting the whole file is good enough. | |
|
996 | f = self.sopener('obsstore', 'wb', atomictemp=True) | |
|
997 | try: | |
|
998 | self.obsstore.flushmarkers(f) | |
|
999 | f.close() | |
|
1000 | except: # re-raises | |
|
1001 | f.discard() | |
|
1002 | raise | |
|
990 | if 'obsstore' in vars(self): | |
|
991 | self.obsstore.flushmarkers() | |
|
1003 | 992 | for k, ce in self._filecache.items(): |
|
1004 | 993 | if k == 'dirstate': |
|
1005 | 994 | continue |
@@ -156,12 +156,17 b' class obsstore(object):' | |||
|
156 | 156 | - successors: new -> set(old) |
|
157 | 157 | """ |
|
158 | 158 | |
|
159 | def __init__(self): | |
|
159 | def __init__(self, sopener): | |
|
160 | 160 | self._all = [] |
|
161 | 161 | # new markers to serialize |
|
162 | 162 | self._new = [] |
|
163 | 163 | self.precursors = {} |
|
164 | 164 | self.successors = {} |
|
165 | self.sopener = sopener | |
|
166 | data = sopener.tryread('obsstore') | |
|
167 | if data: | |
|
168 | for marker in _readmarkers(data): | |
|
169 | self._load(marker) | |
|
165 | 170 | |
|
166 | 171 | def __iter__(self): |
|
167 | 172 | return iter(self._all) |
@@ -193,11 +198,6 b' class obsstore(object):' | |||
|
193 | 198 | self._new.append(marker) |
|
194 | 199 | self._load(marker) |
|
195 | 200 | |
|
196 | def loadmarkers(self, data): | |
|
197 | """Load all markers in data, mark them as known.""" | |
|
198 | for marker in _readmarkers(data): | |
|
199 | self._load(marker) | |
|
200 | ||
|
201 | 201 | def mergemarkers(self, data): |
|
202 | 202 | other = set(_readmarkers(data)) |
|
203 | 203 | local = set(self._all) |
@@ -205,12 +205,21 b' class obsstore(object):' | |||
|
205 | 205 | for marker in new: |
|
206 | 206 | self.add(marker) |
|
207 | 207 | |
|
208 |
def flushmarkers(self |
|
|
209 |
"""Write all markers |
|
|
208 | def flushmarkers(self): | |
|
209 | """Write all markers on disk | |
|
210 | 210 | |
|
211 | 211 | After this operation, "new" markers are considered "known".""" |
|
212 | self._writemarkers(stream) | |
|
213 | self._new[:] = [] | |
|
212 | if self._new: | |
|
213 | # XXX: transaction logic should be used here. But for | |
|
214 | # now rewriting the whole file is good enough. | |
|
215 | f = self.sopener('obsstore', 'wb', atomictemp=True) | |
|
216 | try: | |
|
217 | self._writemarkers(f) | |
|
218 | f.close() | |
|
219 | self._new[:] = [] | |
|
220 | except: # re-raises | |
|
221 | f.discard() | |
|
222 | raise | |
|
214 | 223 | |
|
215 | 224 | def _load(self, marker): |
|
216 | 225 | self._all.append(marker) |
General Comments 0
You need to be logged in to leave comments.
Login now