view tests/test-commit.t @ 30155:b7a966ce89ed

changelog: disable delta chains This patch disables delta chains on changelogs. After this patch, new entries on changelogs - including existing changelogs - will be stored as the fulltext of that data (likely compressed). No delta computation will be performed. An overview of delta chains and data justifying this change follows. Revlogs try to store entries as a delta against a previous entry (either a parent revision in the case of generaldelta or the previous physical revision when not using generaldelta). Most of the time this is the correct thing to do: it frequently results in less CPU usage and smaller storage. Delta chains are most effective when the base revision being deltad against is similar to the current data. This tends to occur naturally for manifests and file data, since only small parts of each tend to change with each revision. Changelogs, however, are a different story. Changelog entries represent changesets/commits. And unless commits in a repository are homogonous (same author, changing same files, similar commit messages, etc), a delta from one entry to the next tends to be relatively large compared to the size of the entry. This means that delta chains tend to be short. How short? Here is the full vs delta revision breakdown on some real world repos: Repo % Full % Delta Max Length hg 45.8 54.2 6 mozilla-central 42.4 57.6 8 mozilla-unified 42.5 57.5 17 pypy 46.1 53.9 6 python-zstandard 46.1 53.9 3 (I threw in python-zstandard as an example of a repo that is homogonous. It contains a small Python project with changes all from the same author.) Contrast this with the manifest revlog for these repos, where 99+% of revisions are deltas and delta chains run into the thousands. So delta chains aren't as useful on changelogs. But even a short delta chain may provide benefits. Let's measure that. Delta chains may require less CPU to read revisions if the CPU time spent reading smaller deltas is less than the CPU time used to decompress larger individual entries. We can measure this via `hg perfrevlog -c -d 1` to iterate a revlog to resolve each revision's fulltext. Here are the results of that command on a repo using delta chains in its changelog and on a repo without delta chains: hg (forward) ! wall 0.407008 comb 0.410000 user 0.410000 sys 0.000000 (best of 25) ! wall 0.390061 comb 0.390000 user 0.390000 sys 0.000000 (best of 26) hg (reverse) ! wall 0.515221 comb 0.520000 user 0.520000 sys 0.000000 (best of 19) ! wall 0.400018 comb 0.400000 user 0.390000 sys 0.010000 (best of 25) mozilla-central (forward) ! wall 4.508296 comb 4.490000 user 4.490000 sys 0.000000 (best of 3) ! wall 4.370222 comb 4.370000 user 4.350000 sys 0.020000 (best of 3) mozilla-central (reverse) ! wall 5.758995 comb 5.760000 user 5.720000 sys 0.040000 (best of 3) ! wall 4.346503 comb 4.340000 user 4.320000 sys 0.020000 (best of 3) mozilla-unified (forward) ! wall 4.957088 comb 4.950000 user 4.940000 sys 0.010000 (best of 3) ! wall 4.660528 comb 4.650000 user 4.630000 sys 0.020000 (best of 3) mozilla-unified (reverse) ! wall 6.119827 comb 6.110000 user 6.090000 sys 0.020000 (best of 3) ! wall 4.675136 comb 4.670000 user 4.670000 sys 0.000000 (best of 3) pypy (forward) ! wall 1.231122 comb 1.240000 user 1.230000 sys 0.010000 (best of 8) ! wall 1.164896 comb 1.160000 user 1.160000 sys 0.000000 (best of 9) pypy (reverse) ! wall 1.467049 comb 1.460000 user 1.460000 sys 0.000000 (best of 7) ! wall 1.160200 comb 1.170000 user 1.160000 sys 0.010000 (best of 9) The data clearly shows that it takes less wall and CPU time to resolve revisions when there are no delta chains in the changelogs, regardless of the direction of traversal. Furthermore, not using a delta chain means that fulltext resolution in reverse is as fast as iterating forward. So not using delta chains on the changelog is a clear CPU win for reading operations. An example of a user-visible operation showing this speed-up is revset evaluation. Here are results for `hg perfrevset 'author(gps) or author(mpm)'`: hg ! wall 1.655506 comb 1.660000 user 1.650000 sys 0.010000 (best of 6) ! wall 1.612723 comb 1.610000 user 1.600000 sys 0.010000 (best of 7) mozilla-central ! wall 17.629826 comb 17.640000 user 17.600000 sys 0.040000 (best of 3) ! wall 17.311033 comb 17.300000 user 17.260000 sys 0.040000 (best of 3) What about 00changelog.i size? Repo Delta Chains No Delta Chains hg 7,033,250 6,976,771 mozilla-central 82,978,748 81,574,623 mozilla-unified 88,112,349 86,702,162 pypy 20,740,699 20,659,741 The data shows that removing delta chains from the changelog makes the changelog smaller. Delta chains are also used during changegroup generation. This operation essentially converts a series of revisions to one large delta chain. And changegroup generation is smart: if the delta in the revlog matches what the changegroup is emitting, it will reuse the delta instead of recalculating it. We can measure the impact removing changelog delta chains has on changegroup generation via `hg perfchangegroupchangelog`: hg ! wall 1.589245 comb 1.590000 user 1.590000 sys 0.000000 (best of 7) ! wall 1.788060 comb 1.790000 user 1.790000 sys 0.000000 (best of 6) mozilla-central ! wall 17.382585 comb 17.380000 user 17.340000 sys 0.040000 (best of 3) ! wall 20.161357 comb 20.160000 user 20.120000 sys 0.040000 (best of 3) mozilla-unified ! wall 18.722839 comb 18.720000 user 18.680000 sys 0.040000 (best of 3) ! wall 21.168075 comb 21.170000 user 21.130000 sys 0.040000 (best of 3) pypy ! wall 4.828317 comb 4.830000 user 4.820000 sys 0.010000 (best of 3) ! wall 5.415455 comb 5.420000 user 5.410000 sys 0.010000 (best of 3) The data shows eliminating delta chains makes the changelog part of changegroup generation slower. This is expected since we now have to compute deltas for revisions where we could recycle the delta before. It is worth putting this regression into context of overall changegroup times. Here is the rough total CPU time spent in changegroup generation for various repos while using delta chains on the changelog: Repo CPU Time (s) CPU Time w/ compression hg 4.50 7.05 mozilla-central 111.1 222.0 pypy 28.68 75.5 Before compression, removing delta chains from the changegroup adds ~4.4% overhead to hg changegroup generation, 1.3% to mozilla-central, and 2.0% to pypy. When you factor in zlib compression, these percentages are roughly divided by 2. While the increased CPU usage for changegroup generation is unfortunate, I think it is acceptable because the percentage is small, server operators (those likely impacted most by this) have other mechanisms to mitigate CPU consumption (namely reducing zlib compression level and pre-generated clone bundles), and because there is room to optimize this in the future. For example, we could use the nullid as the base revision, effectively encoding the full revision for each entry in the changegroup. When doing this, `hg perfchangegroupchangelog` nearly halves: mozilla-unified ! wall 21.168075 comb 21.170000 user 21.130000 sys 0.040000 (best of 3) ! wall 11.196461 comb 11.200000 user 11.190000 sys 0.010000 (best of 3) This looks very promising as a future optimization opportunity. It's worth that the changes in test-acl.t to the changegroup part size. This is because revision 6 in the changegroup had a delta chain of length 2 before and after this patch the base revision is nullrev. When the base revision is nullrev, cg2packer.deltaparent() hardcodes the *previous* revision from the changegroup as the delta parent. This caused the delta in the changegroup to switch base revisions, the delta to change, and the size to change accordingly. While the size increased in this case, I think sizes will remain the same on average, as the delta base for changelog revisions doesn't matter too much (as this patch shows). So, I don't consider this a regression.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 13 Oct 2016 12:50:27 +0200
parents b0811a9fe67c
children d83ca854fa21
line wrap: on
line source

