tests/test-locate.t
author Augie Fackler <augie@google.com>
Wed, 12 Apr 2017 11:23:55 -0700
branchstable
changeset 32050 77eaf9539499
parent 25636 bfe9ed85f27c
child 35393 4441705b7111
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.

  $ hg init repo
  $ cd repo
  $ echo 0 > a
  $ echo 0 > b
  $ echo 0 > t.h
  $ mkdir t
  $ echo 0 > t/x
  $ echo 0 > t/b
  $ echo 0 > t/e.h
  $ mkdir dir.h
  $ echo 0 > dir.h/foo

  $ hg ci -A -m m
  adding a
  adding b
  adding dir.h/foo
  adding t.h
  adding t/b
  adding t/e.h
  adding t/x

  $ touch nottracked

  $ hg locate a
  a

  $ hg locate NONEXISTENT
  [1]

  $ hg locate
  a
  b
  dir.h/foo
  t.h
  t/b
  t/e.h
  t/x

  $ hg rm a
  $ hg ci -m m

  $ hg locate a
  [1]
  $ hg locate NONEXISTENT
  [1]
  $ hg locate relpath:NONEXISTENT
  [1]
  $ hg locate
  b
  dir.h/foo
  t.h
  t/b
  t/e.h
  t/x
  $ hg locate -r 0 a
  a
  $ hg locate -r 0 NONEXISTENT
  [1]
  $ hg locate -r 0 relpath:NONEXISTENT
  [1]
  $ hg locate -r 0
  a
  b
  dir.h/foo
  t.h
  t/b
  t/e.h
  t/x

-I/-X with relative path should work:

  $ cd t
  $ hg locate
  b
  dir.h/foo
  t.h
  t/b
  t/e.h
  t/x
  $ hg locate -I ../t
  t/b
  t/e.h
  t/x

Issue294: hg remove --after dir fails when dir.* also exists

  $ cd ..
  $ rm -r t

  $ hg rm t/b

  $ hg locate 't/**'
  t/b (glob)
  t/e.h (glob)
  t/x (glob)

  $ hg files
  b
  dir.h/foo (glob)
  t.h
  t/e.h (glob)
  t/x (glob)
  $ hg files b
  b

  $ mkdir otherdir
  $ cd otherdir

  $ hg files path:
  ../b (glob)
  ../dir.h/foo (glob)
  ../t.h (glob)
  ../t/e.h (glob)
  ../t/x (glob)
  $ hg files path:.
  ../b (glob)
  ../dir.h/foo (glob)
  ../t.h (glob)
  ../t/e.h (glob)
  ../t/x (glob)

  $ hg locate b
  ../b (glob)
  ../t/b (glob)
  $ hg locate '*.h'
  ../t.h (glob)
  ../t/e.h (glob)
  $ hg locate path:t/x
  ../t/x (glob)
  $ hg locate 're:.*\.h$'
  ../t.h (glob)
  ../t/e.h (glob)
  $ hg locate -r 0 b
  ../b (glob)
  ../t/b (glob)
  $ hg locate -r 0 '*.h'
  ../t.h (glob)
  ../t/e.h (glob)
  $ hg locate -r 0 path:t/x
  ../t/x (glob)
  $ hg locate -r 0 're:.*\.h$'
  ../t.h (glob)
  ../t/e.h (glob)

  $ hg files
  ../b (glob)
  ../dir.h/foo (glob)
  ../t.h (glob)
  ../t/e.h (glob)
  ../t/x (glob)
  $ hg files .
  [1]

  $ cd ../..