[PATCH 2 of 5 modernize-streamclone] streamclone: refactor code for deciding to stream clone

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Oct 3 18:16:34 CDT 2015



On 10/02/2015 10:55 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1443849731 25200
> #      Fri Oct 02 22:22:11 2015 -0700
> # Node ID 3b07d689eb21b1bae0baa38fa708fd339f3521af
> # Parent  78a614c3c6def09605aa17d23da8a94a931fe6cc
> streamclone: refactor code for deciding to stream clone
>
> Having this in a standalone function will eventually enable bundle2 to
> share code with the bundle1 code path.
>
> While I was here, I also added some comments to add clarity.
>
> diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
> --- a/mercurial/streamclone.py
> +++ b/mercurial/streamclone.py
> @@ -16,33 +16,60 @@ from . import (
>       store,
>       util,
>   )
>
> +def canperformstreamclone(repo, remote, heads, streamrequested=None):
> +    """Whether it is possible to perform a streaming clone as part of pull.
> +
> +    Returns a tuple of (supported, requirements). ``supported`` is True if
> +    streaming clone is supported and False otherwise. ``requirements`` is
> +    a set of repo requirements from the remote, or ``None`` if stream clone
> +    isn't supported.
> +    """

I would probably have gone for returning a single thing, None or 
requirement, assuming that None, is not supported. However, this is a 
minor details and your way is valid too.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list