[PATCH 1 of 4] opener: introduce an abstact superclass of it

Adrian Buehlmann adrian at cadifra.com
Sun May 1 02:10:20 CDT 2011


On 2011-05-01 08:44, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
> # Date 1304185008 -7200
> # Node ID 5f957e0a8434bcdfdb7d414273381da904fe2c43
> # Parent  439271cd151f7e1ed9e60fe8bbc5ec0f2fb0f5c5
> opener: introduce an abstact superclass of it
> 
> Currently, this class doesn't do anything useful.
> 
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -129,7 +129,14 @@ class path_auditor(object):
>          # want to add "foo/bar/baz" before checking if there's a "foo/.hg"
>          self.auditeddir.update(prefixes)
>  
> -class opener(object):
> +class abstractopener(object):
> +    """Abstract base class; cannot be instantiated"""
> +
> +    def __init__(self, *args, **kwargs):
> +        '''Prevent instantiation; don't call this from subclasses.'''
> +        raise NotImplementedError('attempted instantiating ' + str(type(self)))
> +
> +class opener(abstractopener):
>      '''Open files relative to a base directory
>  
>      This class is used to hide the details of COW semantics and
> 

Last time I tried this, Matt refused such a base class. Let's see what's
his reaction on this attempt :-)





More information about the Mercurial-devel mailing list