[PATCH] Provide better context for custom Python encode/decode filters

Jesse Glick jesse.glick at sun.com
Sun Jan 27 12:18:59 CST 2008


Patrick Mézard wrote:
> Here is the rebased version of your patch assuming mine is pushed.
> Main differences:
> - exchanged filename/repo arguments positions. Most functions seem to take (ui, repo, ...).

Yes, fine.

> - moved the inspect logic in localrepo._filter() and run it one at every filter creation.

Not sure I understand why, but if it works then fine.

> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> -                    fn = lambda s, c: util.filter(s, c)
> +                    def filterfn(s, cmd, **kwargs):
> +                        return util.filter(s, cmd)
> +                    fn = filterfn

Can't you just use

   fn = lambda s, c, **kwargs: util.filter(s, c)

?

> +                    def compatfn(s, cmd, **kwargs):
> +                        return oldfn(s, cmd)
> +                    fn = compatfn

Similarly, try

   fn = lambda s, c, **kwargs: oldfn(s, c)



More information about the Mercurial-devel mailing list