[PATCH] keyword: compact writing of temporary kwdemo hgrc

Christian Ebert blacktrash at gmx.net
Fri Mar 11 03:32:11 EST 2016


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1457684831 0
#      Fri Mar 11 08:27:11 2016 +0000
# Node ID 013bbbc3e2a3674ef2235b88889c05847b639fe8
# Parent  1c658391b22fb4d98ccfb60c0e57315b55634117
keyword: compact writing of temporary kwdemo hgrc

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -430,10 +430,8 @@ def demo(ui, repo, *args, **opts):
             ui.readconfig(opts.get('rcfile'))
         if args:
             # simulate hgrc parsing
-            rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
-            fp = repo.vfs('hgrc', 'w')
-            fp.writelines(rcmaps)
-            fp.close()
+            rcmaps = '[keywordmaps]\n%s\n' % '\n'.join(args)
+            repo.vfs.write('hgrc', rcmaps)
             ui.readconfig(repo.join('hgrc'))
         kwmaps = dict(ui.configitems('keywordmaps'))
     elif opts.get('default'):


More information about the Mercurial-devel mailing list