comparison doc/gendoc.py @ 44975:1a4b9b602e54 stable

py3: fix broken man page generation, it was generating `(default: NUL*)` `bytes(default)` was producing things like `(default: \x00)` when handed non-bytes values such as `1`, `10`, or `True`. The man page generation would apparently ignore these bytes and produce man pages that had the string `(default: )`. Test Plan: - Ran `cd doc; python3 gendoc.py "hg.1.gendoc"` and grepped for bad output - Ran `make deb`, extracted the deb, manually inspected `hg.1` file. Differential Revision: https://phab.mercurial-scm.org/D8639
author Kyle Lippincott <spectral@google.com>
date Wed, 17 Jun 2020 16:11:11 -0700
parents f0bee3b1b847
children c102b704edb5
comparison
equal deleted inserted replaced
44972:9e5f598fd29b 44975:1a4b9b602e54
38 ) 38 )
39 from mercurial.i18n import ( 39 from mercurial.i18n import (
40 gettext, 40 gettext,
41 _, 41 _,
42 ) 42 )
43 from mercurial.utils import stringutil
43 44
44 table = commands.table 45 table = commands.table
45 globalopts = commands.globalopts 46 globalopts = commands.globalopts
46 helptable = help.helptable 47 helptable = help.helptable
47 loaddoc = help.loaddoc 48 loaddoc = help.loaddoc
83 elif (default is not None) and not isinstance(default, bool): 84 elif (default is not None) and not isinstance(default, bool):
84 allopts[-1] += b" <%s>" % optlabel 85 allopts[-1] += b" <%s>" % optlabel
85 if b'\n' in desc: 86 if b'\n' in desc:
86 # only remove line breaks and indentation 87 # only remove line breaks and indentation
87 desc = b' '.join(l.lstrip() for l in desc.split(b'\n')) 88 desc = b' '.join(l.lstrip() for l in desc.split(b'\n'))
88 desc += default and _(b" (default: %s)") % bytes(default) or b"" 89 if default:
90 default = stringutil.forcebytestr(default)
91 desc += _(b" (default: %s)") % default
89 yield (b", ".join(allopts), desc) 92 yield (b", ".join(allopts), desc)
90 93
91 94
92 def get_cmd(cmd, cmdtable): 95 def get_cmd(cmd, cmdtable):
93 d = {} 96 d = {}