tests/test-resolve
author Renato Cunha <renatoc@gmail.com>
Tue, 03 Aug 2010 13:52:48 -0300
changeset 11748 37a70a784397
parent 11451 51021f4c80b5
permissions -rwxr-xr-x
py3kcompat: added a "compatibility layer" for py3k This patch adds some ugly constructs. The first of them is bytesformatter, a function that formats strings like when '%' is called. The main motivation for this function is py3k's strange behavior: >>> 'foo %s' % b'bar' "foo b'bar'" >>> b'foo %s' % b'bar' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes' >>> b'foo %s' % 'bar' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'str' In other words, if we can't format bytes with bytes, and recall that all mercurial strings will be converted by a fixer, then things will break badly if we don't take a similar approach. The other addition with this patch is that the os.environ dictionary is monkeypatched to have bytes items. Hopefully this won't be needed in the future, as python 3.2 might get a os.environb dictionary that holds bytes items.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7734
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     1
#!/bin/sh
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     2
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     3
# test that a commit clears the merge state.
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     4
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     5
hg init repo
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     6
cd repo
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     7
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
     8
echo foo > file
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7734
diff changeset
     9
hg commit -Am 'add file'
7734
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    10
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    11
echo bar >> file
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7734
diff changeset
    12
hg commit -Am 'append bar'
7734
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    13
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    14
echo % create a second head
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    15
hg up -C 0
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    16
echo baz >> file
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7734
diff changeset
    17
hg commit -Am 'append baz'
7734
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    18
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    19
echo % failing merge
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    20
HGMERGE=internal:fail hg merge
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    21
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    22
echo resolved > file
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    23
hg resolve -m file
8167
6c82beaaa11a tests: removed redundant "-d '0 0'" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7734
diff changeset
    24
hg commit -m 'resolved'
7734
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    25
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    26
echo % resolve -l, should be empty
9f73bddb9d0b reset mergestate after commit
Martin Geisler <mg@daimi.au.dk>
parents:
diff changeset
    27
hg resolve -l
11451
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    28
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    29
# test crashed merge with empty mergestate
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    30
mkdir .hg/merge
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    31
touch .hg/merge/state
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    32
echo % resolve -l, should be empty
51021f4c80b5 resolve: do not crash on empty mergestate
Martin Geisler <mg@lazybytes.net>
parents: 8167
diff changeset
    33
hg resolve -l