Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/obsolete.py Wed Apr 17 11:18:36 2013 +0200 +++ b/mercurial/obsolete.py Wed Apr 17 11:47:49 2013 +0200 @@ -386,6 +386,27 @@ msg = _('failed to push some obsolete markers!\n') repo.ui.warn(msg) +def syncpull(repo, remote, gettransaction): + """utility function to pull bookmark to a remote + + The `gettransaction` is function that return the pull transaction, creating + one if necessary. We return the transaction to inform the calling code that + a new transaction have been created (when applicable). + + Exists mostly to allow overridding for experimentation purpose""" + tr = None + if _enabled: + repo.ui.debug('fetching remote obsolete markers\n') + remoteobs = remote.listkeys('obsolete') + if 'dump0' in remoteobs: + tr = gettransaction() + for key in sorted(remoteobs, reverse=True): + if key.startswith('dump'): + data = base85.b85decode(remoteobs[key]) + repo.obsstore.mergemarkers(tr, data) + repo.invalidatevolatilesets() + return tr + def allmarkers(repo): """all obsolete markers known in a repository""" for markerdata in repo.obsstore: