2714 f.close() |
2714 f.close() |
2715 return name |
2715 return name |
2716 |
2716 |
2717 problems = 0 |
2717 problems = 0 |
2718 |
2718 |
|
2719 fm = ui.formatter('debuginstall', opts) |
|
2720 fm.startitem() |
|
2721 |
2719 # encoding |
2722 # encoding |
2720 ui.status(_("checking encoding (%s)...\n") % encoding.encoding) |
2723 fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding) |
|
2724 err = None |
2721 try: |
2725 try: |
2722 encoding.fromlocal("test") |
2726 encoding.fromlocal("test") |
2723 except error.Abort as inst: |
2727 except error.Abort as inst: |
2724 ui.write(" %s\n" % inst) |
2728 err = inst |
2725 ui.write(_(" (check that your locale is properly set)\n")) |
|
2726 problems += 1 |
2729 problems += 1 |
|
2730 fm.condwrite(err, 'encodingerror', _(" %s\n" |
|
2731 " (check that your locale is properly set)\n"), err) |
2727 |
2732 |
2728 # Python |
2733 # Python |
2729 ui.status(_("checking Python executable (%s)\n") % sys.executable) |
2734 fm.write('pythonexe', _("checking Python executable (%s)\n"), |
2730 ui.status(_("checking Python version (%s)\n") |
2735 sys.executable) |
2731 % ("%s.%s.%s" % sys.version_info[:3])) |
2736 fm.write('pythonver', _("checking Python version (%s)\n"), |
2732 ui.status(_("checking Python lib (%s)...\n") |
2737 ("%s.%s.%s" % sys.version_info[:3])) |
2733 % os.path.dirname(os.__file__)) |
2738 fm.write('pythonlib', _("checking Python lib (%s)...\n"), |
|
2739 os.path.dirname(os.__file__)) |
2734 |
2740 |
2735 # compiled modules |
2741 # compiled modules |
2736 ui.status(_("checking installed modules (%s)...\n") |
2742 fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
2737 % os.path.dirname(__file__)) |
2743 os.path.dirname(__file__)) |
|
2744 |
|
2745 err = None |
2738 try: |
2746 try: |
2739 from . import ( |
2747 from . import ( |
2740 base85, |
2748 base85, |
2741 bdiff, |
2749 bdiff, |
2742 mpatch, |
2750 mpatch, |
2743 osutil, |
2751 osutil, |
2744 ) |
2752 ) |
2745 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
2753 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
2746 except Exception as inst: |
2754 except Exception as inst: |
2747 ui.write(" %s\n" % inst) |
2755 err = inst |
2748 ui.write(_(" One or more extensions could not be found")) |
|
2749 ui.write(_(" (check that you compiled the extensions)\n")) |
|
2750 problems += 1 |
2756 problems += 1 |
|
2757 fm.condwrite(err, 'extensionserror', " %s\n", err) |
2751 |
2758 |
2752 # templates |
2759 # templates |
2753 from . import templater |
2760 from . import templater |
2754 p = templater.templatepaths() |
2761 p = templater.templatepaths() |
2755 ui.status(_("checking templates (%s)...\n") % ' '.join(p)) |
2762 fm.write('templatedirs', 'checking templates (%s)...\n', ' '.join(p)) |
|
2763 fm.condwrite(not p, '', _(" no template directories found\n")) |
2756 if p: |
2764 if p: |
2757 m = templater.templatepath("map-cmdline.default") |
2765 m = templater.templatepath("map-cmdline.default") |
2758 if m: |
2766 if m: |
2759 # template found, check if it is working |
2767 # template found, check if it is working |
|
2768 err = None |
2760 try: |
2769 try: |
2761 templater.templater(m) |
2770 templater.templater(m) |
2762 except Exception as inst: |
2771 except Exception as inst: |
2763 ui.write(" %s\n" % inst) |
2772 err = inst |
2764 p = None |
2773 p = None |
|
2774 fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
2765 else: |
2775 else: |
2766 ui.write(_(" template 'default' not found\n")) |
|
2767 p = None |
2776 p = None |
2768 else: |
2777 fm.condwrite(p, 'defaulttemplate', |
2769 ui.write(_(" no template directories found\n")) |
2778 _("checking default template (%s)\n"), m) |
|
2779 fm.condwrite(not m, 'defaulttemplatenotfound', |
|
2780 _(" template '%s' not found\n"), "default") |
2770 if not p: |
2781 if not p: |
2771 ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
|
2772 problems += 1 |
2782 problems += 1 |
|
2783 fm.condwrite(not p, '', |
|
2784 _(" (templates seem to have been installed incorrectly)\n")) |
2773 |
2785 |
2774 # editor |
2786 # editor |
2775 ui.status(_("checking commit editor...\n")) |
|
2776 editor = ui.geteditor() |
2787 editor = ui.geteditor() |
2777 editor = util.expandpath(editor) |
2788 editor = util.expandpath(editor) |
|
2789 fm.write('editor', _("checking commit editor... (%s)\n"), editor) |
2778 cmdpath = util.findexe(shlex.split(editor)[0]) |
2790 cmdpath = util.findexe(shlex.split(editor)[0]) |
2779 if not cmdpath: |
2791 fm.condwrite(not cmdpath and editor == 'vi', 'vinotfound', |
2780 if editor == 'vi': |
2792 _(" No commit editor set and can't find %s in PATH\n" |
2781 ui.write(_(" No commit editor set and can't find vi in PATH\n")) |
2793 " (specify a commit editor in your configuration" |
2782 ui.write(_(" (specify a commit editor in your configuration" |
2794 " file)\n"), not cmdpath and editor == 'vi' and editor) |
2783 " file)\n")) |
2795 fm.condwrite(not cmdpath and editor != 'vi', 'editornotfound', |
2784 else: |
2796 _(" Can't find editor '%s' in PATH\n" |
2785 ui.write(_(" Can't find editor '%s' in PATH\n") % editor) |
2797 " (specify a commit editor in your configuration" |
2786 ui.write(_(" (specify a commit editor in your configuration" |
2798 " file)\n"), not cmdpath and editor) |
2787 " file)\n")) |
2799 if not cmdpath and editor != 'vi': |
2788 problems += 1 |
2800 problems += 1 |
2789 |
2801 |
2790 # check username |
2802 # check username |
2791 ui.status(_("checking username...\n")) |
2803 username = None |
|
2804 err = None |
2792 try: |
2805 try: |
2793 ui.username() |
2806 username = ui.username() |
2794 except error.Abort as e: |
2807 except error.Abort as e: |
2795 ui.write(" %s\n" % e) |
2808 err = e |
2796 ui.write(_(" (specify a username in your configuration file)\n")) |
|
2797 problems += 1 |
2809 problems += 1 |
2798 |
2810 |
|
2811 fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
|
2812 fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n" |
|
2813 " (specify a username in your configuration file)\n"), err) |
|
2814 |
|
2815 fm.condwrite(not problems, '', |
|
2816 _("no problems detected\n")) |
2799 if not problems: |
2817 if not problems: |
2800 ui.status(_("no problems detected\n")) |
2818 fm.data(problems=problems) |
2801 else: |
2819 fm.condwrite(problems, 'problems', |
2802 ui.write(_("%s problems detected," |
2820 _("%s problems detected," |
2803 " please check your install!\n") % problems) |
2821 " please check your install!\n"), problems) |
|
2822 fm.end() |
2804 |
2823 |
2805 return problems |
2824 return problems |
2806 |
2825 |
2807 @command('debugknown', [], _('REPO ID...'), norepo=True) |
2826 @command('debugknown', [], _('REPO ID...'), norepo=True) |
2808 def debugknown(ui, repopath, *ids, **opts): |
2827 def debugknown(ui, repopath, *ids, **opts): |