comparison mercurial/obsolete.py @ 19054:d5f968f7716f

obsolete: extract obsolescence marker pulling into a dedicated function Having a dedicated function will allow us to experiment with other exchange strategies in an extension. As we have no solid clues about how to do it right, being able to experiment is vital. Some transaction tricks are necessary for pull. But nothing too scary.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 17 Apr 2013 11:47:49 +0200
parents f74f2a4e3327
children f4a0f6dd95a3
comparison
equal deleted inserted replaced
19053:f74f2a4e3327 19054:d5f968f7716f
383 data = remotedata[key] 383 data = remotedata[key]
384 rslts.append(remote.pushkey('obsolete', key, '', data)) 384 rslts.append(remote.pushkey('obsolete', key, '', data))
385 if [r for r in rslts if not r]: 385 if [r for r in rslts if not r]:
386 msg = _('failed to push some obsolete markers!\n') 386 msg = _('failed to push some obsolete markers!\n')
387 repo.ui.warn(msg) 387 repo.ui.warn(msg)
388
389 def syncpull(repo, remote, gettransaction):
390 """utility function to pull bookmark to a remote
391
392 The `gettransaction` is function that return the pull transaction, creating
393 one if necessary. We return the transaction to inform the calling code that
394 a new transaction have been created (when applicable).
395
396 Exists mostly to allow overridding for experimentation purpose"""
397 tr = None
398 if _enabled:
399 repo.ui.debug('fetching remote obsolete markers\n')
400 remoteobs = remote.listkeys('obsolete')
401 if 'dump0' in remoteobs:
402 tr = gettransaction()
403 for key in sorted(remoteobs, reverse=True):
404 if key.startswith('dump'):
405 data = base85.b85decode(remoteobs[key])
406 repo.obsstore.mergemarkers(tr, data)
407 repo.invalidatevolatilesets()
408 return tr
388 409
389 def allmarkers(repo): 410 def allmarkers(repo):
390 """all obsolete markers known in a repository""" 411 """all obsolete markers known in a repository"""
391 for markerdata in repo.obsstore: 412 for markerdata in repo.obsstore:
392 yield marker(repo, markerdata) 413 yield marker(repo, markerdata)