tests/test-mq-subrepo-svn.t
author Augie Fackler <augie@google.com>
Wed, 12 Apr 2017 11:23:55 -0700
branchstable
changeset 32050 77eaf9539499
parent 26374 048e41e9a6ac
child 33365 6d88468d435b
permissions -rw-r--r--
dispatch: protect against malicious 'hg serve --stdio' invocations (sec) Some shared-ssh installations assume that 'hg serve --stdio' is a safe command to run for minimally trusted users. Unfortunately, the messy implementation of argument parsing here meant that trying to access a repo named '--debugger' would give the user a pdb prompt, thereby sidestepping any hoped-for sandboxing. Serving repositories over HTTP(S) is unaffected. We're not currently hardening any subcommands other than 'serve'. If your service exposes other commands to users with arbitrary repository names, it is imperative that you defend against repository names of '--debugger' and anything starting with '--config'. The read-only mode of hg-ssh stopped working because it provided its hook configuration to "hg serve --stdio" via --config parameter. This is banned for security reasons now. This patch switches it to directly call ui.setconfig(). If your custom hosting infrastructure relies on passing --config to "hg serve --stdio", you'll need to find a different way to get that configuration into Mercurial, either by using ui.setconfig() as hg-ssh does in this patch, or by placing an hgrc file someplace where Mercurial will read it. mitrandir@fb.com provided some extra fixes for the dispatch code and for hg-ssh in places that I overlooked.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22046
7a9cbb315d84 tests: replace exit 80 with #require
Matt Mackall <mpm@selenic.com>
parents: 17033
diff changeset
     1
#require svn13
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
     2
23172
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     3
  $ cat <<EOF >> $HGRCPATH
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     4
  > [extensions]
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     5
  > mq =
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     6
  > [diff]
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     7
  > nodates = 1
e955549cd045 tests: write hgrc of more than two lines by using shell heredoc
Yuya Nishihara <yuya@tcha.org>
parents: 22947
diff changeset
     8
  > EOF
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
     9
13326
535a891284da test-subrepo-mq-svn.t: correct comment
Kevin Bullock <kbullock@ringworld.org>
parents: 13300
diff changeset
    10
fn to create new repository, and cd into it
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    11
  $ mkrepo() {
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    12
  >     hg init $1
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    13
  >     cd $1
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    14
  >     hg qinit
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    15
  > }
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    16
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    17
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    18
handle svn subrepos safely
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    19
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    20
  $ svnadmin create svn-repo-2499
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    21
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    22
  $ SVNREPOPATH=`pwd`/svn-repo-2499/project
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    23
#if windows
22947
c63a09b6b337 tests: use $PYTHON instead of hardcoding python
Augie Fackler <raf@durin42.com>
parents: 22046
diff changeset
    24
  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    25
#else
22947
c63a09b6b337 tests: use $PYTHON instead of hardcoding python
Augie Fackler <raf@durin42.com>
parents: 22046
diff changeset
    26
  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    27
#endif
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    28
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    29
  $ mkdir -p svn-project-2499/trunk
26374
048e41e9a6ac tests: suppress verbose output of svn transaction
Yuya Nishihara <yuya@tcha.org>
parents: 24471
diff changeset
    30
  $ svn import -qm 'init project' svn-project-2499 "$SVNREPOURL"
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    31
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    32
qnew on repo w/svn subrepo
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    33
  $ mkrepo repo-2499-svn-subrepo
17033
0413f68da85c tests: cleanup of svn url handling
Mads Kiilerich <mads@kiilerich.com>
parents: 16913
diff changeset
    34
  $ svn co "$SVNREPOURL"/trunk sub
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    35
  Checked out revision 1.
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    36
  $ echo 'sub = [svn]sub' >> .hgsub
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    37
  $ hg add .hgsub
13410
1f2b2c33d386 tests: fixes for svn 1.4.2
Matt Mackall <mpm@selenic.com>
parents: 13326
diff changeset
    38
  $ hg status -S -X '**/format'
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    39
  A .hgsub
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    40
  $ hg qnew -m0 0.diff
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    41
  $ cd sub
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    42
  $ echo a > a
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    43
  $ svn add a
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    44
  A         a
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    45
  $ svn st
13410
1f2b2c33d386 tests: fixes for svn 1.4.2
Matt Mackall <mpm@selenic.com>
parents: 13326
diff changeset
    46
  A*    a (glob)
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    47
  $ cd ..
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    48
  $ hg status -S        # doesn't show status for svn subrepos (yet)
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    49
  $ hg qnew -m1 1.diff
24471
1ff35d76421c subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23172
diff changeset
    50
  abort: uncommitted changes in subrepository 'sub'
13300
23bbb5b888ea subrepo: separate out mq+svn subrepo tests
Kevin Bullock <kbullock@ringworld.org>
parents:
diff changeset
    51
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16894
diff changeset
    52
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16894
diff changeset
    53
  $ cd ..