# HG changeset patch # User Mads Kiilerich # Date 1323358740 -3600 # Node ID 86fc364ca5f811f706144a17fb48a963ae7fe8c8 # Parent 013688350c7d830a06750ce27d5e676fa2309e38 sshrepo: don't quote obviously safe strings (issue2983) This restores compatibility with hg-over-ssh servers that don't parse commandlines as sh does but works ok in the most common cases. diff -r 013688350c7d -r 86fc364ca5f8 mercurial/sshrepo.py --- a/mercurial/sshrepo.py Wed Nov 16 15:29:57 2011 -0600 +++ b/mercurial/sshrepo.py Thu Dec 08 16:39:00 2011 +0100 @@ -5,6 +5,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. +import re from i18n import _ import util, error, wireproto @@ -20,6 +21,8 @@ def _serverquote(s): '''quote a string for the remote shell ... which we assume is sh''' + if re.match(r'[a-zA-Z0-9._\-/]*$', s): + return s return "'%s'" % s.replace("'", "'\\''") class sshrepository(wireproto.wirerepository): diff -r 013688350c7d -r 86fc364ca5f8 tests/test-init.t --- a/tests/test-init.t Wed Nov 16 15:29:57 2011 -0600 +++ b/tests/test-init.t Thu Dec 08 16:39:00 2011 +0100 @@ -105,13 +105,13 @@ output of dummyssh $ cat dummylog - Got arguments 1:user@dummy 2:'hg' init 'remote2' - Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote2' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'remote1' - Got arguments 1:user@dummy 2:'hg' -R 'remote1' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'remote1' - Got arguments 1:user@dummy 2:'hg' init 'remote1' + Got arguments 1:user@dummy 2:hg init remote2 + Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio + Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio + Got arguments 1:user@dummy 2:hg init remote1 + Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio + Got arguments 1:user@dummy 2:hg init remote1 + Got arguments 1:user@dummy 2:hg init remote1 comparing repositories diff -r 013688350c7d -r 86fc364ca5f8 tests/test-ssh.t --- a/tests/test-ssh.t Wed Nov 16 15:29:57 2011 -0600 +++ b/tests/test-ssh.t Thu Dec 08 16:39:00 2011 +0100 @@ -275,27 +275,27 @@ 3fb238f49e8c $ cat dummylog - Got arguments 1:user@dummy 2:'hg' -R 'nonexistent' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '/$TESTTMP/nonexistent' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'local' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/local' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio + Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio + Got arguments 1:user@dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R local serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/local serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1 - Got arguments 1:user@dummy 2:'hg' -R 'remote' serve --stdio - Got arguments 1:user@dummy 2:'hg' init 'a repo' - Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'a repo' serve --stdio + Got arguments 1:user@dummy 2:hg -R remote serve --stdio + Got arguments 1:user@dummy 2:hg init 'a repo' + Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio + Got arguments 1:user@dummy 2:hg -R 'a repo' serve --stdio diff -r 013688350c7d -r 86fc364ca5f8 tests/test-subrepo-relative-path.t --- a/tests/test-subrepo-relative-path.t Wed Nov 16 15:29:57 2011 -0600 +++ b/tests/test-subrepo-relative-path.t Thu Dec 08 16:39:00 2011 +0100 @@ -98,8 +98,8 @@ no changes found $ cat dummylog - Got arguments 1:user@dummy 2:'hg' -R 'cloned' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R 'sub' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/cloned' serve --stdio - Got arguments 1:user@dummy 2:'hg' -R '$TESTTMP/sub' serve --stdio + Got arguments 1:user@dummy 2:hg -R cloned serve --stdio + Got arguments 1:user@dummy 2:hg -R sub serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/cloned serve --stdio + Got arguments 1:user@dummy 2:hg -R $TESTTMP/sub serve --stdio $ rm $BINDIR/ssh