Mercurial > hg
changeset 33687:6294654453ee
py3: use bytes IO to write sample hgrc
Unicode sucks. Stop using Text IO and manually convert line endings.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 03 Aug 2017 00:45:02 +0900 |
parents | 5aac617a028d |
children | 2194a8723138 |
files | mercurial/commands.py mercurial/hg.py mercurial/ui.py |
diffstat | 3 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Aug 04 08:15:10 2017 +0200 +++ b/mercurial/commands.py Thu Aug 03 00:45:02 2017 +0900 @@ -1644,8 +1644,8 @@ samplehgrc = uimod.samplehgrcs['user'] f = paths[0] - fp = open(f, "w") - fp.write(samplehgrc) + fp = open(f, "wb") + fp.write(util.tonativeeol(samplehgrc)) fp.close() editor = ui.geteditor()
--- a/mercurial/hg.py Fri Aug 04 08:15:10 2017 +0200 +++ b/mercurial/hg.py Thu Aug 03 00:45:02 2017 +0900 @@ -641,11 +641,11 @@ destrepo = destpeer.local() if destrepo: template = uimod.samplehgrcs['cloned'] - fp = destrepo.vfs("hgrc", "w", text=True) + fp = destrepo.vfs("hgrc", "wb") u = util.url(abspath) u.passwd = None - defaulturl = str(u) - fp.write(template % defaulturl) + defaulturl = bytes(u) + fp.write(util.tonativeeol(template % defaulturl)) fp.close() destrepo.ui.setconfig('paths', 'default', defaulturl, 'clone')
--- a/mercurial/ui.py Fri Aug 04 08:15:10 2017 +0200 +++ b/mercurial/ui.py Thu Aug 03 00:45:02 2017 +0900 @@ -60,7 +60,7 @@ samplehgrcs = { 'user': -"""# example user config (see 'hg help config' for more info) +b"""# example user config (see 'hg help config' for more info) [ui] # name and email, e.g. # username = Jane Doe <jdoe@example.com> @@ -82,7 +82,7 @@ """, 'cloned': -"""# example repository config (see 'hg help config' for more info) +b"""# example repository config (see 'hg help config' for more info) [paths] default = %s @@ -99,7 +99,7 @@ """, 'local': -"""# example repository config (see 'hg help config' for more info) +b"""# example repository config (see 'hg help config' for more info) [paths] # path aliases to other clones of this repo in URLs or filesystem paths # (see 'hg help config.paths' for more info) @@ -115,7 +115,7 @@ """, 'global': -"""# example system-wide hg config (see 'hg help config' for more info) +b"""# example system-wide hg config (see 'hg help config' for more info) [ui] # uncomment to disable color in command output