diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1644,8 +1644,8 @@ def config(ui, repo, *values, **opts): 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() diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -641,11 +641,11 @@ def clone(ui, peeropts, source, dest=Non 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') diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -60,7 +60,7 @@ git = 1 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 @@ -82,7 +82,7 @@ username = """, '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 @@ default = %s """, '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 @@ default = %s """, '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