Mercurial > hg
view tests/test-rename-merge2 @ 4363:2e3c54fb79a3
actually port simplemerge to hg
- use bdiff instead of patiencediff; this is a larger change, since
bdiff works on 2 multi-line strings, while patiencediff works on 2
lists;
- rename the main class from Merge3 to Merge3Text and add a Merge3
class that derives from Merge3Text. This new Merge3 class has
the same interface from the original class, so that the tests
still work;
- Merge3 uses util.binary to detect binary data and raises
util.Abort instead of a specific exception;
- don't use the @decorator syntax, to keep python2.3 compatibility;
- the test uses unittest, which likes to print how long it took to
run. This obviously doesn't play too well with hg's test suite,
so we override time.time to fool unittest;
- one test has a different (but still valid) output because of the
different diff algorithm used;
- the TestCase class used by bzr has some extras to help debugging.
test-merge3.py used 2 of them:
- log method to log some data
- assertEqualDiff method to ease viewing diffs of diffs
We add a dummy log method and use regular assertEquals instead of
assertEqualDiff.
- make simplemerge executable and add "#!/usr/bin/env python" header
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 16 Apr 2007 20:17:39 -0300 |
parents | c2c8491a30d6 |
children | 7a7d4937272b |
line wrap: on
line source
#!/bin/sh mkdir -p t cd t cat <<EOF > merge import sys, os f = open(sys.argv[1], "wb") f.write("merge %s %s %s" % (sys.argv[1], sys.argv[2], sys.argv[3])) f.close() EOF HGMERGE="python ../merge"; export HGMERGE # perform a test merge with possible renaming # # args: # $1 = action in local branch # $2 = action in remote branch # $3 = action in working dir # $4 = expected result tm() { mkdir t cd t hg init echo "[merge]" >> .hg/hgrc echo "followcopies = 1" >> .hg/hgrc # base echo base > a echo base > rev # used to force commits hg add a rev hg ci -m "base" -d "0 0" # remote echo remote > rev if [ "$2" != "" ] ; then $2 ; fi hg ci -m "remote" -d "0 0" # local hg co -q 0 echo local > rev if [ "$1" != "" ] ; then $1 ; fi hg ci -m "local" -d "0 0" # working dir echo local > rev if [ "$3" != "" ] ; then $3 ; fi # merge echo "--------------" echo "test L:$1 R:$2 W:$3 - $4" echo "--------------" hg merge -y --debug --traceback echo "--------------" hg status -camC -X rev hg ci -m "merge" -d "0 0" echo "--------------" echo cd .. rm -r t } up() { cp rev $1 hg add $1 2> /dev/null if [ "$2" != "" ] ; then cp rev $2 hg add $2 2> /dev/null fi } uc() { up $1; hg cp $1 $2; } # update + copy um() { up $1; hg mv $1 $2; } nc() { hg cp $1 $2; } # just copy nm() { hg mv $1 $2; } # just move tm "up a " "nc a b" " " "1 get local a to b" tm "nc a b" "up a " " " "2 get rem change to a and b" tm "up a " "nm a b" " " "3 get local a change to b, remove a" tm "nm a b" "up a " " " "4 get remote change to b" tm " " "nc a b" " " "5 get b" tm "nc a b" " " " " "6 nothing" tm " " "nm a b" " " "7 get b" tm "nm a b" " " " " "8 nothing" tm "um a b" "um a b" " " "9 do merge with ancestor in a" #tm "um a c" "um x c" " " "10 do merge with no ancestor" tm "nm a b" "nm a c" " " "11 get c, keep b" tm "nc a b" "up b " " " "12 merge b no ancestor" tm "up b " "nm a b" " " "13 merge b no ancestor" tm "nc a b" "up a b" " " "14 merge b no ancestor" tm "up b " "nm a b" " " "15 merge b no ancestor, remove a" tm "nc a b" "up a b" " " "16 get a, merge b no ancestor" tm "up a b" "nc a b" " " "17 keep a, merge b no ancestor" tm "nm a b" "up a b" " " "18 merge b no ancestor" tm "up a b" "nm a b" " " "19 merge b no ancestor, prompt remove a" tm "up a " "um a b" " " "20 merge a and b to b, remove a" tm "um a b" "up a " " " "21 merge a and b to b" #tm "nm a b" "um x a" " " "22 get a, keep b" tm "nm a b" "up a c" " " "23 get c, keep b"