commit date test

  $ hg init test
  $ cd test
  $ echo foo > foo
  $ hg add foo
  $ cat > $TESTTMP/checkeditform.sh <<EOF
  > env | grep HGEDITFORM
  > true
  > EOF
  $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg commit -m ""
  HGEDITFORM=commit.normal.normal
  abort: empty commit message
  [255]
  $ hg commit -d '0 0' -m commit-1
  $ echo foo >> foo
  $ hg commit -d '1 4444444' -m commit-3
  abort: impossible time zone offset: 4444444
  [255]
  $ hg commit -d '1	15.1' -m commit-4
  abort: invalid date: '1\t15.1'
  [255]
  $ hg commit -d 'foo bar' -m commit-5
  abort: invalid date: 'foo bar'
  [255]
  $ hg commit -d ' 1 4444' -m commit-6
  $ hg commit -d '111111111111 0' -m commit-7
  abort: date exceeds 32 bits: 111111111111
  [255]
  $ hg commit -d '-111111111111 0' -m commit-7
  abort: date exceeds 32 bits: -111111111111
  [255]
  $ echo foo >> foo
  $ hg commit -d '1901-12-13 20:45:52 +0000' -m commit-7-2
  $ echo foo >> foo
  $ hg commit -d '-2147483648 0' -m commit-7-3
  $ hg log -T '{rev} {date|isodatesec}\n' -l2
  3 1901-12-13 20:45:52 +0000
  2 1901-12-13 20:45:52 +0000
  $ hg commit -d '1901-12-13 20:45:51 +0000' -m commit-7
  abort: date exceeds 32 bits: -2147483649
  [255]
  $ hg commit -d '-2147483649 0' -m commit-7
  abort: date exceeds 32 bits: -2147483649
  [255]

