[PATCH] debugignore: catch the case when ignore.includepat doesn't exist

Augie Fackler lists at durin42.com
Tue Feb 15 14:25:23 CST 2011


On Tue, Feb 15, 2011 at 4:24 AM, Jason Harris <jason.f.harris at gmail.com> wrote:
> # HG changeset patch
> # User jfh <jason at jasonfharris.com>
> # Date 1297765396 -46800
> # Node ID 5e57c199848df186cd0b16476072831188ca41ed
> # Parent  682edefe7dbbefabbd56090de40d04709af21edb
> debugignore: catch the case when ignore.includepat doesn't exist
>
> In testing of my recent addition of a debugignore command, some of my MacHg
> users uncovered the exceptional case that if there is no ignore patterns of any
> kind then a traceback occurred. Catch and fix this case.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1355,7 +1355,10 @@
>  def debugignore(ui, repo, *values, **opts):
>     """display the combined ignore pattern"""
>     ignore = repo.dirstate._ignore
> -    ui.write("%s\n" % ignore.includepat)
> +    if hasattr(ignore, 'includepat'):

hasattr() is buggy (catches KeyboardInterrupt etc, not just
attributeerror), you should use getattr(ignore, 'includepat', None)
instead.

> +        ui.write("%s\n" % ignore.includepat)
> +    else:
> +        raise util.Abort(_("no ignore patterns found"))
>
>  def debugindex(ui, repo, file_, **opts):
>     """dump the contents of an index file"""
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list