[PATCH STABLE] keyword: avoid traceback when kwdemo is run outside a repo

Augie Fackler raf at durin42.com
Wed Jul 27 15:18:41 EDT 2016


On Wed, Jul 27, 2016 at 02:14:06PM +0100, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1469624271 -3600
> #      Wed Jul 27 13:57:51 2016 +0100
> # Branch stable
> # Node ID 2ae62fa7a85057d1c11df6cd948c09e29dabd6e5
> # Parent  6217180f9ab8c61320ea3826591960415779282e
> keyword: avoid traceback when kwdemo is run outside a repo

Can I interest you in adding a test of kwdemo to some test-keyword*.t
file so we don't regress this in the future?

>
> f0564402d059 causes a fatal AttributeError if kwdemo is run outside a repo
> because in the temporary repo creation repo is None and therefore cannot have a
> baseui attribute.
> In this case fall back to using ui.
>
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -412,7 +412,11 @@ def demo(ui, repo, *args, **opts):
>      fn = 'demo.txt'
>      tmpdir = tempfile.mkdtemp('', 'kwdemo.')
>      ui.note(_('creating temporary repository at %s\n') % tmpdir)
> -    repo = localrepo.localrepository(repo.baseui, tmpdir, True)
> +    if repo == None:
> +        baseui = ui
> +    else:
> +        baseui = repo.baseui
> +    repo = localrepo.localrepository(baseui, tmpdir, True)
>      ui.setconfig('keyword', fn, '', 'keyword')
>      svn = ui.configbool('keywordset', 'svn')
>      # explicitly set keywordset for demo output
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list