[PATCH 36 of 36] changectx: if passing a context then exit __init__ immediately

Augie Fackler raf at durin42.com
Wed Aug 7 13:32:57 CDT 2013


On Wed, Aug 07, 2013 at 01:13:36PM -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1375825361 18000
> #      Tue Aug 06 16:42:41 2013 -0500
> # Node ID 7316661a4968456c3868c178cab6e32004094504
> # Parent  3f12610b25b6e786c81d84734ca8433ad47ab7a3
> changectx: if passing a context then exit __init__ immediately

hm, so we'd leave an uninitialized object? I feel like this should
throw some kind of exception (TypeError? ArgumentError?) instead.

>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -152,10 +152,16 @@
>      """A changecontext object makes access to data related to a particular
>      changeset convenient. It represents a read-only context already presnt in
>      the repo."""
>      def __init__(self, repo, changeid=''):
>          """changeid is a revision number, node, or tag"""
> +
> +        # allow changeid to be a context so that we can simplify creating a
> +        # copy
> +        if isinstance(changeid, context):
> +            return
> +
>          if changeid == '':
>              changeid = '.'
>          self._repo = repo
>
>          if isinstance(changeid, int):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list