commit added file that has been deleted

  $ echo bar > bar
  $ hg add bar
  $ rm bar
  $ hg commit -m commit-8
  nothing changed (1 missing files, see 'hg status')
  [1]
  $ hg commit -m commit-8-2 bar
  abort: bar: file not found!
  [255]

  $ hg -q revert -a --no-backup

  $ mkdir dir
  $ echo boo > dir/file
  $ hg add
  adding dir/file (glob)
  $ hg -v commit -m commit-9 dir
  committing files:
  dir/file
  committing manifest
  committing changelog
  committed changeset 4:1957363f1ced

  $ echo > dir.file
  $ hg add
  adding dir.file
  $ hg commit -m commit-10 dir dir.file
  abort: dir: no match under directory!
  [255]

  $ echo >> dir/file
  $ mkdir bleh
  $ mkdir dir2
  $ cd bleh
  $ hg commit -m commit-11 .
  abort: bleh: no match under directory!
  [255]
  $ hg commit -m commit-12 ../dir ../dir2
  abort: dir2: no match under directory!
  [255]
  $ hg -v commit -m commit-13 ../dir
  committing files:
  dir/file
  committing manifest
  committing changelog
  committed changeset 5:a31d8f87544a
  $ cd ..

  $ hg commit -m commit-14 does-not-exist
  abort: does-not-exist: * (glob)
  [255]

#if symlink
  $ ln -s foo baz
  $ hg commit -m commit-15 baz
  abort: baz: file not tracked!
  [255]
#endif

  $ touch quux
  $ hg commit -m commit-16 quux
  abort: quux: file not tracked!
  [255]
  $ echo >> dir/file
  $ hg -v commit -m commit-17 dir/file
  committing files:
  dir/file
  committing manifest
  committing changelog
  committed changeset 6:32d054c9d085

An empty date was interpreted as epoch origin

  $ echo foo >> foo
  $ hg commit -d '' -m commit-no-date
  $ hg tip --template '{date|isodate}\n' | grep '1970'
  [1]

Make sure we do not obscure unknown requires file entries (issue2649)

  $ echo foo >> foo
  $ echo fake >> .hg/requires
  $ hg commit -m bla
  abort: repository requires features unknown to this Mercurial: fake!
  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
  [255]

  $ cd ..


partial subdir commit test

  $ hg init test2
  $ cd test2
  $ mkdir foo
  $ echo foo > foo/foo
  $ mkdir bar
  $ echo bar > bar/bar
  $ hg add
  adding bar/bar (glob)
  adding foo/foo (glob)
  $ HGEDITOR=cat hg ci -e -m commit-subdir-1 foo
  commit-subdir-1
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: added foo/foo


  $ hg ci -m commit-subdir-2 bar

subdir log 1

  $ hg log -v foo
  changeset:   0:f97e73a25882
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       foo/foo
  description:
  commit-subdir-1
  
  

subdir log 2

  $ hg log -v bar
  changeset:   1:aa809156d50d
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       bar/bar
  description:
  commit-subdir-2
  
  

