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