2019-07-18 06:59:57 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2020-02-01 02:19:49 +03:00
|
|
|
from testutil.dott import sh, testtmp # noqa: F401
|
2020-01-31 05:40:49 +03:00
|
|
|
|
|
|
|
|
2019-07-18 06:59:57 +03:00
|
|
|
sh % "cat" << r"""
|
|
|
|
[extensions]
|
|
|
|
checkmessagehook=
|
|
|
|
""" >> "$HGRCPATH"
|
|
|
|
|
|
|
|
# Build up a repo
|
|
|
|
|
2019-10-29 05:11:29 +03:00
|
|
|
sh % "hg init repo" == ""
|
2019-07-18 06:59:57 +03:00
|
|
|
sh % "cd repo"
|
|
|
|
sh % "touch a"
|
2019-10-01 02:51:26 +03:00
|
|
|
sh % 'hg commit -A -l "$TESTDIR/ctrlchar-msg.txt"' == r"""
|
2019-07-18 06:59:57 +03:00
|
|
|
adding a
|
|
|
|
non-printable characters in commit message
|
|
|
|
Line 5: 'This has a sneaky ctrl-A: \x01'
|
|
|
|
Line 6: 'And this has esc: \x1b'
|
|
|
|
abort: pretxncommit.checkmessage hook failed
|
|
|
|
[255]"""
|
2019-10-01 02:51:26 +03:00
|
|
|
sh % 'hg commit -A -l "$TESTDIR/perfectlyok-msg.txt"' == "adding a"
|
2019-07-18 06:59:57 +03:00
|
|
|
sh % "hg log -r ." == r"""
|
2020-07-21 03:23:52 +03:00
|
|
|
commit: d9cf9881be7b
|
2019-07-18 06:59:57 +03:00
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: This commit message is perfectly OK, and has no sneaky control characters."""
|
2019-10-29 05:11:29 +03:00
|
|
|
|
|
|
|
# Try force adding a non-printable character
|
|
|
|
sh % "touch b"
|
|
|
|
sh % 'hg commit -A -l "$TESTDIR/ctrlchar-msg.txt" --config checkmessage.allownonprintable=True' == "adding b"
|