rage: force use of utf-8 and lines-square graph renderer

Summary:
`hg rage` generates the rage in the user's encoding.  Since pastes are expected
to be in UTF-8, non-UTF-8 encodings result in garbled pastes.

Similarly, the lines-dec graph renderer uses escape sequences that won't work
on web pages, and the lines graph renderer uses curved lines which don't
render very well either.  Force the use of the lines-square graph renderer,
which renders well.

Reviewed By: quark-zju

Differential Revision: D19951382

fbshipit-source-id: d1a5fd2ef195658f9bf10210088031474355f168
This commit is contained in:
Mark Thomas 2020-02-20 04:27:06 -08:00 committed by Facebook Github Bot
parent 1d70594590
commit c4acebfca1

View File

@ -225,8 +225,18 @@ def readcommitcloudstate(repo):
def _makerage(ui, repo, **opts):
# Make graphlog shorter.
configoverrides = {("experimental", "graphshorten"): "1"}
# Make graphlog shorter, and force use of lines-square renderer, as the
# user's configuration may not render properly in a text file.
configoverrides = {
("experimental", "graphshorten"): "1",
("experimental", "graph.renderer"): "lines-square",
}
# Override the encoding to "UTF-8" to generate the rage in UTF-8.
oldencoding = encoding.encoding
oldencodingmode = encoding.encodingmode
encoding.encoding = "UTF-8"
encoding.encodingmode = "replace"
def hgcmd(cmdname, *args, **additional_opts):
cmd, opts = cmdutil.getcmdanddefaultopts(cmdname, commands.table)
@ -458,6 +468,8 @@ def _makerage(ui, repo, **opts):
msg = "".join(msg)
ui._colormode = oldcolormode
encoding.encoding = oldencoding
encoding.encodingmode = oldencodingmode
return msg
@ -481,7 +493,7 @@ def rage(ui, repo, *pats, **opts):
if opts.get("preview"):
ui.pager("rage")
ui.write("%s\n" % msg)
ui.write("%s\n" % encoding.unitolocal(msg.decode("utf-8")))
return
with progress.spinner(ui, "saving paste"):