tests/test-commit.t
changeset 36420 a39126a40be6
parent 35400 8a0cac20a1ad
child 36939 45bfcd16f27e
equal deleted inserted replaced
36419:75c76cee1b1b 36420:a39126a40be6
   642   
   642   
   643 verify pathauditor blocks evil filepaths
   643 verify pathauditor blocks evil filepaths
   644   $ cat > evil-commit.py <<EOF
   644   $ cat > evil-commit.py <<EOF
   645   > from __future__ import absolute_import
   645   > from __future__ import absolute_import
   646   > from mercurial import context, hg, node, ui as uimod
   646   > from mercurial import context, hg, node, ui as uimod
   647   > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
   647   > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
   648   > u = uimod.ui.load()
   648   > u = uimod.ui.load()
   649   > r = hg.repository(u, '.')
   649   > r = hg.repository(u, b'.')
   650   > def filectxfn(repo, memctx, path):
   650   > def filectxfn(repo, memctx, path):
   651   >     return context.memfilectx(repo, memctx, path,
   651   >     return context.memfilectx(repo, memctx, path,
   652   >         '[hooks]\nupdate = echo owned')
   652   >         b'[hooks]\nupdate = echo owned')
   653   > c = context.memctx(r, [r['tip'].node(), node.nullid],
   653   > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
   654   >                    'evil', [notrc], filectxfn, 0)
   654   >                    b'evil', [notrc], filectxfn, 0)
   655   > r.commitctx(c)
   655   > r.commitctx(c)
   656   > EOF
   656   > EOF
   657   $ $PYTHON evil-commit.py
   657   $ $PYTHON evil-commit.py
   658 #if windows
   658 #if windows
   659   $ hg co --clean tip
   659   $ hg co --clean tip
   668   $ hg rollback -f
   668   $ hg rollback -f
   669   repository tip rolled back to revision 2 (undo commit)
   669   repository tip rolled back to revision 2 (undo commit)
   670   $ cat > evil-commit.py <<EOF
   670   $ cat > evil-commit.py <<EOF
   671   > from __future__ import absolute_import
   671   > from __future__ import absolute_import
   672   > from mercurial import context, hg, node, ui as uimod
   672   > from mercurial import context, hg, node, ui as uimod
   673   > notrc = "HG~1/hgrc"
   673   > notrc = b"HG~1/hgrc"
   674   > u = uimod.ui.load()
   674   > u = uimod.ui.load()
   675   > r = hg.repository(u, '.')
   675   > r = hg.repository(u, b'.')
   676   > def filectxfn(repo, memctx, path):
   676   > def filectxfn(repo, memctx, path):
   677   >     return context.memfilectx(repo, memctx, path,
   677   >     return context.memfilectx(repo, memctx, path,
   678   >         '[hooks]\nupdate = echo owned')
   678   >         b'[hooks]\nupdate = echo owned')
   679   > c = context.memctx(r, [r['tip'].node(), node.nullid],
   679   > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
   680   >                    'evil', [notrc], filectxfn, 0)
   680   >                    b'evil', [notrc], filectxfn, 0)
   681   > r.commitctx(c)
   681   > r.commitctx(c)
   682   > EOF
   682   > EOF
   683   $ $PYTHON evil-commit.py
   683   $ $PYTHON evil-commit.py
   684   $ hg co --clean tip
   684   $ hg co --clean tip
   685   abort: path contains illegal component: HG~1/hgrc
   685   abort: path contains illegal component: HG~1/hgrc
   688   $ hg rollback -f
   688   $ hg rollback -f
   689   repository tip rolled back to revision 2 (undo commit)
   689   repository tip rolled back to revision 2 (undo commit)
   690   $ cat > evil-commit.py <<EOF
   690   $ cat > evil-commit.py <<EOF
   691   > from __future__ import absolute_import
   691   > from __future__ import absolute_import
   692   > from mercurial import context, hg, node, ui as uimod
   692   > from mercurial import context, hg, node, ui as uimod
   693   > notrc = "HG8B6C~2/hgrc"
   693   > notrc = b"HG8B6C~2/hgrc"
   694   > u = uimod.ui.load()
   694   > u = uimod.ui.load()
   695   > r = hg.repository(u, '.')
   695   > r = hg.repository(u, b'.')
   696   > def filectxfn(repo, memctx, path):
   696   > def filectxfn(repo, memctx, path):
   697   >     return context.memfilectx(repo, memctx, path,
   697   >     return context.memfilectx(repo, memctx, path,
   698   >         '[hooks]\nupdate = echo owned')
   698   >         b'[hooks]\nupdate = echo owned')
   699   > c = context.memctx(r, [r['tip'].node(), node.nullid],
   699   > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
   700   >                    'evil', [notrc], filectxfn, 0)
   700   >                    b'evil', [notrc], filectxfn, 0)
   701   > r.commitctx(c)
   701   > r.commitctx(c)
   702   > EOF
   702   > EOF
   703   $ $PYTHON evil-commit.py
   703   $ $PYTHON evil-commit.py
   704   $ hg co --clean tip
   704   $ hg co --clean tip
   705   abort: path contains illegal component: HG8B6C~2/hgrc
   705   abort: path contains illegal component: HG8B6C~2/hgrc