Patchwork [6,of,6] fastannotate: pconvert paths from the server for Windows

login
register
mail settings
Submitter Matt Harbison
Date Aug. 22, 2018, 2:55 a.m.
Message ID <66f810d860a7bc5d6f7a.1534906527@Envy>
Download mbox | patch
Permalink /patch/33963/
State Accepted
Headers show

Comments

Matt Harbison - Aug. 22, 2018, 2:55 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1534906148 14400
#      Tue Aug 21 22:49:08 2018 -0400
# Node ID 66f810d860a7bc5d6f7a0cc34a05f04538618ec4
# Parent  78044da31ab9bc0cbd0793bf9bc587271eb74bbf
fastannotate: pconvert paths from the server for Windows

I'm guessing that the right thing to do here is to convert the paths on the
server, but I know this is a WIP, and I don't know where that needs to happen.
I'm just trying to eliminate the malicious path warnings in the tests.
Matt Harbison - Aug. 22, 2018, 3:07 a.m.
On Tue, 21 Aug 2018 22:55:27 -0400, Matt Harbison <mharbison72@gmail.com>  
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1534906148 14400
> #      Tue Aug 21 22:49:08 2018 -0400
> # Node ID 66f810d860a7bc5d6f7a0cc34a05f04538618ec4
> # Parent  78044da31ab9bc0cbd0793bf9bc587271eb74bbf
> fastannotate: pconvert paths from the server for Windows

Giving durin42 a heads up on this.

The remaining failure is an error text divergence where Unix says  
"Directory not empty", and Windows hits a custom error in posix unlink  
emulation[1].  There doesn't seem to be a point in checking for empty if  
unlinking isn't possible at all.  I haven't found the posix *.py code to  
see what it is doing yet.

[1] https://www.mercurial-scm.org/repo/hg/file/4.7/mercurial/win32.py#l599
Yuya Nishihara - Aug. 23, 2018, 10:51 p.m.
On Tue, 21 Aug 2018 22:55:27 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1534906148 14400
> #      Tue Aug 21 22:49:08 2018 -0400
> # Node ID 66f810d860a7bc5d6f7a0cc34a05f04538618ec4
> # Parent  78044da31ab9bc0cbd0793bf9bc587271eb74bbf
> fastannotate: pconvert paths from the server for Windows

These look good, so queued. Thanks.

> I'm guessing that the right thing to do here is to convert the paths on the
> server, but I know this is a WIP, and I don't know where that needs to happen.
> I'm just trying to eliminate the malicious path warnings in the tests.

Perhaps. Even more, maybe we'll have to rethink about the wire protocol?

Patch

diff --git a/hgext/fastannotate/protocol.py b/hgext/fastannotate/protocol.py
--- a/hgext/fastannotate/protocol.py
+++ b/hgext/fastannotate/protocol.py
@@ -15,6 +15,7 @@  from mercurial import (
     extensions,
     hg,
     localrepo,
+    util,
     wireprotov1peer,
     wireprotov1server,
 )
@@ -166,6 +167,8 @@  def clientfetch(repo, paths, lastnodemap
     ui.debug('fastannotate: server returned\n')
     for result in results:
         r = result.result()
+        # TODO: pconvert these paths on the server?
+        r = {util.pconvert(p): v for p, v in r.iteritems()}
         for path in sorted(r):
             # ignore malicious paths
             if not path.startswith('fastannotate/') or '/../' in (path + '/'):