mercurial/debugcommands.py
changeset 37084 f0b6fbea00cf
parent 37057 2ec1fb9de638
child 37120 a8a902d7176e
equal deleted inserted replaced
37083:f99d64e8a4e4 37084:f0b6fbea00cf
    79     util,
    79     util,
    80     vfs as vfsmod,
    80     vfs as vfsmod,
    81     wireprotoframing,
    81     wireprotoframing,
    82     wireprotoserver,
    82     wireprotoserver,
    83 )
    83 )
    84 from .utils import dateutil
    84 from .utils import (
       
    85     dateutil,
       
    86     stringutil,
       
    87 )
    85 
    88 
    86 release = lockmod.release
    89 release = lockmod.release
    87 
    90 
    88 command = registrar.command()
    91 command = registrar.command()
    89 
    92 
  1139     fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
  1142     fm.write('encoding', _("checking encoding (%s)...\n"), encoding.encoding)
  1140     err = None
  1143     err = None
  1141     try:
  1144     try:
  1142         codecs.lookup(pycompat.sysstr(encoding.encoding))
  1145         codecs.lookup(pycompat.sysstr(encoding.encoding))
  1143     except LookupError as inst:
  1146     except LookupError as inst:
  1144         err = util.forcebytestr(inst)
  1147         err = stringutil.forcebytestr(inst)
  1145         problems += 1
  1148         problems += 1
  1146     fm.condwrite(err, 'encodingerror', _(" %s\n"
  1149     fm.condwrite(err, 'encodingerror', _(" %s\n"
  1147                  " (check that your locale is properly set)\n"), err)
  1150                  " (check that your locale is properly set)\n"), err)
  1148 
  1151 
  1149     # Python
  1152     # Python
  1195                 mpatch,
  1198                 mpatch,
  1196                 osutil,
  1199                 osutil,
  1197             )
  1200             )
  1198             dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
  1201             dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
  1199         except Exception as inst:
  1202         except Exception as inst:
  1200             err = util.forcebytestr(inst)
  1203             err = stringutil.forcebytestr(inst)
  1201             problems += 1
  1204             problems += 1
  1202         fm.condwrite(err, 'extensionserror', " %s\n", err)
  1205         fm.condwrite(err, 'extensionserror', " %s\n", err)
  1203 
  1206 
  1204     compengines = util.compengines._engines.values()
  1207     compengines = util.compengines._engines.values()
  1205     fm.write('compengines', _('checking registered compression engines (%s)\n'),
  1208     fm.write('compengines', _('checking registered compression engines (%s)\n'),
  1232             # template found, check if it is working
  1235             # template found, check if it is working
  1233             err = None
  1236             err = None
  1234             try:
  1237             try:
  1235                 templater.templater.frommapfile(m)
  1238                 templater.templater.frommapfile(m)
  1236             except Exception as inst:
  1239             except Exception as inst:
  1237                 err = util.forcebytestr(inst)
  1240                 err = stringutil.forcebytestr(inst)
  1238                 p = None
  1241                 p = None
  1239             fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
  1242             fm.condwrite(err, 'defaulttemplateerror', " %s\n", err)
  1240         else:
  1243         else:
  1241             p = None
  1244             p = None
  1242         fm.condwrite(p, 'defaulttemplate',
  1245         fm.condwrite(p, 'defaulttemplate',
  1269     username = None
  1272     username = None
  1270     err = None
  1273     err = None
  1271     try:
  1274     try:
  1272         username = ui.username()
  1275         username = ui.username()
  1273     except error.Abort as e:
  1276     except error.Abort as e:
  1274         err = util.forcebytestr(e)
  1277         err = stringutil.forcebytestr(e)
  1275         problems += 1
  1278         problems += 1
  1276 
  1279 
  1277     fm.condwrite(username, 'username',  _("checking username (%s)\n"), username)
  1280     fm.condwrite(username, 'username',  _("checking username (%s)\n"), username)
  1278     fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
  1281     fm.condwrite(err, 'usernameerror', _("checking username...\n %s\n"
  1279         " (specify a username in your configuration file)\n"), err)
  1282         " (specify a username in your configuration file)\n"), err)
  1820         r = target.pushkey(namespace, key, old, new)
  1823         r = target.pushkey(namespace, key, old, new)
  1821         ui.status(pycompat.bytestr(r) + '\n')
  1824         ui.status(pycompat.bytestr(r) + '\n')
  1822         return not r
  1825         return not r
  1823     else:
  1826     else:
  1824         for k, v in sorted(target.listkeys(namespace).iteritems()):
  1827         for k, v in sorted(target.listkeys(namespace).iteritems()):
  1825             ui.write("%s\t%s\n" % (util.escapestr(k),
  1828             ui.write("%s\t%s\n" % (stringutil.escapestr(k),
  1826                                    util.escapestr(v)))
  1829                                    stringutil.escapestr(v)))
  1827 
  1830 
  1828 @command('debugpvec', [], _('A B'))
  1831 @command('debugpvec', [], _('A B'))
  1829 def debugpvec(ui, repo, a, b=None):
  1832 def debugpvec(ui, repo, a, b=None):
  1830     ca = scmutil.revsingle(repo, a)
  1833     ca = scmutil.revsingle(repo, a)
  1831     cb = scmutil.revsingle(repo, b)
  1834     cb = scmutil.revsingle(repo, b)
  2907             if not stdin:
  2910             if not stdin:
  2908                 raise error.Abort(_('cannot call raw/raw+ on this peer'))
  2911                 raise error.Abort(_('cannot call raw/raw+ on this peer'))
  2909 
  2912 
  2910             # Concatenate the data together.
  2913             # Concatenate the data together.
  2911             data = ''.join(l.lstrip() for l in lines)
  2914             data = ''.join(l.lstrip() for l in lines)
  2912             data = util.unescapestr(data)
  2915             data = stringutil.unescapestr(data)
  2913             stdin.write(data)
  2916             stdin.write(data)
  2914 
  2917 
  2915             if action == 'raw+':
  2918             if action == 'raw+':
  2916                 stdin.flush()
  2919                 stdin.flush()
  2917         elif action == 'flush':
  2920         elif action == 'flush':
  2933                     key = fields[0]
  2936                     key = fields[0]
  2934                     value = ''
  2937                     value = ''
  2935                 else:
  2938                 else:
  2936                     key, value = fields
  2939                     key, value = fields
  2937 
  2940 
  2938                 args[key] = util.unescapestr(value)
  2941                 args[key] = stringutil.unescapestr(value)
  2939 
  2942 
  2940             if batchedcommands is not None:
  2943             if batchedcommands is not None:
  2941                 batchedcommands.append((command, args))
  2944                 batchedcommands.append((command, args))
  2942                 continue
  2945                 continue
  2943 
  2946 
  2946             if 'PUSHFILE' in args:
  2949             if 'PUSHFILE' in args:
  2947                 with open(args['PUSHFILE'], r'rb') as fh:
  2950                 with open(args['PUSHFILE'], r'rb') as fh:
  2948                     del args['PUSHFILE']
  2951                     del args['PUSHFILE']
  2949                     res, output = peer._callpush(command, fh,
  2952                     res, output = peer._callpush(command, fh,
  2950                                                  **pycompat.strkwargs(args))
  2953                                                  **pycompat.strkwargs(args))
  2951                     ui.status(_('result: %s\n') % util.escapedata(res))
  2954                     ui.status(_('result: %s\n') % stringutil.escapedata(res))
  2952                     ui.status(_('remote output: %s\n') %
  2955                     ui.status(_('remote output: %s\n') %
  2953                               util.escapedata(output))
  2956                               stringutil.escapedata(output))
  2954             else:
  2957             else:
  2955                 res = peer._call(command, **pycompat.strkwargs(args))
  2958                 res = peer._call(command, **pycompat.strkwargs(args))
  2956                 ui.status(_('response: %s\n') % util.escapedata(res))
  2959                 ui.status(_('response: %s\n') % stringutil.escapedata(res))
  2957 
  2960 
  2958         elif action == 'batchbegin':
  2961         elif action == 'batchbegin':
  2959             if batchedcommands is not None:
  2962             if batchedcommands is not None:
  2960                 raise error.Abort(_('nested batchbegin not allowed'))
  2963                 raise error.Abort(_('nested batchbegin not allowed'))
  2961 
  2964 
  2965             # difficult to normalize requests into function calls. It is easier
  2968             # difficult to normalize requests into function calls. It is easier
  2966             # to bypass this layer and normalize to commands + args.
  2969             # to bypass this layer and normalize to commands + args.
  2967             ui.status(_('sending batch with %d sub-commands\n') %
  2970             ui.status(_('sending batch with %d sub-commands\n') %
  2968                       len(batchedcommands))
  2971                       len(batchedcommands))
  2969             for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
  2972             for i, chunk in enumerate(peer._submitbatch(batchedcommands)):
  2970                 ui.status(_('response #%d: %s\n') % (i, util.escapedata(chunk)))
  2973                 ui.status(_('response #%d: %s\n') %
       
  2974                           (i, stringutil.escapedata(chunk)))
  2971 
  2975 
  2972             batchedcommands = None
  2976             batchedcommands = None
  2973 
  2977 
  2974         elif action.startswith('httprequest '):
  2978         elif action.startswith('httprequest '):
  2975             if not opener:
  2979             if not opener: