chgserver: resolve relative path before sending via system channel
authorJun Wu <quark@fb.com>
Mon, 14 Mar 2016 11:23:04 +0000
changeset 28514 0747ef2c4ab2
parent 28513 859af6e78368
child 28515 491eabd0df79
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.
hgext/chgserver.py
--- a/hgext/chgserver.py	Sat Mar 12 13:19:19 2016 -0800
+++ b/hgext/chgserver.py	Mon Mar 14 11:23:04 2016 +0000
@@ -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)))