##// END OF EJS Templates
obsolete: refactor writemarkers to only encode them...
Pierre-Yves.David@ens-lyon.org -
r17219:494a970f default
parent child Browse files
Show More
@@ -203,10 +203,9 class obsstore(object):
203 f.seek(0, 2) # os.SEEK_END
203 f.seek(0, 2) # os.SEEK_END
204 offset = f.tell()
204 offset = f.tell()
205 transaction.add('obsstore', offset)
205 transaction.add('obsstore', offset)
206 if offset == 0:
206 # offset == 0: new file - add the version header
207 # new file add version header
207 for bytes in _encodemarkers([marker], offset == 0):
208 f.write(_pack('>B', _fmversion))
208 f.write(bytes)
209 _writemarkers(f.write, [marker])
210 finally:
209 finally:
211 # XXX: f.close() == filecache invalidation == obsstore rebuilt.
210 # XXX: f.close() == filecache invalidation == obsstore rebuilt.
212 # call 'filecacheentry.refresh()' here
211 # call 'filecacheentry.refresh()' here
@@ -229,25 +228,26 class obsstore(object):
229 for suc in sucs:
228 for suc in sucs:
230 self.successors.setdefault(suc, set()).add(marker)
229 self.successors.setdefault(suc, set()).add(marker)
231
230
232 def _writemarkers(write, markers):
231 def _encodemarkers(markers, addheader=False):
233 # Kept separate from flushmarkers(), it will be reused for
232 # Kept separate from flushmarkers(), it will be reused for
234 # markers exchange.
233 # markers exchange.
234 if addheader:
235 yield _pack('>B', _fmversion)
235 for marker in markers:
236 for marker in markers:
236 pre, sucs, flags, metadata = marker
237 pre, sucs, flags, metadata = marker
237 nbsuc = len(sucs)
238 nbsuc = len(sucs)
238 format = _fmfixed + (_fmnode * nbsuc)
239 format = _fmfixed + (_fmnode * nbsuc)
239 data = [nbsuc, len(metadata), flags, pre]
240 data = [nbsuc, len(metadata), flags, pre]
240 data.extend(sucs)
241 data.extend(sucs)
241 write(_pack(format, *data))
242 yield _pack(format, *data)
242 write(metadata)
243 yield metadata
243
244
244 def listmarkers(repo):
245 def listmarkers(repo):
245 """List markers over pushkey"""
246 """List markers over pushkey"""
246 if not repo.obsstore:
247 if not repo.obsstore:
247 return {}
248 return {}
248 data = [_pack('>B', _fmversion)]
249 markers = _encodemarkers(repo.obsstore, True)
249 _writemarkers(data.append, repo.obsstore)
250 return {'dump': base85.b85encode(''.join(markers))}
250 return {'dump': base85.b85encode(''.join(data))}
251
251
252 def pushmarker(repo, key, old, new):
252 def pushmarker(repo, key, old, new):
253 """Push markers over pushkey"""
253 """Push markers over pushkey"""
General Comments 0
You need to be logged in to leave comments. Login now