full log

  $ hg log -v
  changeset:   1:aa809156d50d
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       bar/bar
  description:
  commit-subdir-2
  
  
  changeset:   0:f97e73a25882
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       foo/foo
  description:
  commit-subdir-1
  
  
  $ cd ..


dot and subdir commit test

  $ hg init test3
  $ echo commit-foo-subdir > commit-log-test
  $ cd test3
  $ mkdir foo
  $ echo foo content > foo/plain-file
  $ hg add foo/plain-file
  $ HGEDITOR=cat hg ci --edit -l ../commit-log-test foo
  commit-foo-subdir
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: added foo/plain-file


  $ echo modified foo content > foo/plain-file
  $ hg ci -m commit-foo-dot .

full log

  $ hg log -v
  changeset:   1:95b38e3a5b2e
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       foo/plain-file
  description:
  commit-foo-dot
  
  
  changeset:   0:65d4e9386227
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       foo/plain-file
  description:
  commit-foo-subdir
  
  

subdir log

  $ cd foo
  $ hg log .
  changeset:   1:95b38e3a5b2e
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     commit-foo-dot
  
  changeset:   0:65d4e9386227
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  summary:     commit-foo-subdir
  
  $ cd ..
  $ cd ..

Issue1049: Hg permits partial commit of merge without warning

  $ hg init issue1049
  $ cd issue1049
  $ echo a > a
  $ hg ci -Ama
  adding a
  $ echo a >> a
  $ hg ci -mb
  $ hg up 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo b >> a
  $ hg ci -mc
  created new head
  $ HGMERGE=true hg merge
  merging a
  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)

should fail because we are specifying a file name

  $ hg ci -mmerge a
  abort: cannot partially commit a merge (do not specify files or patterns)
  [255]

should fail because we are specifying a pattern

  $ hg ci -mmerge -I a
  abort: cannot partially commit a merge (do not specify files or patterns)
  [255]

should succeed

  $ HGEDITOR="sh $TESTTMP/checkeditform.sh" hg ci -mmerge --edit
  HGEDITFORM=commit.normal.merge
  $ cd ..


test commit message content

  $ hg init commitmsg
  $ cd commitmsg
  $ echo changed > changed
  $ echo removed > removed
  $ hg book activebookmark
  $ hg ci -qAm init

  $ hg rm removed
  $ echo changed >> changed
  $ echo added > added
  $ hg add added
  $ HGEDITOR=cat hg ci -A
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: bookmark 'activebookmark'
  HG: added added
  HG: changed changed
  HG: removed removed
  abort: empty commit message
  [255]

test saving last-message.txt

  $ hg init sub
  $ echo a > sub/a
  $ hg -R sub add sub/a
  $ cat > sub/.hg/hgrc <<EOF
  > [hooks]
  > precommit.test-saving-last-message = false
  > EOF

  $ echo 'sub = sub' > .hgsub
  $ hg add .hgsub

  $ cat > $TESTTMP/editor.sh <<EOF
  > echo "==== before editing:"
  > cat \$1
  > echo "===="
  > echo "test saving last-message.txt" >> \$1
  > EOF

  $ rm -f .hg/last-message.txt
  $ HGEDITOR="sh $TESTTMP/editor.sh" hg commit -S -q
  ==== before editing:
  
  
  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
  HG: Leave message empty to abort commit.
  HG: --
  HG: user: test
  HG: branch 'default'
  HG: bookmark 'activebookmark'
  HG: subrepo sub
  HG: added .hgsub
  HG: added added
  HG: changed .hgsubstate
  HG: changed changed
  HG: removed removed
  ====
  abort: precommit.test-saving-last-message hook exited with status 1 (in subrepo sub)
  [255]
  $ cat .hg/last-message.txt
  
  
  test saving last-message.txt

