Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
d8fa35c2
Commit
d8fa35c2
authored
13 years ago
by
kiilerix
Browse files
Options
Downloads
Patches
Plain Diff
ssh: quote remote paths (issue2983)
parent
5a773356
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
mercurial/sshrepo.py
+11
-7
11 additions, 7 deletions
mercurial/sshrepo.py
tests/test-init.t
+7
-7
7 additions, 7 deletions
tests/test-init.t
tests/test-ssh.t
+30
-19
30 additions, 19 deletions
tests/test-ssh.t
tests/test-subrepo-relative-path.t
+4
-4
4 additions, 4 deletions
tests/test-subrepo-relative-path.t
with
52 additions
and
37 deletions
mercurial/sshrepo.py
+
11
−
7
View file @
d8fa35c2
...
...
@@ -18,6 +18,10 @@
if
self
.
repo
:
self
.
release
()
def
_serverquote
(
s
):
'''
quote a string for the remote shell ... which we assume is sh
'''
return
"'
%s
'"
%
s
.
replace
(
"'"
,
"'
\\
''"
)
class
sshrepository
(
wireproto
.
wirerepository
):
def
__init__
(
self
,
ui
,
path
,
create
=
False
):
self
.
_url
=
path
...
...
@@ -40,9 +44,9 @@
args
=
util
.
sshargs
(
sshcmd
,
self
.
host
,
self
.
user
,
self
.
port
)
if
create
:
cmd
=
'
%s %s
"
%s
init %s
"'
cmd
=
cmd
%
(
sshcmd
,
args
,
remotecmd
,
self
.
path
)
cmd
=
'
%s %s %s
'
%
(
sshcmd
,
args
,
util
.
shellquote
(
"
%s init %s
"
%
(
_serverquote
(
remotecmd
),
_serverquote
(
self
.
path
))))
ui
.
note
(
_
(
'
running %s
\n
'
)
%
cmd
)
res
=
util
.
system
(
cmd
)
if
res
!=
0
:
...
...
@@ -57,7 +61,8 @@
# cleanup up previous run
self
.
cleanup
()
cmd
=
'
%s %s
"
%s -R %s serve --stdio
"'
cmd
=
cmd
%
(
sshcmd
,
args
,
remotecmd
,
self
.
path
)
cmd
=
'
%s %s %s
'
%
(
sshcmd
,
args
,
util
.
shellquote
(
"
%s -R %s serve --stdio
"
%
(
_serverquote
(
remotecmd
),
_serverquote
(
self
.
path
))))
ui
.
note
(
_
(
'
running %s
\n
'
)
%
cmd
)
cmd
=
util
.
quotecommand
(
cmd
)
...
...
@@ -63,5 +68,4 @@
cmd
=
util
.
quotecommand
(
cmd
)
ui
.
note
(
_
(
'
running %s
\n
'
)
%
cmd
)
self
.
pipeo
,
self
.
pipei
,
self
.
pipee
=
util
.
popen3
(
cmd
)
# skip any noise generated by remote shell
...
...
This diff is collapsed.
Click to expand it.
tests/test-init.t
+
7
−
7
View file @
d8fa35c2
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
tests/test-ssh.t
+
30
−
19
View file @
d8fa35c2
...
...
@@ -266,4 +266,12 @@
[
255
]
$
cd
..
Test
remote
paths
with
spaces
(
issue2983
):
$
hg
init
--
ssh
"
python
$TESTDIR
/dummyssh
"
"
ssh://user
@dummy
/a repo
"
$
hg
-
R
'
a repo
'
tag
tag
$
hg
id
--
ssh
"
python
$TESTDIR
/dummyssh
"
"
ssh://user
@dummy
/a repo
"
3
fb238f49e8c
$
cat
dummylog
...
...
@@ -269,11 +277,11 @@
$
cat
dummylog
Got
arguments
1
:
user@dummy
2
:
hg
-
R
nonexistent
serve
--
stdio
Got
arguments
1
:
user@dummy
2
:
hg
-
R
/$TESTTMP/non
existent
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
...
...
@@ -279,11 +287,11 @@
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
=
1383141674
ec756a6056f6a9097618482fe0f4a6
HG_SOURCE
=
serve
HG_URL
=
remote:ssh:127
.0.0.1
...
...
@@ -289,2 +297,5 @@
changegroup
-
in
-
remote
hook:
HG_NODE
=
1383141674
ec756a6056f6a9097618482fe0f4a6
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
'
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
This diff is collapsed.
Click to expand it.
tests/test-subrepo-relative-path.t
+
4
−
4
View file @
d8fa35c2
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment