tests/test-mq-missingfiles
author Martin Geisler <mg@lazybytes.net>
Wed, 20 May 2009 00:52:46 +0200
changeset 8527 f9a80054dd3c
parent 7506 abd2bc899d86
permissions -rwxr-xr-x
use 'x is None' instead of 'x == None' The built-in None object is a singleton and it is therefore safe to compare memory addresses with is. It is also faster, how much depends on the object being compared. For a simple type like str I get: | s = "foo" | s = None ----------+-----------+---------- s == None | 0.25 usec | 0.21 usec s is None | 0.17 usec | 0.17 usec
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5581
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     3
# Test issue835:
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     4
# qpush fails immediately when patching a missing file, but
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     5
# remaining added files are still created empty which will
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     6
# trick a future qrefresh.
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     7
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     8
cat > writelines.py <<EOF
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     9
import sys
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    10
path = sys.argv[1]
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    11
args = sys.argv[2:]
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    12
assert (len(args) % 2) == 0
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    13
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    14
f = file(path, 'wb')
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    15
for i in xrange(len(args)/2):
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    16
   count, s = args[2*i:2*i+2]
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    17
   count = int(count)
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    18
   s = s.decode('string_escape')
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    19
   f.write(s*count)
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    20
f.close()
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    21
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    22
EOF
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    23
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    24
echo "[extensions]" >> $HGRCPATH
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    25
echo "mq=" >> $HGRCPATH
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    26
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    27
hg init normal
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    28
cd normal
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    29
python ../writelines.py b 10 'a\n'
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    30
hg ci -Am addb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    31
echo a > a
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    32
python ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    33
echo c > c
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    34
hg add a c
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    35
hg qnew -f changeb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    36
hg qpop
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
hg rm b
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    38
hg ci -Am rmb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    39
echo % push patch with missing target
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    40
hg qpush
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    41
echo % display added files
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    42
cat a
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    43
cat c
5652
e90e72c6b4c7 patch: write rej files for missing targets (issue 853)
Patrick Mezard <pmezard@gmail.com>
parents: 5581
diff changeset
    44
echo % display rejections
e90e72c6b4c7 patch: write rej files for missing targets (issue 853)
Patrick Mezard <pmezard@gmail.com>
parents: 5581
diff changeset
    45
cat b.rej
5581
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    46
cd ..
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    47
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    48
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    49
echo "[diff]" >> $HGRCPATH
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    50
echo "git=1" >> $HGRCPATH
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    51
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    52
hg init git
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    53
cd git
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    54
python ../writelines.py b 1 '\x00'
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    55
hg ci -Am addb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    56
echo a > a
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    57
python ../writelines.py b 1 '\x01' 1 '\x00'
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    58
echo c > c
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    59
hg add a c
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    60
hg qnew -f changeb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    61
hg qpop
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    62
hg rm b
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    63
hg ci -Am rmb
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    64
echo % push git patch with missing target
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    65
hg qpush 2>&1 | sed -e 's/b:.*/b: No such file or directory/'
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    66
hg st
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    67
echo % display added files
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    68
cat a
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    69
cat c
5652
e90e72c6b4c7 patch: write rej files for missing targets (issue 853)
Patrick Mezard <pmezard@gmail.com>
parents: 5581
diff changeset
    70
echo % display rejections
e90e72c6b4c7 patch: write rej files for missing targets (issue 853)
Patrick Mezard <pmezard@gmail.com>
parents: 5581
diff changeset
    71
cat b.rej
5581
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    72
cd ..
8a8c341bd292 mq: missing target files do not make qpush to fail immediately (issue 835)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    73
7506
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    74
echo % test push creating directory during git copy or rename
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    75
hg init missingdir
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    76
cd missingdir
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    77
echo a > a
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    78
hg ci -Am adda
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    79
mkdir d
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    80
hg copy a d/a2
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    81
hg mv a d/a
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    82
hg qnew -g -f patch
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    83
hg qpop
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    84
hg qpush
abd2bc899d86 test-mq-missing: add test for directory creation on git copy
Patrick Mezard <pmezard@gmail.com>
parents: 5652
diff changeset
    85
cd ..