Debian Codegraph @

tests/test-fix-pickle.t

raw
1 A script that implements uppercasing all letters in a file.
2
3 $ UPPERCASEPY="$TESTTMP/uppercase.py"
4 $ cat > $UPPERCASEPY <<EOF
5 > import sys
6 > from mercurial.utils.procutil import setbinary
7 > setbinary(sys.stdin)
8 > setbinary(sys.stdout)
9 > sys.stdout.write(sys.stdin.read().upper())
10 > EOF
11 $ TESTLINES="foo\nbar\nbaz\n"
12 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
13 FOO
14 BAR
15 BAZ
16
17 This file attempts to test our workarounds for pickle's lack of
18 support for short reads.
19
20 $ cat >> $HGRCPATH <<EOF
21 > [extensions]
22 > fix =
23 > [fix]
24 > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
25 > uppercase-whole-file:pattern=set:**
26 > EOF
27
28 $ hg init repo
29 $ cd repo
30
31 # Create a file that's large enough that it seems to not fit in
32 # pickle's buffer, making it use the code path that expects our
33 # _blockingreader's read() method to return bytes.
34 $ echo "some stuff" > file
35 $ for i in $($TESTDIR/seq.py 13); do
36 > cat file file > tmp
37 > mv -f tmp file
38 > done
39 $ hg commit -Am "add large file"
40 adding file
41
42 Check that we don't get a crash
43
44 $ hg fix -r .
45 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-fix.hg (glob)