849 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
855 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
850 if pp[1] != nullid: |
856 if pp[1] != nullid: |
851 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
857 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
852 ui.write("}\n") |
858 ui.write("}\n") |
853 |
859 |
|
860 @command('debuginstall', [] + commands.formatteropts, '', norepo=True) |
|
861 def debuginstall(ui, **opts): |
|
862 '''test Mercurial installation |
|
863 |
|
864 Returns 0 on success. |
|
865 ''' |
|
866 |
|
867 def writetemp(contents): |
|
868 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
|
869 f = os.fdopen(fd, "wb") |
|
870 f.write(contents) |
|
871 f.close() |
|
872 return name |
|
873 |
|
874 problems = 0 |
|
875 |
|
876 fm = ui.formatter('debuginstall', opts) |
|
877 fm.startitem() |
|
878 |
|
879 # encoding |
|
880 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
|
881 err = None |
|
882 try: |
|
883 encoding.fromlocal("test") |
|
884 except error.Abort as inst: |
|
885 err = inst |
|
886 problems += 1 |
|
887 fm.condwrite(err, 'encodingerror', _(" %s\n" |
|
888 " (check that your locale is properly set)\n"), err) |
|
889 |
|
890 # Python |
|
891 fm.write('pythonexe', _("checking Python executable (%s)\n"), |
|
892 pycompat.sysexecutable) |
|
893 fm.write('pythonver', _("checking Python version (%s)\n"), |
|
894 ("%d.%d.%d" % sys.version_info[:3])) |
|
895 fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
|
896 os.path.dirname(pycompat.fsencode(os.__file__))) |
|
897 |
|
898 security = set(sslutil.supportedprotocols) |
|
899 if sslutil.hassni: |
|
900 security.add('sni') |
|
901 |
|
902 fm.write('pythonsecurity', _("checking Python security support (%s)\n"), |
|
903 fm.formatlist(sorted(security), name='protocol', |
|
904 fmt='%s', sep=',')) |
|
905 |
|
906 # These are warnings, not errors. So don't increment problem count. This |
|
907 # may change in the future. |
|
908 if 'tls1.2' not in security: |
|
909 fm.plain(_(' TLS 1.2 not supported by Python install; ' |
|
910 'network connections lack modern security\n')) |
|
911 if 'sni' not in security: |
|
912 fm.plain(_(' SNI not supported by Python install; may have ' |
|
913 'connectivity issues with some servers\n')) |
|
914 |
|
915 # TODO print CA cert info |
|
916 |
|
917 # hg version |
|
918 hgver = util.version() |
|
919 fm.write('hgver', _("checking Mercurial version (%s)\n"), |
|
920 hgver.split('+')[0]) |
|
921 fm.write('hgverextra', _("checking Mercurial custom build (%s)\n"), |
|
922 '+'.join(hgver.split('+')[1:])) |
|
923 |
|
924 # compiled modules |
|
925 fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), |
|
926 policy.policy) |
|
927 fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
|
928 os.path.dirname(__file__)) |
|
929 |
|
930 err = None |
|
931 try: |
|
932 from . import ( |
|
933 base85, |
|
934 bdiff, |
|
935 mpatch, |
|
936 osutil, |
|
937 ) |
|
938 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
|
939 except Exception as inst: |
|
940 err = inst |
|
941 problems += 1 |
|
942 fm.condwrite(err, 'extensionserror', " %s\n", err) |
|
943 |
|
944 compengines = util.compengines._engines.values() |
|
945 fm.write('compengines', _('checking registered compression engines (%s)\n'), |
|
946 fm.formatlist(sorted(e.name() for e in compengines), |
|
947 name='compengine', fmt='%s', sep=', ')) |
|
948 fm.write('compenginesavail', _('checking available compression engines ' |
|
949 '(%s)\n'), |
|
950 fm.formatlist(sorted(e.name() for e in compengines |
|
951 if e.available()), |
|
952 name='compengine', fmt='%s', sep=', ')) |
|
953 wirecompengines = util.compengines.supportedwireengines(util.SERVERROLE) |
|
954 fm.write('compenginesserver', _('checking available compression engines ' |
|
955 'for wire protocol (%s)\n'), |
|
956 fm.formatlist([e.name() for e in wirecompengines |
|
957 if e.wireprotosupport()], |
|
958 name='compengine', fmt='%s', sep=', ')) |
|
959 |
|
960 # templates |
|
961 p = templater.templatepaths() |
|
962 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
|
963 fm.condwrite(not p, '', _(" no template directories found\n")) |
|
964 if p: |
|
965 m = templater.templatepath("map-cmdline.default") |
|
966 if m: |
|
967 # template found, check if it is working |
|
968 err = None |
|
969 try: |
|
970 templater.templater.frommapfile(m) |
|
971 except Exception as inst: |
|
972 err = inst |
|
973 p = None |
|
974 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
|
975 else: |
|
976 p = None |
|
977 fm.condwrite(p, 'defaulttemplate', |
|
978 _("checking default template (%s)\n"), m) |
|
979 fm.condwrite(not m, 'defaulttemplatenotfound', |
|
980 _(" template '%s' not found\n"), "default") |
|
981 if not p: |
|
982 problems += 1 |
|
983 fm.condwrite(not p, '', |
|
984 _(" (templates seem to have been installed incorrectly)\n")) |
|
985 |
|
986 # editor |
|
987 editor = ui.geteditor() |
|
988 editor = util.expandpath(editor) |
|
989 fm.write('editor', _("checking commit editor... (%s)\n"), editor) |
|
990 cmdpath = util.findexe(pycompat.shlexsplit(editor)[0]) |
|
991 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
|
992 _(" No commit editor set and can't find %s in PATH\n" |
|
993 " (specify a commit editor in your configuration" |
|
994 " file)\n"), not cmdpath and editor == 'vi' and editor) |
|
995 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
|
996 _(" Can't find editor '%s' in PATH\n" |
|
997 " (specify a commit editor in your configuration" |
|
998 " file)\n"), not cmdpath and editor) |
|
999 if not cmdpath and editor != 'vi': |
|
1000 problems += 1 |
|
1001 |
|
1002 # check username |
|
1003 username = None |
|
1004 err = None |
|
1005 try: |
|
1006 username = ui.username() |
|
1007 except error.Abort as e: |
|
1008 err = e |
|
1009 problems += 1 |
|
1010 |
|
1011 fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
|
1012 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
|
1013 " (specify a username in your configuration file)\n"), err) |
|
1014 |
|
1015 fm.condwrite(not problems, '', |
|
1016 _("no problems detected\n")) |
|
1017 if not problems: |
|
1018 fm.data(problems=problems) |
|
1019 fm.condwrite(problems, 'problems', |
|
1020 _("%d problems detected," |
|
1021 " please check your install!\n"), problems) |
|
1022 fm.end() |
|
1023 |
|
1024 return problems |
|
1025 |
854 @command('debugupgraderepo', [ |
1026 @command('debugupgraderepo', [ |
855 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
1027 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')), |
856 ('', 'run', False, _('performs an upgrade')), |
1028 ('', 'run', False, _('performs an upgrade')), |
857 ]) |
1029 ]) |
858 def debugupgraderepo(ui, repo, run=False, optimize=None): |
1030 def debugupgraderepo(ui, repo, run=False, optimize=None): |