tests/test-merge1
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Fri, 17 Aug 2007 20:18:05 -0300
changeset 5195 33015dac5df5
parent 4294 ccfe423d3d0a
child 7080 a6477aa893b8
permissions -rwxr-xr-x
convert: fix mercurial_sink.putcommit Changeset 4ebc8693ce72 added some code to putcommit to avoid creating a revision that touches no files, but this can break regular conversions from some repositories: - conceptually, since we're converting a repo, we should try to make the new hg repo as similar as possible to the original repo - we should create a new changeset, even if the original revision didn't touch any files (maybe the commit message had some important bit); - even if a "regular" revision that doesn't touch any file may seem weird (and maybe even broken), it's completely legitimate for a merge revision to not touch any file, and, if we just skip it, the converted repo will end up with wrong history and possibly an extra head. As an example, say the crew and main hg repos are sync'ed. Somebody sends an important patch to the mailing list. Matt quickly applies and pushes it. But at the same time somebody also applies it to crew and pushes it. Suppose the commit message ended up being a bit different (say, there was a typo and somebody didn't fix it) or that the date ended up being different (because of different patch-applying scripts): the changeset hashes will be different, but the manifests will be the same. Since both changesets were pushed to public repos, it's hard to recall them. If both are merged, the manifest from the resulting merge revision will have the exact same contents as its parents - i.e. the merge revision really doesn't touch any file at all. To keep the file filtering stuff "working", the generic code was changed to skip empty revisions if we're filtering the repo, fixing a bug in the process (we want parents[0] instead of tip).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
800
ec85f9e6f3b1 Don't use 'set -x', fix exports, sed and hexdump usage for Solaris.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 749
diff changeset
     1
#!/bin/sh
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
     2
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
     3
cat <<EOF > merge
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
     4
import sys, os
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
     5
print "merging for", os.path.basename(sys.argv[1])
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
     6
EOF
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
     7
HGMERGE="python ../merge"; export HGMERGE
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
     8
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
     9
mkdir t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    10
cd t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    11
hg init
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    12
echo This is file a1 > a
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    13
hg add a
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    14
hg commit -m "commit #0" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    15
echo This is file b1 > b
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    16
hg add b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    17
hg commit -m "commit #1" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    18
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    19
hg update 0
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    20
echo This is file c1 > c
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    21
hg add c
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    22
hg commit -m "commit #2" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    23
echo This is file b1 > b
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    24
echo %% no merges expected
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    25
hg merge 1
3330
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    26
hg diff --nodates
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    27
hg status
3988
9dcf9d45cab8 Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3330
diff changeset
    28
cd ..; rm -r t
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    29
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    30
mkdir t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    31
cd t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    32
hg init
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    33
echo This is file a1 > a
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    34
hg add a
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    35
hg commit -m "commit #0" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    36
echo This is file b1 > b
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    37
hg add b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    38
hg commit -m "commit #1" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    39
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    40
hg update 0
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    41
echo This is file c1 > c
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    42
hg add c
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    43
hg commit -m "commit #2" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    44
echo This is file b2 > b
1581
db10b7114de0 abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1236
diff changeset
    45
echo %% merge should fail
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    46
hg merge 1
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    47
echo %% merge of b expected
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    48
hg merge -f 1
3330
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    49
hg diff --nodates
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    50
hg status
3988
9dcf9d45cab8 Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3330
diff changeset
    51
cd ..; rm -r t
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    52
echo %%
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    53
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    54
mkdir t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    55
cd t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    56
hg init
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    57
echo This is file a1 > a
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    58
hg add a
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    59
hg commit -m "commit #0" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    60
echo This is file b1 > b
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    61
hg add b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    62
hg commit -m "commit #1" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    63
echo This is file b22 > b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    64
hg commit -m "commit #2" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    65
hg update 1
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    66
echo This is file c1 > c
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    67
hg add c
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    68
hg commit -m "commit #3" -d "1000000 0"
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    69
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    70
echo 'Contents of b should be "this is file b1"'
430
5b22029b5aa2 Fix up test-merge1
mpm@selenic.com
parents: 407
diff changeset
    71
cat b
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    72
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    73
echo This is file b22 > b
1581
db10b7114de0 abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1236
diff changeset
    74
echo %% merge fails
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    75
hg merge 2
1236
67a28636ea64 Fix bug with co -C across branches, update tests
mpm@selenic.com
parents: 814
diff changeset
    76
echo %% merge expected!
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    77
hg merge -f 2
3330
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    78
hg diff --nodates
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
    79
hg status
3988
9dcf9d45cab8 Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3330
diff changeset
    80
cd ..; rm -r t
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    81
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    82
mkdir t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    83
cd t
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    84
hg init
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    85
echo This is file a1 > a
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    86
hg add a
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    87
hg commit -m "commit #0" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    88
echo This is file b1 > b
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    89
hg add b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    90
hg commit -m "commit #1" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    91
echo This is file b22 > b
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    92
hg commit -m "commit #2" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    93
hg update 1
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    94
echo This is file c1 > c
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    95
hg add c
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1581
diff changeset
    96
hg commit -m "commit #3" -d "1000000 0"
407
0e0d0670b2bc [PATCH] Merging identical changes from another branch
mpm@selenic.com
parents:
diff changeset
    97
echo This is file b33 > b
1581
db10b7114de0 abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1236
diff changeset
    98
echo %% merge of b should fail
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
    99
hg merge 2
1581
db10b7114de0 abort when merging two heads and repository has local changes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1236
diff changeset
   100
echo %% merge of b expected
4294
ccfe423d3d0a test-merge1: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3988
diff changeset
   101
hg merge -f 2
3330
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
   102
hg diff --nodates
49966b5ab16f fix traceback of extdiff after a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2283
diff changeset
   103
hg status