66 > class StdoutWrapper(object): |
66 > class StdoutWrapper(object): |
67 > def __init__(self, stdout): |
67 > def __init__(self, stdout): |
68 > self._file = stdout |
68 > self._file = stdout |
69 > |
69 > |
70 > def write(self, data): |
70 > def write(self, data): |
71 > if data == '47\n': |
71 > if data == b'47\n': |
72 > # latin1 encoding is one %xx (3 bytes) shorter |
72 > # latin1 encoding is one %xx (3 bytes) shorter |
73 > data = '44\n' |
73 > data = b'44\n' |
74 > elif data.startswith('%C3%A6 '): |
74 > elif data.startswith(b'%C3%A6 '): |
75 > # translate to latin1 encoding |
75 > # translate to latin1 encoding |
76 > data = '%%E6 %s' % data[7:] |
76 > data = b'%%E6 %s' % data[7:] |
77 > self._file.write(data) |
77 > self._file.write(data) |
78 > |
78 > |
79 > def __getattr__(self, name): |
79 > def __getattr__(self, name): |
80 > return getattr(self._file, name) |
80 > return getattr(self._file, name) |
81 > |
81 > |
82 > sys.stdout = StdoutWrapper(sys.stdout) |
82 > sys.stdout = StdoutWrapper(getattr(sys.stdout, 'buffer', sys.stdout)) |
83 > sys.stderr = StdoutWrapper(sys.stderr) |
83 > sys.stderr = StdoutWrapper(getattr(sys.stderr, 'buffer', sys.stderr)) |
84 > |
84 > |
85 > myui = ui.ui.load() |
85 > myui = ui.ui.load() |
86 > repo = hg.repository(myui, 'a') |
86 > repo = hg.repository(myui, b'a') |
87 > commands.serve(myui, repo, stdio=True, cmdserver=False) |
87 > commands.serve(myui, repo, stdio=True, cmdserver=False) |
88 > EOF |
88 > EOF |
89 $ echo baz >> b/foo |
89 $ echo baz >> b/foo |
90 $ hg -R b ci -m baz |
90 $ hg -R b ci -m baz |
91 $ hg push -R b -e "\"$PYTHON\" oldhg" ssh://dummy/ --encoding latin1 |
91 $ hg push -R b -e "\"$PYTHON\" oldhg" ssh://dummy/ --encoding latin1 |