tests/test-fix-pickle.t
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Fri, 26 Apr 2024 19:10:35 +0100
changeset 51626 865efc020c33
parent 45390 7d24201b6447
permissions -rw-r--r--
dirstate: remove the python-side whitelist of allowed matchers This whitelist is too permissive because it allows matchers that contain disallowed ones deep inside, for example through `intersectionmatcher`. It is also too restrictive because it doesn't pass through some of the matchers we support, such as `patternmatcher`. It's also unnecessary because unsupported matchers raise `FallbackError` and we fall back anyway. Making this change makes more of the tests use rust code path, and therefore subtly change behavior. For example, rust status in largefiles repos seems to have strange behavior.

A script that implements uppercasing all letters in a file.

  $ UPPERCASEPY="$TESTTMP/uppercase.py"
  $ cat > $UPPERCASEPY <<EOF
  > import sys
  > from mercurial.utils.procutil import setbinary
  > setbinary(sys.stdin)
  > setbinary(sys.stdout)
  > sys.stdout.write(sys.stdin.read().upper())
  > EOF
  $ TESTLINES="foo\nbar\nbaz\n"
  $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
  FOO
  BAR
  BAZ

This file attempts to test our workarounds for pickle's lack of
support for short reads.

  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > fix =
  > [fix]
  > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
  > uppercase-whole-file:pattern=set:**
  > EOF

  $ hg init repo
  $ cd repo

# Create a file that's large enough that it seems to not fit in
# pickle's buffer, making it use the code path that expects our
# _blockingreader's read() method to return bytes.
  $ echo "some stuff" > file
  $ for i in $($TESTDIR/seq.py 13); do
  >   cat file file > tmp
  >   mv -f tmp file
  > done
  $ hg commit -Am "add large file"
  adding file

Check that we don't get a crash

  $ hg fix -r .
  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-fix.hg (glob)