tests/test-commit.t
changeset 47012 d55b71393907
parent 45906 95c4cca641f6
child 48369 35f1ecd84bd0
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
   644   
   644   
   645   
   645   
   646 verify pathauditor blocks evil filepaths
   646 verify pathauditor blocks evil filepaths
   647   $ cat > evil-commit.py <<EOF
   647   $ cat > evil-commit.py <<EOF
   648   > from __future__ import absolute_import
   648   > from __future__ import absolute_import
   649   > from mercurial import context, hg, node, ui as uimod
   649   > from mercurial import context, hg, ui as uimod
   650   > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
   650   > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
   651   > u = uimod.ui.load()
   651   > u = uimod.ui.load()
   652   > r = hg.repository(u, b'.')
   652   > r = hg.repository(u, b'.')
   653   > def filectxfn(repo, memctx, path):
   653   > def filectxfn(repo, memctx, path):
   654   >     return context.memfilectx(repo, memctx, path,
   654   >     return context.memfilectx(repo, memctx, path,
   655   >         b'[hooks]\nupdate = echo owned')
   655   >         b'[hooks]\nupdate = echo owned')
   656   > c = context.memctx(r, [r.changelog.tip(), node.nullid],
   656   > c = context.memctx(r, [r.changelog.tip(), r.nullid],
   657   >                    b'evil', [notrc], filectxfn, 0)
   657   >                    b'evil', [notrc], filectxfn, 0)
   658   > r.commitctx(c)
   658   > r.commitctx(c)
   659   > EOF
   659   > EOF
   660   $ "$PYTHON" evil-commit.py
   660   $ "$PYTHON" evil-commit.py
   661 #if windows
   661 #if windows
   670 
   670 
   671   $ hg rollback -f
   671   $ hg rollback -f
   672   repository tip rolled back to revision 2 (undo commit)
   672   repository tip rolled back to revision 2 (undo commit)
   673   $ cat > evil-commit.py <<EOF
   673   $ cat > evil-commit.py <<EOF
   674   > from __future__ import absolute_import
   674   > from __future__ import absolute_import
   675   > from mercurial import context, hg, node, ui as uimod
   675   > from mercurial import context, hg, ui as uimod
   676   > notrc = b"HG~1/hgrc"
   676   > notrc = b"HG~1/hgrc"
   677   > u = uimod.ui.load()
   677   > u = uimod.ui.load()
   678   > r = hg.repository(u, b'.')
   678   > r = hg.repository(u, b'.')
   679   > def filectxfn(repo, memctx, path):
   679   > def filectxfn(repo, memctx, path):
   680   >     return context.memfilectx(repo, memctx, path,
   680   >     return context.memfilectx(repo, memctx, path,
   681   >         b'[hooks]\nupdate = echo owned')
   681   >         b'[hooks]\nupdate = echo owned')
   682   > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
   682   > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
   683   >                    b'evil', [notrc], filectxfn, 0)
   683   >                    b'evil', [notrc], filectxfn, 0)
   684   > r.commitctx(c)
   684   > r.commitctx(c)
   685   > EOF
   685   > EOF
   686   $ "$PYTHON" evil-commit.py
   686   $ "$PYTHON" evil-commit.py
   687   $ hg co --clean tip
   687   $ hg co --clean tip
   690 
   690 
   691   $ hg rollback -f
   691   $ hg rollback -f
   692   repository tip rolled back to revision 2 (undo commit)
   692   repository tip rolled back to revision 2 (undo commit)
   693   $ cat > evil-commit.py <<EOF
   693   $ cat > evil-commit.py <<EOF
   694   > from __future__ import absolute_import
   694   > from __future__ import absolute_import
   695   > from mercurial import context, hg, node, ui as uimod
   695   > from mercurial import context, hg, ui as uimod
   696   > notrc = b"HG8B6C~2/hgrc"
   696   > notrc = b"HG8B6C~2/hgrc"
   697   > u = uimod.ui.load()
   697   > u = uimod.ui.load()
   698   > r = hg.repository(u, b'.')
   698   > r = hg.repository(u, b'.')
   699   > def filectxfn(repo, memctx, path):
   699   > def filectxfn(repo, memctx, path):
   700   >     return context.memfilectx(repo, memctx, path,
   700   >     return context.memfilectx(repo, memctx, path,
   701   >         b'[hooks]\nupdate = echo owned')
   701   >         b'[hooks]\nupdate = echo owned')
   702   > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
   702   > c = context.memctx(r, [r[b'tip'].node(), r.nullid],
   703   >                    b'evil', [notrc], filectxfn, 0)
   703   >                    b'evil', [notrc], filectxfn, 0)
   704   > r.commitctx(c)
   704   > r.commitctx(c)
   705   > EOF
   705   > EOF
   706   $ "$PYTHON" evil-commit.py
   706   $ "$PYTHON" evil-commit.py
   707   $ hg co --clean tip
   707   $ hg co --clean tip