##// END OF EJS Templates
extdiff: escape path for docstring (issue5301)...
Matt Mackall -
r29630:67b180c0 stable
parent child Browse files
Show More
@@ -76,7 +76,6 b' from mercurial import ('
76 76 archival,
77 77 cmdutil,
78 78 commands,
79 encoding,
80 79 error,
81 80 filemerge,
82 81 scmutil,
@@ -365,7 +364,10 b' def uisetup(ui):'
365 364 if options:
366 365 options = ' ' + options
367 366 return dodiff(ui, repo, cmdline + options, pats, opts)
368 doc = _('''\
367 # We can't pass non-ASCII through docstrings (and path is
368 # in an unknown encoding anyway)
369 docpath = path.encode("string-escape")
370 mydiff.__doc__ = '''\
369 371 use %(path)s to diff repository (or selected files)
370 372
371 373 Show differences between revisions for the specified files, using
@@ -376,15 +378,7 b' use %(path)s to diff repository (or sele'
376 378 that revision is compared to the working directory, and, when no
377 379 revisions are specified, the working directory files are compared
378 380 to its parent.\
379 ''') % {'path': util.uirepr(path)}
380
381 # We must translate the docstring right away since it is
382 # used as a format string. The string will unfortunately
383 # be translated again in commands.helpcmd and this will
384 # fail when the docstring contains non-ASCII characters.
385 # Decoding the string to a Unicode string here (using the
386 # right encoding) prevents that.
387 mydiff.__doc__ = doc.decode(encoding.encoding)
381 ''' % {'path': util.uirepr(docpath)}
388 382 return mydiff
389 383 command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
390 384 inferrepo=True)(save(cmdline))
@@ -389,3 +389,23 b' Test symlinks handling (issue1909)'
389 389 $ cd ..
390 390
391 391 #endif
392
393 Test handling of non-ASCII paths in generated docstrings (issue5301)
394
395 >>> open("u", "w").write("\xa5\xa5")
396 $ U=`cat u`
397
398 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help -k xyzzy
399 abort: no matches
400 (try "hg help" for a list of topics)
401 [255]
402
403 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help td > /dev/null
404
405 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help -k xyzzy
406 abort: no matches
407 (try "hg help" for a list of topics)
408 [255]
409
410 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help td | grep "^use"
411 use '\xa5\xa5' to diff repository (or selected files)
General Comments 0
You need to be logged in to leave comments. Login now