mirror of
https://github.com/facebook/sapling.git
synced 2024-12-24 13:34:37 +03:00
py3: fix test-help.t
Reviewed By: xavierd Differential Revision: D20953745 fbshipit-source-id: 7d6dd303e5789ae8c0a6a32ed40d884aa1f24803
This commit is contained in:
parent
3e38bb9b6a
commit
73f93a438b
15
eden/scm/doc/check-seclevel.py
Executable file → Normal file
15
eden/scm/doc/check-seclevel.py
Executable file → Normal file
@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This software may be used and distributed according to the terms of the
|
||||
@ -36,8 +35,8 @@ demandimport.enable()
|
||||
table = commands.table
|
||||
helptable = help.helptable
|
||||
|
||||
level2mark = [b'"', b"=", b"-", b".", b"#"]
|
||||
reservedmarks = [b'"']
|
||||
level2mark = ['"', "=", "-", ".", "#"]
|
||||
reservedmarks = ['"']
|
||||
|
||||
mark2level = {}
|
||||
for m, l in zip(level2mark, range(len(level2mark))):
|
||||
@ -59,16 +58,14 @@ def showavailables(ui, initlevel):
|
||||
|
||||
def checkseclevel(ui, doc, name, initlevel):
|
||||
ui.note(('checking "%s"\n') % name)
|
||||
if not isinstance(doc, bytes):
|
||||
doc = doc.encode("utf-8")
|
||||
blocks, pruned = minirst.parse(doc, 0, ["verbose"])
|
||||
errorcnt = 0
|
||||
curlevel = initlevel
|
||||
for block in blocks:
|
||||
if block[b"type"] != b"section":
|
||||
if block["type"] != "section":
|
||||
continue
|
||||
mark = block[b"underline"]
|
||||
title = block[b"lines"][0]
|
||||
mark = block["underline"]
|
||||
title = block["lines"][0]
|
||||
if (mark not in mark2level) or (mark2level[mark] <= initlevel):
|
||||
ui.warn(
|
||||
(
|
||||
@ -97,7 +94,7 @@ def checkseclevel(ui, doc, name, initlevel):
|
||||
def checkcmdtable(ui, cmdtable, namefmt, initlevel):
|
||||
errorcnt = 0
|
||||
for k, entry in cmdtable.items():
|
||||
name = k.split(b"|")[0].lstrip(b"^")
|
||||
name = k.split("|")[0].lstrip("^")
|
||||
if not entry[0].__doc__:
|
||||
ui.note(("skip checking %s: no help document\n") % (namefmt % name))
|
||||
continue
|
||||
|
@ -98,7 +98,11 @@ class LazyFinder(object):
|
||||
|
||||
def find_spec(self, *args, **kwargs):
|
||||
finder = object.__getattribute__(self, "_finder")
|
||||
spec = finder.find_spec(*args, **kwargs)
|
||||
find_spec = getattr(finder, "find_spec", None)
|
||||
if find_spec:
|
||||
spec = find_spec(*args, **kwargs)
|
||||
else:
|
||||
spec = None
|
||||
|
||||
# Lazy loader requires exec_module().
|
||||
if (
|
||||
|
@ -821,8 +821,6 @@ def _parse(ui, args):
|
||||
|
||||
# combine global options into local
|
||||
c += commands.globalopts
|
||||
# for o in commands.globalopts:
|
||||
# c.append((o[0], o[1], options[o[1]], o[3]))
|
||||
|
||||
try:
|
||||
flagdefs = [(flagdef[0], flagdef[1], flagdef[2]) for flagdef in c]
|
||||
|
@ -280,8 +280,7 @@ def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
|
||||
continue
|
||||
text = gettext(text)
|
||||
if dedent:
|
||||
# Abuse latin1 to use textwrap.dedent() on bytes.
|
||||
text = textwrap.dedent(text.decode("latin1")).encode("latin1")
|
||||
text = textwrap.dedent(text)
|
||||
lines = text.splitlines()
|
||||
doclines = [(lines[0])]
|
||||
for l in lines[1:]:
|
||||
|
@ -281,10 +281,10 @@ impl ToPyObject for Flag {
|
||||
|
||||
fn to_py_object(&self, py: Python) -> Self::ObjectType {
|
||||
(
|
||||
Bytes::from(self.short_name.map(|s| s.to_string()).unwrap_or_default()),
|
||||
Bytes::from(self.long_name.to_string()),
|
||||
Str::from(self.short_name.map(|s| s.to_string()).unwrap_or_default()),
|
||||
Str::from(self.long_name.to_string()),
|
||||
&self.default_value,
|
||||
Bytes::from(self.description.to_string()),
|
||||
Str::from(self.description.to_string()),
|
||||
)
|
||||
.to_py_object(py)
|
||||
.into_object()
|
||||
|
@ -1,4 +1,3 @@
|
||||
#require py2
|
||||
#chg-compatible
|
||||
|
||||
#require no-fsmonitor
|
||||
@ -781,14 +780,14 @@ this is a section and erroring out weirdly.
|
||||
> command = registrar.command(cmdtable)
|
||||
>
|
||||
> @command('nohelp',
|
||||
> [(b'', b'longdesc', 3, b'x'*90),
|
||||
> (b'n', b'', None, b'normal desc'),
|
||||
> (b'', b'newline', b'', b'line1\nline2')],
|
||||
> b'hg nohelp',
|
||||
> [('', 'longdesc', 3, 'x'*90),
|
||||
> ('n', '', None, 'normal desc'),
|
||||
> ('', 'newline', '', 'line1\nline2')],
|
||||
> 'hg nohelp',
|
||||
> norepo=True)
|
||||
> @command('debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
|
||||
> @command('debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
|
||||
> @command('debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
|
||||
> @command('debugoptADV', [('', 'aopt', None, 'option is (ADVANCED)')])
|
||||
> @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
|
||||
> @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
|
||||
> def nohelp(ui, *args, **kwargs):
|
||||
> pass
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user