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

Christian Ebert blacktrash at gmx.net
Wed Jul 27 09:14:06 EDT 2016


# 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

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


More information about the Mercurial-devel mailing list