Submitter | Jun Wu |
---|---|
Date | March 12, 2016, 5:12 a.m. |
Message ID | <82abdd91e22e218fbf17.1457759556@x1c> |
Download | mbox | patch |
Permalink | /patch/13819/ |
State | Superseded |
Commit | 0747ef2c4ab25e6f0928143217588ad4f6698d9c |
Delegated to: | Yuya Nishihara |
Headers | show |
Comments
On Sat, 12 Mar 2016 05:12:36 +0000, Jun Wu wrote: > # HG changeset patch > # User Jun Wu <quark@fb.com> > # Date 1457754336 0 > # Sat Mar 12 03:45:36 2016 +0000 > # Node ID 82abdd91e22e218fbf17d032cbb15be72252fb28 > # Parent 3bd824c35cd84e5259e65be611a40ad2f8080922 > 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. Ah, good point. > diff --git a/hgext/chgserver.py b/hgext/chgserver.py > --- a/hgext/chgserver.py > +++ b/hgext/chgserver.py > @@ -243,6 +243,8 @@ > csystem = self._csystem > else: > csystem = defaultcsystem > + if cwd is not None and not os.path.isabs(cwd): > + cwd = os.path.realpath(cwd) If the purpose of isabs(cwd) is to avoid the cost of symlink resolution, you can simply use abspath(cwd). Other than that, this looks good to me.
Patch
diff --git a/hgext/chgserver.py b/hgext/chgserver.py --- a/hgext/chgserver.py +++ b/hgext/chgserver.py @@ -243,6 +243,8 @@ csystem = self._csystem else: csystem = defaultcsystem + if cwd is not None and not os.path.isabs(cwd): + cwd = os.path.realpath(cwd) rc = csystem(cmd, env, cwd) if rc and onerr: errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]), @@ -311,7 +313,7 @@ self.channel = channel def __call__(self, cmd, environ, cwd): - args = [util.quotecommand(cmd), cwd or '.'] + args = [util.quotecommand(cmd), cwd or os.getcwd()] 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)))