Mercurial > hg
changeset 19053:f74f2a4e3327
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.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Wed, 17 Apr 2013 11:18:36 +0200 |
parents | 63a783d1ac85 |
children | d5f968f7716f |
files | mercurial/localrepo.py mercurial/obsolete.py |
diffstat | 2 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Apr 18 12:55:58 2013 -0700 +++ b/mercurial/localrepo.py Wed Apr 17 11:18:36 2013 +0200 @@ -1912,17 +1912,7 @@ self.ui.warn(_('updating %s to public failed!\n') % newremotehead) self.ui.debug('try to push obsolete markers to remote\n') - if (obsolete._enabled and self.obsstore and - '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) + obsolete.syncpush(self, remote) finally: if lock is not None: lock.release()
--- a/mercurial/obsolete.py Thu Apr 18 12:55:58 2013 -0700 +++ b/mercurial/obsolete.py Wed Apr 17 11:18:36 2013 +0200 @@ -370,6 +370,22 @@ finally: 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): """all obsolete markers known in a repository""" for markerdata in repo.obsstore: