mercurial/commands.py
changeset 3848 8cbf060f637e
parent 3846 18855084b922
child 3855 b9cdd6f2aa43
equal deleted inserted replaced
3847:048e9bc5cdc2 3848:8cbf060f637e
   843     ui.status(_("Checking encoding (%s)...\n") % util._encoding)
   843     ui.status(_("Checking encoding (%s)...\n") % util._encoding)
   844     try:
   844     try:
   845         util.fromlocal("test")
   845         util.fromlocal("test")
   846     except util.Abort, inst:
   846     except util.Abort, inst:
   847         ui.write(" %s\n" % inst)
   847         ui.write(" %s\n" % inst)
       
   848         ui.write(_(" (check that your locale is properly set)\n"))
   848         problems += 1
   849         problems += 1
   849 
   850 
   850     # compiled modules
   851     # compiled modules
   851     ui.status(_("Checking extensions...\n"))
   852     ui.status(_("Checking extensions...\n"))
   852     try:
   853     try:
   853         import bdiff, mpatch, base85
   854         import bdiff, mpatch, base85
   854     except Exception, inst:
   855     except Exception, inst:
   855         ui.write(" %s\n" % inst)
   856         ui.write(" %s\n" % inst)
   856         ui.write(_(" One or more extensions could not be found,"
   857         ui.write(_(" One or more extensions could not be found"))
   857                  " check your build.\n"))
   858         ui.write(_(" (check that you compiled the extensions)\n"))
   858         problems += 1
   859         problems += 1
   859 
   860 
   860     # templates
   861     # templates
   861     ui.status(_("Checking templates...\n"))
   862     ui.status(_("Checking templates...\n"))
   862     try:
   863     try:
   863         import templater
   864         import templater
   864         t = templater.templater(templater.templatepath("map-cmdline.default"))
   865         t = templater.templater(templater.templatepath("map-cmdline.default"))
   865     except Exception, inst:
   866     except Exception, inst:
   866         ui.write(" %s\n" % inst)
   867         ui.write(" %s\n" % inst)
       
   868         ui.write(_(" (templates seem to have been installed incorrectly)\n"))
   867         problems += 1
   869         problems += 1
   868 
   870 
   869     # patch
   871     # patch
   870     ui.status(_("Checking patch...\n"))
   872     ui.status(_("Checking patch...\n"))
   871     path = os.environ.get('PATH', '')
   873     path = os.environ.get('PATH', '')
   872     patcher = util.find_in_path('gpatch', path,
   874     patcher = util.find_in_path('gpatch', path,
   873                                 util.find_in_path('patch', path, None))
   875                                 util.find_in_path('patch', path, None))
   874     if not patcher:
   876     if not patcher:
   875         ui.write(_(" Can't find patch or gpatch in PATH\n"))
   877         ui.write(_(" Can't find patch or gpatch in PATH\n"))
       
   878         ui.write(_(" (specify a patch utility in your .hgrc file)\n"))
   876         problems += 1
   879         problems += 1
   877     else:
   880     else:
   878         # actually attempt a patch here
   881         # actually attempt a patch here
   879         a = "1\n2\n3\n4\n"
   882         a = "1\n2\n3\n4\n"
   880         b = "1\n2\n3\ninsert\n4\n"
   883         b = "1\n2\n3\ninsert\n4\n"
   889             if line.startswith('patching file '):
   892             if line.startswith('patching file '):
   890                 pf = util.parse_patch_output(line.rstrip())
   893                 pf = util.parse_patch_output(line.rstrip())
   891                 files.append(pf)
   894                 files.append(pf)
   892         if files != [fa]:
   895         if files != [fa]:
   893             ui.write(_(" unexpected patch output!"))
   896             ui.write(_(" unexpected patch output!"))
       
   897             ui.write(_(" (you may have an incompatible version of patch)\n"))
   894             ui.write(data)
   898             ui.write(data)
   895             problems += 1
   899             problems += 1
   896         a = file(fa).read()
   900         a = file(fa).read()
   897         if a != b:
   901         if a != b:
   898             ui.write(_(" patch test failed!"))
   902             ui.write(_(" patch test failed!"))
       
   903             ui.write(_(" (you may have an incompatible version of patch)\n"))
   899             problems += 1
   904             problems += 1
   900         os.unlink(fa)
   905         os.unlink(fa)
   901         os.unlink(fd)
   906         os.unlink(fd)
   902 
   907 
   903     # merge helper
   908     # merge helper
   909         cmdpath = util.find_in_path(cmd.split()[0], path)
   914         cmdpath = util.find_in_path(cmd.split()[0], path)
   910     if not cmdpath:
   915     if not cmdpath:
   911         if cmd == 'hgmerge':
   916         if cmd == 'hgmerge':
   912             ui.write(_(" No merge helper set and can't find default"
   917             ui.write(_(" No merge helper set and can't find default"
   913                        " hgmerge script in PATH\n"))
   918                        " hgmerge script in PATH\n"))
       
   919             ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
   914         else:
   920         else:
   915             ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
   921             ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
       
   922             ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
   916             problems += 1
   923             problems += 1
   917     else:
   924     else:
   918         # actually attempt a patch here
   925         # actually attempt a patch here
   919         fa = writetemp("1\n2\n3\n4\n")
   926         fa = writetemp("1\n2\n3\n4\n")
   920         fl = writetemp("1\n2\n3\ninsert\n4\n")
   927         fl = writetemp("1\n2\n3\ninsert\n4\n")
   924             ui.write(_(" got unexpected merge error %d!") % r)
   931             ui.write(_(" got unexpected merge error %d!") % r)
   925             problems += 1
   932             problems += 1
   926         m = file(fl).read()
   933         m = file(fl).read()
   927         if m != "begin\n1\n2\n3\ninsert\n4\n":
   934         if m != "begin\n1\n2\n3\ninsert\n4\n":
   928             ui.write(_(" got unexpected merge results!") % r)
   935             ui.write(_(" got unexpected merge results!") % r)
       
   936             ui.write(_(" (your merge helper may have the"
       
   937                        " wrong argument order)\n"))
   929             ui.write(m)
   938             ui.write(m)
   930         os.unlink(fa)
   939         os.unlink(fa)
   931         os.unlink(fl)
   940         os.unlink(fl)
   932         os.unlink(fr)
   941         os.unlink(fr)
   933 
   942 
   940     if not cmdpath:
   949     if not cmdpath:
   941         cmdpath = util.find_in_path(editor.split()[0], path)
   950         cmdpath = util.find_in_path(editor.split()[0], path)
   942     if not cmdpath:
   951     if not cmdpath:
   943         if cmd == 'vi':
   952         if cmd == 'vi':
   944             ui.write(_(" No commit editor set and can't find vi in PATH\n"))
   953             ui.write(_(" No commit editor set and can't find vi in PATH\n"))
       
   954             ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
   945         else:
   955         else:
   946             ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
   956             ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
       
   957             ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
   947             problems += 1
   958             problems += 1
       
   959 
       
   960     # check username
       
   961     ui.status(_("Checking username...\n"))
       
   962     user = os.environ.get("HGUSER")
       
   963     if user is None:
       
   964         user = ui.config("ui", "username")
       
   965     if user is None:
       
   966         user = os.environ.get("EMAIL")
       
   967     if not user:
       
   968         ui.warn(" ")
       
   969         ui.username()
       
   970         ui.write(_(" (specify a username in your .hgrc file)\n"))
   948 
   971 
   949     if not problems:
   972     if not problems:
   950         ui.status(_("No problems detected\n"))
   973         ui.status(_("No problems detected\n"))
   951     else:
   974     else:
   952         ui.write(_("%s problems detected,"
   975         ui.write(_("%s problems detected,"