[PATCH 18 of 19] workingctx: customize _matchstatus for parentworking case

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu May 15 19:24:36 CDT 2014



On 05/15/2014 02:16 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley at gmail.com>
> # Date 1398346348 18000
> #      Thu Apr 24 08:32:28 2014 -0500
> # Node ID a7bf5d5ab5a5671c5362389d52a2e3dd438be49c
> # Parent  0770226fad0f8961a755cb516c9e0604c7a4209a
> workingctx: customize _matchstatus for parentworking case

There is some strange magic going on here. Please elaborate.

>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1318,10 +1318,26 @@ class workingctx(committablectx):
>               s = super(workingctx, self)._generatestatus(other, s, match,
>                                                           listignored, listclean,
>                                                           listunknown)
>           return s
>
> +    def _matchstatus(self, other, s, match, listignored, listclean,
> +                     listunknown):
> +        """return different match.bad if other isn't parent"""

As said before, the black magic in strong in this area. You want a full 
featured docstring.

Reminder: doc-string works as changeset description

   short oneliner

   longer details
   one multiple line


> +        match = super(workingctx, self)._matchstatus(other, s, match,
> +                                                     listignored, listclean,
> +                                                     listunknown)
> +        if other != self._repo['.']:
> +            def bad(f, msg):
> +                # 'f' may be a directory pattern from 'match.files()',
> +                # so 'f not in ctx1' is not enough
> +                if f not in other and f not in other.dirs():
> +                    self._repo.ui.warn('%s: %s\n' %
> +                                       (self._repo.dirstate.pathto(f), msg))

Drops `self._repo.dirstate.pathto(f)` in a variable so that you do not 
needs the two line for displaying the messages


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list