[PATCH 1 of 2] obsolete: extract obsolescence marker pushing in a dedicated function

Kevin Bullock kbullock+mercurial at ringworld.org
Thu Apr 18 16:04:10 CDT 2013


On 18 Apr 2013, at 12:16 PM, pierre-yves.david at logilab.fr wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1366190316 -7200
> #      Wed Apr 17 11:18:36 2013 +0200
> # Node ID 368a3c420ecf9712b2efa3caf894acf447814b3a
> # Parent  ab04e87a5f3bcee588b72d615e1aeb42f10d3b99
> obsolete: extract obsolescence marker pushing in a dedicated function
> 
> Having a dedicated function will allows use to experiment with other exchange
> strategy in extension. Has we have not 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 to advance
> in the release cycle for it.
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1910,21 +1910,11 @@ class localrepository(object):
>                                            str(phases.public))
>                         if not r:
>                             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()
>         finally:
>             locallock.release()
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -368,10 +368,28 @@ def pushmarker(repo, key, old, new):
>         finally:
>             tr.release()
>     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)
> +
> +
> +

More added whitespace than strictly necessary, but this one LGTM.

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list