From 319dba47501d3a0966e0d470705532c6474a47bf Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 5 Oct 2011 12:07:13 -0400 Subject: [PATCH] codereview: fix hg change in Windows console lib/codereview: Unable to use vim for 'hg change' from windows console reload(sys) break workaround for windows. see: http://mercurial.selenic.com/bts/issue2888 http://mercurial.selenic.com/bts/issue1452 Also does not work with backslash paths. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5150054 --- lib/codereview/codereview.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py index 22b08ad0d60..6b512566285 100644 --- a/lib/codereview/codereview.py +++ b/lib/codereview/codereview.py @@ -185,7 +185,9 @@ set_mercurial_encoding_to_utf8() # encoding for all of Python to 'utf-8', not 'ascii'. def default_to_utf8(): import sys + stdout, __stdout__ = sys.stdout, sys.__stdout__ reload(sys) # site.py deleted setdefaultencoding; get it back + sys.stdout, sys.__stdout__ = stdout, __stdout__ sys.setdefaultencoding('utf-8') default_to_utf8() @@ -3216,7 +3218,7 @@ class MercurialVCS(VersionControlSystem): # A path # M path # etc - line = self.status[i] + line = self.status[i].replace('\\', '/') if line[2:] == path: if i+1 < len(self.status) and self.status[i+1][:2] == ' ': return self.status[i:i+2]