tests/test-mv-cp-st-diff
author Henrik Stuart <henrik.stuart@edlund.dk>
Tue, 12 May 2009 15:50:44 +0200
changeset 8364 fa901423ac23
parent 6425 2d9328a2f81f
child 8518 3f4f14eab085
permissions -rwxr-xr-x
windows: avoid deleting non-empty reparse points If a hg repository including working directory is a reparse point (directory symlinked or a junction point), then using os.removedirs will remove the reparse point erroneously. This is fixed by only removing directories if they are empty.
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
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
show()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    29
    echo "- $2: $1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    30
    hg st -C $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    32
    hg diff --git $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
}
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
6282
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    36
count=0
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
# 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
    38
# $1 - first commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
# $2 - second commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
# $3 - working dir action
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
# $4 - test description
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
tb()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
    hg co -q -C 0
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
6282
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    46
    add a $count
709652cd7bff test-mv-cp-st-diff: avoid linkrev collisions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 6278
diff changeset
    47
    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
    48
    hg ci -m "t0"
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    49
    $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    50
    hg ci -m "t1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
    $2
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
    hg ci -m "t2"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
    $3
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    55
    echo "** $4 **"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    56
    echo "** $1 / $2 / $3"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    57
    show "" "working to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
    show "--rev 0" "working to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    59
    show "--rev 2" "working to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    60
    show "--rev 0 --rev ." "root to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    61
    show "--rev . --rev 0" "parent to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    62
    show "--rev 2 --rev ." "branch to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    63
    show "--rev . --rev 2" "parent to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    64
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    65
}
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    66
6425
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    67
6278
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    68
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
    69
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
    70
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
    71
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
    72
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
    73
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
    74
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
    75
2d9328a2f81f copies: skip directory rename checks when not merging
Matt Mackall <mpm@selenic.com>
parents: 6286
diff changeset
    76
tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move"