tests/test-merge-default
author David Greenaway <hg-dev@davidgreenaway.com>
Sat, 03 Apr 2010 11:58:16 +1100
changeset 11060 e6df01776e08
parent 10658 95c7c4b7e67a
permissions -rwxr-xr-x
findrenames: Optimise "addremove -s100" by matching files by their SHA1 hashes. We speed up 'findrenames' for the usecase when a user specifies they want a similarity of 100% by matching files by their exact SHA1 hash value. This reduces the number of comparisons required to find exact matches from O(n^2) to O(n). While it would be nice if we could just use mercurial's pre-calculated SHA1 hash for existing files, this hash includes the file's ancestor information making it unsuitable for our purposes. Instead, we calculate the hash of old content from scratch. The following benchmarks were taken on the current head of crew: addremove 100% similarity: rm -rf *; hg up -C; mv tests tests.new hg --time addremove -s100 --dry-run before: real 176.350 secs (user 128.890+0.000 sys 47.430+0.000) after: real 2.130 secs (user 1.890+0.000 sys 0.240+0.000) addremove 75% similarity: rm -rf *; hg up -C; mv tests tests.new; \ for i in tests.new/*; do echo x >> $i; done hg --time addremove -s75 --dry-run before: real 264.560 secs (user 215.130+0.000 sys 49.410+0.000) after: real 218.710 secs (user 172.790+0.000 sys 45.870+0.000)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     2
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     3
hg init
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     4
echo a > a
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     5
hg commit -A -ma
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     6
10504
d2c1fc440533 test-merge-default: make content of test repo clearer.
Greg Ward <greg-hg@gerg.ca>
parents: 10355
diff changeset
     7
echo b >> a
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     8
hg commit -mb
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
     9
10504
d2c1fc440533 test-merge-default: make content of test repo clearer.
Greg Ward <greg-hg@gerg.ca>
parents: 10355
diff changeset
    10
echo c >> a
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    11
hg commit -mc
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    12
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    13
hg up 1
10504
d2c1fc440533 test-merge-default: make content of test repo clearer.
Greg Ward <greg-hg@gerg.ca>
parents: 10355
diff changeset
    14
echo d >> a
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    15
hg commit -md
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    16
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    17
hg up 1
10504
d2c1fc440533 test-merge-default: make content of test repo clearer.
Greg Ward <greg-hg@gerg.ca>
parents: 10355
diff changeset
    18
echo e >> a
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    19
hg commit -me
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    20
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    21
hg up 1
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    22
echo % should fail because not at a head
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    23
hg merge
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    24
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    25
hg up
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    26
echo % should fail because \> 2 heads
10658
95c7c4b7e67a test-merge-default and check-code.py: No "export x=x" in sh
Mads Kiilerich <mads@kiilerich.com>
parents: 10505
diff changeset
    27
HGMERGE=internal:other; export HGMERGE
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    28
hg merge
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    29
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    30
echo % should succeed
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    31
hg merge 2
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    32
hg commit -mm1
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    33
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    34
echo % should succeed - 2 heads
8834
6d36fc70754e merge: rename -S/--show option to -P/--preview
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 8387
diff changeset
    35
hg merge -P
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    36
hg merge
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    37
hg commit -mm2
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    38
5242
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2915
diff changeset
    39
echo % should fail because at tip
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2915
diff changeset
    40
hg merge
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2915
diff changeset
    41
9cd6578750b9 improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2915
diff changeset
    42
hg up 0
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    43
echo % should fail because 1 head
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    44
hg merge
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    45
10355
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    46
hg up 3
10504
d2c1fc440533 test-merge-default: make content of test repo clearer.
Greg Ward <greg-hg@gerg.ca>
parents: 10355
diff changeset
    47
echo f >> a
10355
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    48
hg branch foobranch
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    49
hg commit -mf
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    50
echo % should fail because merge with other branch
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    51
hg merge
a5576908b589 merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 8834
diff changeset
    52
10505
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    53
# Test for issue2043: ensure that 'merge -P' shows ancestors of 6 that
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    54
# are not ancestors of 7, regardless of where their least common
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    55
# ancestor is.
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    56
echo % merge preview not affected by common ancestor
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    57
hg up -q 7
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    58
hg merge -q -P 6         # expect: 2, 4, 5, 6
b3311e26f94f merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents: 10504
diff changeset
    59
2915
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
    60
true