Patchwork [1,of,2,V2] chgserver: resolve relative path before sending via system channel

login
register
mail settings
Submitter Jun Wu
Date March 14, 2016, 12:20 p.m.
Message ID <37c1410031153c71a46a.1457958035@x1c>
Download mbox | patch
Permalink /patch/13861/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Jun Wu - March 14, 2016, 12:20 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1457954584 0
#      Mon Mar 14 11:23:04 2016 +0000
# Node ID 37c1410031153c71a46a467e6c94af16a7266d02
# Parent  ade330deb39a4d2b0bfe044196c87fc4c5fd69b2
chgserver: resolve relative path before sending via system channel

The chgserver may have a different cwd from the client because of the side
effect of "--cwd" and other possible os.chdir done by extensions. Therefore
relative paths can be misunderstood by the client.

This patch solves it by expanding relative cwd path to absolute one before
sending them via the 'S' channel. It can help chg to pass a testcase in
test-alias.t later.
Yuya Nishihara - March 14, 2016, 3:08 p.m.
On Mon, 14 Mar 2016 12:20:35 +0000, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1457954584 0
> #      Mon Mar 14 11:23:04 2016 +0000
> # Node ID 37c1410031153c71a46a467e6c94af16a7266d02
> # Parent  ade330deb39a4d2b0bfe044196c87fc4c5fd69b2
> chgserver: resolve relative path before sending via system channel

Nice. Queued this, thanks.

Patch

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -314,7 +314,7 @@ 
         self.channel = channel
 
     def __call__(self, cmd, environ, cwd):
-        args = [util.quotecommand(cmd), cwd or '.']
+        args = [util.quotecommand(cmd), os.path.abspath(cwd or '.')]
         args.extend('%s=%s' % (k, v) for k, v in environ.iteritems())
         data = '\0'.join(args)
         self.out.write(struct.pack('>cI', self.channel, len(data)))