[PATCH 2 of 7 shelve-ext v5] shelve: add a function to check whether obs-based shelve is enabled

Ryan McElroy rm at fb.com
Thu Mar 30 05:09:31 EDT 2017


On 3/29/17 2:18 PM, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1490790691 25200
> #      Wed Mar 29 05:31:31 2017 -0700
> # Node ID 0aa864184c9d78c11d18980cf0faa10828445ff5
> # Parent  b5d6e501621808f330e46295d09526a5d1e9064a
> shelve: add a function to check whether obs-based shelve is enabled
>
> A central place to check whether code should use traditional or
> obsolescense-based shelve behavior.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -41,6 +41,7 @@ from mercurial import (
>       mdiff,
>       merge,
>       node as nodemod,
> +    obsolete,
>       patch,
>       phases,
>       repair,
> @@ -72,6 +73,18 @@ patchextension = 'patch'
>   # generic user for all shelve operations
>   shelveuser = 'shelve at localhost'
>   
> +def isobsshelve(repo, ui):
> +    """Check whether obsolescense-based shelve is enabled"""
> +    obsshelve = ui.configbool('experimental', 'obsshelve')

Even though check-code doesn't require experimental flags to be 
documented yet, we should be good citizens and add documentation for any 
configuration we introduce.

> +    if not obsshelve:
> +        return False
> +    if not obsolete.isenabled(repo, obsolete.createmarkersopt):
> +        w = _('ignoring experimental.obsshelve because createmarkers option '
> +              'is disabled')
> +        ui.warn(w)
> +        return False
> +    return True
> +
>   class shelvedfile(object):
>       """Helper for the file storing a single shelve
>   
>



More information about the Mercurial-devel mailing list