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

login
register
mail settings
Submitter Christian Ebert
Date July 27, 2016, 1:14 p.m.
Message ID <2ae62fa7a85057d1c11d.1469625246@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/15989/
State Superseded
Headers show

Comments

Christian Ebert - July 27, 2016, 1:14 p.m.
# HG changeset patch
# User Christian Ebert <blacktrash@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

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.
Augie Fackler - July 27, 2016, 7:18 p.m.
On Wed, Jul 27, 2016 at 02:14:06PM +0100, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash@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@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Christian Ebert - July 27, 2016, 8:34 p.m.
* Augie Fackler on Wednesday, July 27, 2016 at 15:18:41 -0400
> On Wed, Jul 27, 2016 at 02:14:06PM +0100, Christian Ebert wrote:
>> # HG changeset patch
>> # User Christian Ebert <blacktrash@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?

Sure, was planning to do so myself, but wasn't certain whether I
would get to it in time because of tight schedule. - Hopefully
tomorrow.

Patch

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