Show More
@@ -140,7 +140,7 b' def topicmatch(ui, commands, kw):' | |||
|
140 | 140 | else: |
|
141 | 141 | summary = '' |
|
142 | 142 | # translate docs *before* searching there |
|
143 |
docs = _( |
|
|
143 | docs = _(pycompat.getdoc(entry[0])) or '' | |
|
144 | 144 | if kw in cmd or lowercontains(summary) or lowercontains(docs): |
|
145 | 145 | doclines = docs.splitlines() |
|
146 | 146 | if doclines: |
@@ -162,8 +162,9 b' def topicmatch(ui, commands, kw):' | |||
|
162 | 162 | for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): |
|
163 | 163 | if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): |
|
164 | 164 | cmdname = cmd.partition('|')[0].lstrip('^') |
|
165 | if entry[0].__doc__: | |
|
166 | cmddoc = gettext(entry[0].__doc__).splitlines()[0] | |
|
165 | cmddoc = pycompat.getdoc(entry[0]) | |
|
166 | if cmddoc: | |
|
167 | cmddoc = gettext(cmddoc).splitlines()[0] | |
|
167 | 168 | else: |
|
168 | 169 | cmddoc = _('(no help text available)') |
|
169 | 170 | if filtercmd(ui, cmdname, kw, cmddoc): |
@@ -259,7 +260,7 b' def makeitemsdoc(ui, topic, doc, marker,' | |||
|
259 | 260 | """ |
|
260 | 261 | entries = [] |
|
261 | 262 | for name in sorted(items): |
|
262 |
text = (items[name] |
|
|
263 | text = (pycompat.getdoc(items[name]) or '').rstrip() | |
|
263 | 264 | if (not text |
|
264 | 265 | or not ui.verbose and any(w in text for w in _exclkeywords)): |
|
265 | 266 | continue |
@@ -345,7 +346,7 b' def help_(ui, commands, name, unknowncmd' | |||
|
345 | 346 | rst.append('\n') |
|
346 | 347 | |
|
347 | 348 | # description |
|
348 |
doc = gettext(entry[0] |
|
|
349 | doc = gettext(pycompat.getdoc(entry[0])) | |
|
349 | 350 | if not doc: |
|
350 | 351 | doc = _("(no help text available)") |
|
351 | 352 | if util.safehasattr(entry[0], 'definition'): # aliased command |
@@ -367,7 +368,7 b' def help_(ui, commands, name, unknowncmd' | |||
|
367 | 368 | # extension help text |
|
368 | 369 | try: |
|
369 | 370 | mod = extensions.find(name) |
|
370 |
doc = gettext(mod |
|
|
371 | doc = gettext(pycompat.getdoc(mod)) or '' | |
|
371 | 372 | if '\n' in doc.strip(): |
|
372 | 373 | msg = _("(use 'hg help -e %s' to show help for " |
|
373 | 374 | "the %s extension)") % (name, name) |
@@ -415,7 +416,7 b' def help_(ui, commands, name, unknowncmd' | |||
|
415 | 416 | if name == "shortlist" and not f.startswith("^"): |
|
416 | 417 | continue |
|
417 | 418 | f = f.lstrip("^") |
|
418 |
doc = e[0] |
|
|
419 | doc = pycompat.getdoc(e[0]) | |
|
419 | 420 | if filtercmd(ui, f, name, doc): |
|
420 | 421 | continue |
|
421 | 422 | doc = gettext(doc) |
@@ -518,7 +519,7 b' def help_(ui, commands, name, unknowncmd' | |||
|
518 | 519 | def helpext(name, subtopic=None): |
|
519 | 520 | try: |
|
520 | 521 | mod = extensions.find(name) |
|
521 |
doc = gettext(mod |
|
|
522 | doc = gettext(pycompat.getdoc(mod)) or _('no help text available') | |
|
522 | 523 | except KeyError: |
|
523 | 524 | mod = None |
|
524 | 525 | doc = extensions.disabledext(name) |
@@ -554,7 +555,7 b' def help_(ui, commands, name, unknowncmd' | |||
|
554 | 555 | def helpextcmd(name, subtopic=None): |
|
555 | 556 | cmd, ext, mod = extensions.disabledcmd(ui, name, |
|
556 | 557 | ui.configbool('ui', 'strict')) |
|
557 |
doc = gettext(mod |
|
|
558 | doc = gettext(pycompat.getdoc(mod)).splitlines()[0] | |
|
558 | 559 | |
|
559 | 560 | rst = listexts(_("'%s' is provided by the following " |
|
560 | 561 | "extension:") % cmd, {ext: doc}, indent=4, |
@@ -177,6 +177,14 b' if ispy3:' | |||
|
177 | 177 | """Raise exception with the given traceback""" |
|
178 | 178 | raise exc.with_traceback(tb) |
|
179 | 179 | |
|
180 | def getdoc(obj): | |
|
181 | """Get docstring as bytes; may be None so gettext() won't confuse it | |
|
182 | with _('')""" | |
|
183 | doc = getattr(obj, u'__doc__', None) | |
|
184 | if doc is None: | |
|
185 | return doc | |
|
186 | return sysbytes(doc) | |
|
187 | ||
|
180 | 188 | def _wrapattrfunc(f): |
|
181 | 189 | @functools.wraps(f) |
|
182 | 190 | def w(object, name, *args): |
@@ -255,6 +263,9 b' else:' | |||
|
255 | 263 | # better not to touch Python 2 part as it's already working fine. |
|
256 | 264 | fsdecode = identity |
|
257 | 265 | |
|
266 | def getdoc(obj): | |
|
267 | return getattr(obj, '__doc__', None) | |
|
268 | ||
|
258 | 269 | def getoptb(args, shortlist, namelist): |
|
259 | 270 | return getopt.getopt(args, shortlist, namelist) |
|
260 | 271 |
@@ -137,6 +137,20 b' Test bytes-ness of policy.policy with HG' | |||
|
137 | 137 | update: (current) |
|
138 | 138 | phases: 2 draft |
|
139 | 139 | |
|
140 | Test weird unicode-vs-bytes stuff | |
|
141 | ||
|
142 | $ $PYTHON3 $HGBIN help | egrep -v '^ |^$' | |
|
143 | Mercurial Distributed SCM | |
|
144 | list of commands: | |
|
145 | additional help topics: | |
|
146 | (use 'hg help -v' to show built-in aliases and global options) | |
|
147 | ||
|
148 | $ $PYTHON3 $HGBIN help help | egrep -v '^ |^$' | |
|
149 | hg help [-ecks] [TOPIC] | |
|
150 | show help for a given topic or a help overview | |
|
151 | options ([+] can be repeated): | |
|
152 | (some details hidden, use --verbose to show complete help) | |
|
153 | ||
|
140 | 154 | Prove the repo is valid using the Python 2 `hg`: |
|
141 | 155 | $ hg verify |
|
142 | 156 | checking changesets |
General Comments 0
You need to be logged in to leave comments.
Login now