obsolete: extract obsolescence marker pushing into a dedicated function

Having a dedicated function will allows 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.

I intended a more ambitious extraction of push logic, but we are far too
advanced in the release cycle for it.
This commit is contained in:
Pierre-Yves David 2013-04-17 11:18:36 +02:00
parent eed131db97
commit 0a4431da48
2 changed files with 17 additions and 11 deletions

View File

@ -1912,17 +1912,7 @@ class localrepository(object):
self.ui.warn(_('updating %s to public failed!\n') self.ui.warn(_('updating %s to public failed!\n')
% newremotehead) % newremotehead)
self.ui.debug('try to push obsolete markers to remote\n') self.ui.debug('try to push obsolete markers to remote\n')
if (obsolete._enabled and self.obsstore and obsolete.syncpush(self, remote)
'obsolete' in remote.listkeys('namespaces')):
rslts = []
remotedata = self.listkeys('obsolete')
for key in sorted(remotedata, reverse=True):
# reverse sort to ensure we end with dump0
data = remotedata[key]
rslts.append(remote.pushkey('obsolete', key, '', data))
if [r for r in rslts if not r]:
msg = _('failed to push some obsolete markers!\n')
self.ui.warn(msg)
finally: finally:
if lock is not None: if lock is not None:
lock.release() lock.release()

View File

@ -370,6 +370,22 @@ def pushmarker(repo, key, old, new):
finally: finally:
lock.release() lock.release()
def syncpush(repo, remote):
"""utility function to push bookmark to a remote
Exist mostly to allow overridding for experimentation purpose"""
if (_enabled and repo.obsstore and
'obsolete' in remote.listkeys('namespaces')):
rslts = []
remotedata = repo.listkeys('obsolete')
for key in sorted(remotedata, reverse=True):
# reverse sort to ensure we end with dump0
data = remotedata[key]
rslts.append(remote.pushkey('obsolete', key, '', data))
if [r for r in rslts if not r]:
msg = _('failed to push some obsolete markers!\n')
repo.ui.warn(msg)
def allmarkers(repo): def allmarkers(repo):
"""all obsolete markers known in a repository""" """all obsolete markers known in a repository"""
for markerdata in repo.obsstore: for markerdata in repo.obsstore: