Patchwork keyword: compact writing of temporary kwdemo hgrc

login
register
mail settings
Submitter Christian Ebert
Date March 11, 2016, 8:32 a.m.
Message ID <013bbbc3e2a3674ef223.1457685131@1.0.0.127.in-addr.arpa>
Download mbox | patch
Permalink /patch/13755/
State Accepted
Headers show

Comments

Christian Ebert - March 11, 2016, 8:32 a.m.
# HG changeset patch
# User Christian Ebert <blacktrash@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
Pierre-Yves David - March 11, 2016, 12:10 p.m.
On 03/11/2016 08:32 AM, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash@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

Sure, pushed to the clowncopter.

Patch

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'):