# HG changeset patch # User Yuya Nishihara # Date 1441031355 -32400 # Node ID 7332bf4ae95926090f72ce44f4efbb37985e0aea # Parent fa6ba7c9600be7db9c1f6a0a2cec5a481f49be6b dispatch: error out on invalid -R path even if optionalrepo (issue4805) (BC) Before this patch, repo could be set to None for wrong -R. It's okay for commands that can reject repo=None, but the command server have a problem because: - it accepts repo=None for "unbound" mode - and it reenters dispatch() where repo object is created for cwd by default Test outputs are changed because the error is detected earlier. I think new message is better than ".hg not found". diff -r fa6ba7c9600b -r 7332bf4ae959 mercurial/dispatch.py --- a/mercurial/dispatch.py Tue Sep 01 16:38:52 2015 +0900 +++ b/mercurial/dispatch.py Mon Aug 31 23:29:15 2015 +0900 @@ -890,6 +890,8 @@ except error.RequirementError: raise except error.RepoError: + if rpath and rpath[-1]: # invalid -R path + raise if cmd not in commands.optionalrepo.split(): if (cmd in commands.inferrepo.split() and args and not path): # try to infer -R from command args diff -r fa6ba7c9600b -r 7332bf4ae959 tests/test-clone.t --- a/tests/test-clone.t Tue Sep 01 16:38:52 2015 +0900 +++ b/tests/test-clone.t Mon Aug 31 23:29:15 2015 +0900 @@ -1020,7 +1020,7 @@ $ hg -R a id -r 0 acb14030fe0a $ hg id -R remote -r 0 - abort: there is no Mercurial repository here (.hg not found) + abort: repository remote not found! [255] $ hg --config share.pool=share -q clone -e "python \"$TESTDIR/dummyssh\"" a ssh://user@dummy/remote $ hg -R remote id -r 0 diff -r fa6ba7c9600b -r 7332bf4ae959 tests/test-commandserver.t --- a/tests/test-commandserver.t Tue Sep 01 16:38:52 2015 +0900 +++ b/tests/test-commandserver.t Mon Aug 31 23:29:15 2015 +0900 @@ -589,6 +589,15 @@ 000000000000 tip +don't fall back to cwd if invalid -R path is specified (issue4805): + + $ cd repo + $ hg serve --cmdserver pipe -R ../nonexistent + abort: repository ../nonexistent not found! + [255] + $ cd .. + + unix domain socket: $ cd repo diff -r fa6ba7c9600b -r 7332bf4ae959 tests/test-ssh-bundle1.t --- a/tests/test-ssh-bundle1.t Tue Sep 01 16:38:52 2015 +0900 +++ b/tests/test-ssh-bundle1.t Mon Aug 31 23:29:15 2015 +0900 @@ -43,14 +43,14 @@ repo not found error $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository nonexistent not found! abort: no suitable response from remote hg! [255] non-existent absolute path $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy//`pwd`/nonexistent local - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository /$TESTTMP/nonexistent not found! abort: no suitable response from remote hg! [255] @@ -128,7 +128,7 @@ $ hg pull -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/doesnotexist pulling from ssh://user@dummy/doesnotexist - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository doesnotexist not found! abort: no suitable response from remote hg! [255] diff -r fa6ba7c9600b -r 7332bf4ae959 tests/test-ssh.t --- a/tests/test-ssh.t Tue Sep 01 16:38:52 2015 +0900 +++ b/tests/test-ssh.t Mon Aug 31 23:29:15 2015 +0900 @@ -34,14 +34,14 @@ repo not found error $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository nonexistent not found! abort: no suitable response from remote hg! [255] non-existent absolute path $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/`pwd`/nonexistent local - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository $TESTTMP/nonexistent not found! abort: no suitable response from remote hg! [255] @@ -119,7 +119,7 @@ $ hg pull -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/doesnotexist pulling from ssh://user@dummy/doesnotexist - remote: abort: there is no Mercurial repository here (.hg not found)! + remote: abort: repository doesnotexist not found! abort: no suitable response from remote hg! [255]