[PATCH STABLE] record: display filename in local encoding when asking about file inclusion

Matt Mackall mpm at selenic.com
Fri Jun 29 22:24:03 CDT 2012


On Fri, 2012-06-29 at 22:15 -0500, Matt Mackall wrote:
> On Sat, 2012-06-30 at 00:43 +0400, Nikolaj Sjujskij wrote:
> > # HG changeset patch
> > # User Nikolaj Sjujskij <sterkrig at myopera.com>
> > # Date 1341002447 -14400
> > # Node ID 023ecef662bba83047243678a56fa3c4d756e75f
> > # Parent  1cdd0ebce8dc11983fcc58f1279c8350f8d66b14
> > record: display filename in local encoding when asking about file inclusion
> > 
> > When constructing message about whether to include a file into changeset/patch,
> > record uses `repr(filename)`. This results in unreadable mess when filename
> > isn't ASCII. The patch replaces `repr` with `encoding.tolocal`, ensuring proper
> > conversion and hence readability.
> 
> Please check out:
> 
> http://mercurial.selenic.com/wiki/EncodingStrategy
> 
> The current code is considered correct.

Actually, no, the current code is not correct, because it's using repr()
which mangles non-ASCII. And that's been in that prompt since day 1. A
better answer is:

diff -r 2440822446ce hgext/record.py
--- a/hgext/record.py	Sat Jun 23 19:57:29 2012 +0300
+++ b/hgext/record.py	Fri Jun 29 22:22:45 2012 -0500
@@ -380,7 +380,7 @@
         if skipall is None:
             h.pretty(ui)
         msg = (_('examine changes to %s?') %
-               _(' and ').join(map(repr, h.files())))
+               _(' and ').join("'%s'" % f for f in h.files()))
         r, skipfile, skipall, np = prompt(skipfile, skipall, msg, None)
         if not r:
             continue

..which passes tests. Thanks for spotting.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list