tests/test-mv-cp-st-diff
author Adrian Buehlmann <adrian@cadifra.com>
Fri, 03 Sep 2010 09:12:36 +0200
changeset 12189 fb0c6373ec36
parent 10179 83cfa1baf8ad
permissions -rwxr-xr-x
tests: unify test-empty-group
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
#!/bin/sh
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
add()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
    echo $2 >> $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
}
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
hg init t
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
cd t
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
# set up a boring main branch
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
add a a
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
hg add a
6425
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    14
mkdir x
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    15
add x/x x
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    16
hg add x/x
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
hg ci -m0
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
add a m1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
hg ci -m1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    21
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
add a m2
6425
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    23
add x/y y1
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    24
hg add x/y
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
hg ci -m2
8518
3f4f14eab085 update --clean: do not unlink added files (issue575)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6425
diff changeset
    26
cd ..
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
show()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    29
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    30
    echo "- $2: $1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
    hg st -C $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    32
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
    hg diff --git $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
}
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
6282
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    37
count=0
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
# make a new branch and get diff/status output
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
# $1 - first commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
# $2 - second commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
# $3 - working dir action
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
# $4 - test description
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
tb()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
{
8518
3f4f14eab085 update --clean: do not unlink added files (issue575)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6425
diff changeset
    45
    hg clone t t2 ; cd t2
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
    hg co -q -C 0
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
6282
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    48
    add a $count
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    49
    count=`expr $count + 1`
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    50
    hg ci -m "t0"
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
    $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
    hg ci -m "t1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
    $2
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
    hg ci -m "t2"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    55
    $3
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    56
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    57
    echo "** $4 **"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
    echo "** $1 / $2 / $3"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    59
    show "" "working to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    60
    show "--rev 0" "working to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    61
    show "--rev 2" "working to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    62
    show "--rev 0 --rev ." "root to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    63
    show "--rev . --rev 0" "parent to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    64
    show "--rev 2 --rev ." "branch to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    65
    show "--rev . --rev 2" "parent to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    66
    echo
8518
3f4f14eab085 update --clean: do not unlink added files (issue575)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6425
diff changeset
    67
    cd ..
3f4f14eab085 update --clean: do not unlink added files (issue575)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6425
diff changeset
    68
    rm -rf t2
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    69
}
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    70
6425
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    71
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    72
tb "add a a1" "add a a2" "hg mv a b" "rename in working dir"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    73
tb "add a a1" "add a a2" "hg cp a b" "copy in working dir" 
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    74
tb "hg mv a b" "add b b1" "add b w" "single rename"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    75
tb "hg cp a b" "add b b1" "add a w" "single copy"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    76
tb "hg mv a b" "hg mv b c" "hg mv c d" "rename chain"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    77
tb "hg cp a b" "hg cp b c" "hg cp c d" "copy chain"
6286
90a4329a6b4a filectx.ancestor: use fctx._repopath to cache filelogs (issue1035)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6282
diff changeset
    78
tb "add a a1" "hg mv a b" "hg mv b a" "circular rename"
6425
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    79
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    80
tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move"
10179
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    81
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    82
# Cannot implement unrelated branch with tb
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    83
echo '% testing copies with unrelated branch'
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    84
hg init unrelated
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    85
cd unrelated
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    86
add a a
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    87
hg ci -Am adda
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    88
hg mv a b
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    89
hg ci -m movea
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    90
hg up -C null
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    91
add a a
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    92
hg ci -Am addunrelateda
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    93
echo '% unrelated branch diff'
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    94
hg diff --git -r 2 -r 1
83cfa1baf8ad copies: don't report copies with unrelated branch
Patrick Mezard <pmezard@gmail.com>
parents: 8518
diff changeset
    95
cd ..