Patchwork [STABLE] commandserver: drop tell() and seek() from channels (issue5049)

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 19, 2016, 3:52 p.m.
Message ID <148f033b0f1a53a644b1.1453218750@mimosa>
Download mbox | patch
Permalink /patch/12832/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 19, 2016, 3:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1453216080 -32400
#      Wed Jan 20 00:08:00 2016 +0900
# Branch stable
# Node ID 148f033b0f1a53a644b1ed3c85c9feae5b0fdf60
# Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
commandserver: drop tell() and seek() from channels (issue5049)

These operations are obviously invalid for file-like channels because they
will read or write protocol headers.

This patch works around the issue that "hg archive" generates a corrupted
zip file on Windows commandserver because of unusable tell() implementation.
But the problem still occurs without using a commandserver.

  $ hg archive -R not-small-repo -t zip - | cat > invalid.zip

So, this patch cannot fix the issue5049 completely.
Matt Mackall - Jan. 20, 2016, 7:44 p.m.
On Wed, 2016-01-20 at 00:52 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1453216080 -32400
> #      Wed Jan 20 00:08:00 2016 +0900
> # Branch stable
> # Node ID 148f033b0f1a53a644b1ed3c85c9feae5b0fdf60
> # Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
> commandserver: drop tell() and seek() from channels (issue5049)

Queued for stable, thanks.
-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -55,7 +55,7 @@  class channeledoutput(object):
         self.out.flush()
 
     def __getattr__(self, attr):
-        if attr in ('isatty', 'fileno'):
+        if attr in ('isatty', 'fileno', 'tell', 'seek'):
             raise AttributeError(attr)
         return getattr(self.out, attr)
 
@@ -139,7 +139,7 @@  class channeledinput(object):
         return l
 
     def __getattr__(self, attr):
-        if attr in ('isatty', 'fileno'):
+        if attr in ('isatty', 'fileno', 'tell', 'seek'):
             raise AttributeError(attr)
         return getattr(self.in_, attr)