Clearing up the backlog
Matt Mackall
mpm at selenic.com
Sat Aug 13 15:39:17 CDT 2005
On Sat, Aug 13, 2005 at 02:44:55PM +0200, vseguip at gmail.com wrote:
> Hi Matt,
>
> I wonder if you could apply the 1st patch for i8n which ensures
> that hg outputs messages to the correct user encoding. The second patch
> of the series stills needs work according to Thomas.
Yes. Just so you know, I do want to move forward on the i18n bits, but
being a dumb American, I have zero expertise here. So I'd like to
hear some other thoughts on these bits.
This piece by itself is isolated enough that I can apply it by itself,
so I'll do that.. (after dropping the stray README hunk)
> # HG changeset patch
> # User vseguip at gmail.com
> # Node ID 355b0d7a60b888127d687a4dcf2a0e2d540947ba
> # Parent 6d6095823b82f32c7d20230c4b7fc18fe6343dae
> # Parent b10c42919766d630d3ea12f75ae36d0938ea4b14
> This ensures that hg outputs in the user preferred encoding.
>
> diff -r 6d6095823b82 -r 355b0d7a60b8 README
> --- a/README Sat Aug 13 07:54:09 2005
> +++ b/README Sat Aug 13 12:37:40 2005
> @@ -92,3 +92,4 @@
> # Set up a CGI server on your webserver
> foo$ cp hgweb.cgi ~/public_html/hg/index.cgi
> foo$ emacs ~/public_html/hg/index.cgi # adjust the defaults
> +
> diff -r 6d6095823b82 -r 355b0d7a60b8 mercurial/ui.py
> --- a/mercurial/ui.py Sat Aug 13 07:54:09 2005
> +++ b/mercurial/ui.py Sat Aug 13 12:37:40 2005
> @@ -24,6 +24,13 @@
> self.verbose = (self.verbose or verbose) or debug
> self.debugflag = (self.debugflag or debug)
> self.interactive = (self.interactive and interactive)
> + self.user_encoding = self.config("ui","encoding")
> +
> + # sys.stdin.encoding is used to make "hg log|more" work on Windows
> + self.encoding = (self.user_encoding
> + or sys.stdout.encoding
> + or sys.stdin.encoding or
> + locale.getpreferredencoding())
>
> def readconfig(self, fp):
> self.cdata.readfp(fp)
> @@ -58,14 +65,24 @@
>
> return paths.get(loc, loc)
>
> - def write(self, *args):
> + def write(self, *args, **kw):
> for a in args:
> - sys.stdout.write(str(a))
> + #force to string as we sometimes pass objects instead of strings
> + if type(a) != str: a = str(a)
> + if kw:
> + a %= kw
> + #convert to unicode and encode to output
> + sys.stdout.write(a.decode("UTF-8").encode(self.encoding))
>
> - def write_err(self, *args):
> + def write_err(self, *args, **kw):
> sys.stdout.flush()
> for a in args:
> - sys.stderr.write(str(a))
> + #force to string as we sometimes pass objects instead of strings
> + if type(a)!=str: a = str(a)
> + if kw:
> + a %= kw
> + #convert to unicode and encode to output
> + sys.stderr.write(a.decode("UTF-8").encode(self.encoding))
>
> def readline(self):
> return sys.stdin.readline()[:-1]
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list