# HG changeset patch # User Pierre-Yves David # Date 1366190316 -7200 # Node ID f74f2a4e33275f7a0bfddba694ea949f29815227 # Parent 63a783d1ac852d60e60669b2f8551a9b26de2947 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. diff -r 63a783d1ac85 -r f74f2a4e3327 mercurial/localrepo.py --- 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() diff -r 63a783d1ac85 -r f74f2a4e3327 mercurial/obsolete.py --- 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: