Skip to content

Commit

Permalink
configwizard: encode output when printing new hgrc to screen (Bug 175…
Browse files Browse the repository at this point in the history
…1287)

Also add a new test showing the expected output.

--HG--
extra : amend_source : d8fd5d5de1d41bf0fdcae61ae2404031ed099443
extra : histedit_source : 1cb77d3de4530d32be3e6bd1605d6c11d0329b15%2C6a50db1e170e91dbdaa9d0098b9f61dfcdce7eff
  • Loading branch information
cgsheeh committed Apr 21, 2022
1 parent d76d168 commit c1dfb4a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hgext/configwizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ def _handleconfigchange(ui, cw):
ui.write(b'Your config file needs updating.\n')
if not ui.promptchoice(b'Would you like to see a diff of the changes first (Yn)? $$ &Yes $$ &No'):
for line in diff:
ui.write(b'%s\n' % pycompat.bytestr(line))
ui.write(b'%s\n' % pycompat.bytestr(line.encode('utf-8')))
ui.write(b'\n')

if not ui.promptchoice(b'Write changes to hgrc file (Yn)? $$ &Yes $$ &No'):
Expand Down
43 changes: 43 additions & 0 deletions hgext/configwizard/tests/test-username.t
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,46 @@ Name and email will result in ui.username being set
$ cat .hgrc
[ui]
username = Joe Smith <jsmith@example.com>
Usernames with non-ascii characters should be accepted.
$ hg --config ui.interactive=true --config configwizard.steps=username,configchange configwizard << EOF
>
> Emilio Cobos Álvarez
> emilio@example.com
> y
> y
> EOF
This wizard will guide you through configuring Mercurial for an optimal
experience contributing to Mozilla projects.
The wizard makes no changes without your permission.
To begin, press the enter/return key.
<RETURN>
You don't have a username defined in your Mercurial config file. In order
to author commits, you'll need to define a name and e-mail address.
This data will be publicly available when you send commits/patches to others.
If you aren't comfortable giving us your full name, pseudonames are
acceptable.
(Relevant config option: ui.username)
What is your name? Emilio Cobos \xc3\x81lvarez (esc)
What is your e-mail address? emilio@example.com
setting ui.username=Emilio Cobos \xc3\x81lvarez <emilio@example.com> (esc)
Your config file needs updating.
Would you like to see a diff of the changes first (Yn)? y
--- hgrc.old
+++ hgrc.new
@@ -1,2 +1,2 @@
[ui]
-username = Joe Smith <jsmith@example.com>
+username = Emilio Cobos \xc3\x83\xc2\x83\xc3\x82\xc2\x81lvarez <emilio@example.com> (esc)
Write changes to hgrc file (Yn)? y
$ cat .hgrc
[ui]
username = Emilio Cobos \xc3\x83\xc2\x81lvarez <emilio@example.com> (esc)

0 comments on commit c1dfb4a

Please sign in to comment.