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