test that '[committemplate] changeset' definition and commit log
specific template keywords work well

  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset.commit.normal = HG: this is "commit.normal" template
  >     HG: {extramsg}
  >     {if(activebookmark,
  >    "HG: bookmark '{activebookmark}' is activated\n",
  >    "HG: no bookmark is activated\n")}{subrepos %
  >    "HG: subrepo '{subrepo}' is changed\n"}
  > 
  > changeset.commit = HG: this is "commit" template
  >     HG: {extramsg}
  >     {if(activebookmark,
  >    "HG: bookmark '{activebookmark}' is activated\n",
  >    "HG: no bookmark is activated\n")}{subrepos %
  >    "HG: subrepo '{subrepo}' is changed\n"}
  > 
  > changeset = HG: this is customized commit template
  >     HG: {extramsg}
  >     {if(activebookmark,
  >    "HG: bookmark '{activebookmark}' is activated\n",
  >    "HG: no bookmark is activated\n")}{subrepos %
  >    "HG: subrepo '{subrepo}' is changed\n"}
  > EOF

  $ hg init sub2
  $ echo a > sub2/a
  $ hg -R sub2 add sub2/a
  $ echo 'sub2 = sub2' >> .hgsub

  $ HGEDITOR=cat hg commit -S -q
  HG: this is "commit.normal" template
  HG: Leave message empty to abort commit.
  HG: bookmark 'activebookmark' is activated
  HG: subrepo 'sub' is changed
  HG: subrepo 'sub2' is changed
  abort: empty commit message
  [255]

  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset.commit.normal =
  > # now, "changeset.commit" should be chosen for "hg commit"
  > EOF

  $ hg bookmark --inactive activebookmark
  $ hg forget .hgsub
  $ HGEDITOR=cat hg commit -q
  HG: this is "commit" template
  HG: Leave message empty to abort commit.
  HG: no bookmark is activated
  abort: empty commit message
  [255]

  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset.commit =
  > # now, "changeset" should be chosen for "hg commit"
  > EOF

  $ HGEDITOR=cat hg commit -q
  HG: this is customized commit template
  HG: Leave message empty to abort commit.
  HG: no bookmark is activated
  abort: empty commit message
  [255]

  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset = {desc}
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}
  >     HG:
  >     {splitlines(diff()) % 'HG: {line}\n'
  >    }HG:
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}\n
  > EOF
  $ hg status -amr
  M changed
  A added
  R removed
  $ HGEDITOR=cat hg commit -q -e -m "foo bar" changed
  foo bar
  HG: mods=changed
  HG: adds=
  HG: dels=
  HG: files=changed
  HG:
  HG: --- a/changed	Thu Jan 01 00:00:00 1970 +0000
  HG: +++ b/changed	Thu Jan 01 00:00:00 1970 +0000
  HG: @@ -1,1 +1,2 @@
  HG:  changed
  HG: +changed
  HG:
  HG: mods=changed
  HG: adds=
  HG: dels=
  HG: files=changed
  $ hg status -amr
  A added
  R removed
  $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
  M changed
  A 
  R 
  $ hg rollback -q

  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset = {desc}
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}
  >     HG:
  >     {splitlines(diff("changed")) % 'HG: {line}\n'
  >    }HG:
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}
  >     HG:
  >     {splitlines(diff("added")) % 'HG: {line}\n'
  >    }HG:
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}
  >     HG:
  >     {splitlines(diff("removed")) % 'HG: {line}\n'
  >    }HG:
  >     HG: mods={file_mods}
  >     HG: adds={file_adds}
  >     HG: dels={file_dels}
  >     HG: files={files}\n
  > EOF
  $ HGEDITOR=cat hg commit -q -e -m "foo bar" added removed
  foo bar
  HG: mods=
  HG: adds=added
  HG: dels=removed
  HG: files=added removed
  HG:
  HG:
  HG: mods=
  HG: adds=added
  HG: dels=removed
  HG: files=added removed
  HG:
  HG: --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  HG: +++ b/added	Thu Jan 01 00:00:00 1970 +0000
  HG: @@ -0,0 +1,1 @@
  HG: +added
  HG:
  HG: mods=
  HG: adds=added
  HG: dels=removed
  HG: files=added removed
  HG:
  HG: --- a/removed	Thu Jan 01 00:00:00 1970 +0000
  HG: +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  HG: @@ -1,1 +0,0 @@
  HG: -removed
  HG:
  HG: mods=
  HG: adds=added
  HG: dels=removed
  HG: files=added removed
  $ hg status -amr
  M changed
  $ hg parents --template "M {file_mods}\nA {file_adds}\nR {file_dels}\n"
  M 
  A added
  R removed
  $ hg rollback -q

  $ cat >> .hg/hgrc <<EOF
  > # disable customizing for subsequent tests
  > [committemplate]
  > changeset =
  > EOF

  $ cd ..


