Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/dispatch.py @ 35939:d5457d94e1c9
py3: replace "if ispy3" by pycompat.sysbytes() or util.forcebytestr()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 27 Jan 2018 13:14:06 +0900 |
parents | a2b3b5c5a25a |
children | f81df691efe7 |
comparison
equal
deleted
inserted
replaced
35938:a2b3b5c5a25a | 35939:d5457d94e1c9 |
---|---|
937 # version number and try updating. | 937 # version number and try updating. |
938 ct = util.versiontuple(n=2) | 938 ct = util.versiontuple(n=2) |
939 worst = None, ct, '' | 939 worst = None, ct, '' |
940 if ui.config('ui', 'supportcontact') is None: | 940 if ui.config('ui', 'supportcontact') is None: |
941 for name, mod in extensions.extensions(): | 941 for name, mod in extensions.extensions(): |
942 testedwith = getattr(mod, 'testedwith', '') | 942 # 'testedwith' should be bytes, but not all extensions are ported |
943 if pycompat.ispy3 and isinstance(testedwith, str): | 943 # to py3 and we don't want UnicodeException because of that. |
944 testedwith = testedwith.encode(u'utf-8') | 944 testedwith = util.forcebytestr(getattr(mod, 'testedwith', '')) |
945 report = getattr(mod, 'buglink', _('the extension author.')) | 945 report = getattr(mod, 'buglink', _('the extension author.')) |
946 if not testedwith.strip(): | 946 if not testedwith.strip(): |
947 # We found an untested extension. It's likely the culprit. | 947 # We found an untested extension. It's likely the culprit. |
948 worst = name, 'unknown', report | 948 worst = name, 'unknown', report |
949 break | 949 break |
974 bugtracker = ui.config('ui', 'supportcontact') | 974 bugtracker = ui.config('ui', 'supportcontact') |
975 if bugtracker is None: | 975 if bugtracker is None: |
976 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker") | 976 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker") |
977 warning = (_("** unknown exception encountered, " | 977 warning = (_("** unknown exception encountered, " |
978 "please report by visiting\n** ") + bugtracker + '\n') | 978 "please report by visiting\n** ") + bugtracker + '\n') |
979 if pycompat.ispy3: | 979 sysversion = pycompat.sysbytes(sys.version).replace('\n', '') |
980 sysversion = sys.version.encode(u'utf-8') | |
981 else: | |
982 sysversion = sys.version | |
983 sysversion = sysversion.replace('\n', '') | |
984 warning += ((_("** Python %s\n") % sysversion) + | 980 warning += ((_("** Python %s\n") % sysversion) + |
985 (_("** Mercurial Distributed SCM (version %s)\n") % | 981 (_("** Mercurial Distributed SCM (version %s)\n") % |
986 util.version()) + | 982 util.version()) + |
987 (_("** Extensions loaded: %s\n") % | 983 (_("** Extensions loaded: %s\n") % |
988 ", ".join([x[0] for x in extensions.extensions()]))) | 984 ", ".join([x[0] for x in extensions.extensions()]))) |