commit copy

  $ hg init dir2
  $ cd dir2
  $ echo bleh > bar
  $ hg add bar
  $ hg ci -m 'add bar'

  $ hg cp bar foo
  $ echo >> bar
  $ hg ci -m 'cp bar foo; change bar'

  $ hg debugrename foo
  foo renamed from bar:26d3ca0dfd18e44d796b564e38dd173c9668d3a9
  $ hg debugindex bar
     rev    offset  length  ..... linkrev nodeid       p1           p2 (re)
       0         0       6  .....       0 26d3ca0dfd18 000000000000 000000000000 (re)
       1         6       7  .....       1 d267bddd54f7 26d3ca0dfd18 000000000000 (re)

Test making empty commits
  $ hg commit --config ui.allowemptycommit=True -m "empty commit"
  $ hg log -r . -v --stat
  changeset:   2:d809f3644287
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  description:
  empty commit
  
  
  
verify pathauditor blocks evil filepaths
  $ cat > evil-commit.py <<EOF
  > from mercurial import ui, hg, context, node
  > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
  > u = ui.ui()
  > r = hg.repository(u, '.')
  > def filectxfn(repo, memctx, path):
  >     return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
  > c = context.memctx(r, [r['tip'].node(), node.nullid],
  >                    'evil', [notrc], filectxfn, 0)
  > r.commitctx(c)
  > EOF
  $ $PYTHON evil-commit.py
#if windows
  $ hg co --clean tip
  abort: path contains illegal component: .h\xe2\x80\x8cg\\hgrc (esc)
  [255]
#else
  $ hg co --clean tip
  abort: path contains illegal component: .h\xe2\x80\x8cg/hgrc (esc)
  [255]
#endif

  $ hg rollback -f
  repository tip rolled back to revision 2 (undo commit)
  $ cat > evil-commit.py <<EOF
  > from mercurial import ui, hg, context, node
  > notrc = "HG~1/hgrc"
  > u = ui.ui()
  > r = hg.repository(u, '.')
  > def filectxfn(repo, memctx, path):
  >     return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
  > c = context.memctx(r, [r['tip'].node(), node.nullid],
  >                    'evil', [notrc], filectxfn, 0)
  > r.commitctx(c)
  > EOF
  $ $PYTHON evil-commit.py
  $ hg co --clean tip
  abort: path contains illegal component: HG~1/hgrc (glob)
  [255]

  $ hg rollback -f
  repository tip rolled back to revision 2 (undo commit)
  $ cat > evil-commit.py <<EOF
  > from mercurial import ui, hg, context, node
  > notrc = "HG8B6C~2/hgrc"
  > u = ui.ui()
  > r = hg.repository(u, '.')
  > def filectxfn(repo, memctx, path):
  >     return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
  > c = context.memctx(r, [r['tip'].node(), node.nullid],
  >                    'evil', [notrc], filectxfn, 0)
  > r.commitctx(c)
  > EOF
  $ $PYTHON evil-commit.py
  $ hg co --clean tip
  abort: path contains illegal component: HG8B6C~2/hgrc (glob)
  [255]

# test that an unmodified commit template message aborts

  $ hg init unmodified_commit_template
  $ cd unmodified_commit_template
  $ echo foo > foo
  $ hg add foo
  $ hg commit -m "foo"
  $ cat >> .hg/hgrc <<EOF
  > [committemplate]
  > changeset.commit = HI THIS IS NOT STRIPPED
  >     HG: this is customized commit template
  >     HG: {extramsg}
  >     {if(activebookmark,
  >    "HG: bookmark '{activebookmark}' is activated\n",
  >    "HG: no bookmark is activated\n")}{subrepos %
  >    "HG: subrepo '{subrepo}' is changed\n"}
  > EOF
  $ cat > $TESTTMP/notouching.sh <<EOF
  > true
  > EOF
  $ echo foo2 > foo2
  $ hg add foo2
  $ HGEDITOR="sh $TESTTMP/notouching.sh" hg commit
  abort: commit message unchanged
  [255]
  $ cd ..