tests/test-mv-cp-st-diff
author Matt Mackall <mpm@selenic.com>
Sat, 15 Mar 2008 16:49:27 -0500
changeset 6278 81e7112b07ae
child 6282 709652cd7bff
permissions -rwxr-xr-x
copies: add tests for status -C/diff --git This goes through 42 combinations of copy/rename branch/parent/working dir.
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
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
hg ci -m0
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
add a m1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
hg ci -m1
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 m2
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
hg ci -m2
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
show()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
    echo "- $2: $1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
    hg st -C $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
    echo
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
    hg diff --git $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    28
    echo
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
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
# 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
    32
# $1 - first commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
# $2 - second commit
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
# $3 - working dir action
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
# $4 - test description
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
tb()
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
{
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
    hg co -q -C 0
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
    $1
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
    hg ci -m "t1"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
    $2
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
    hg ci -m "t2"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
    $3
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
    echo "** $4 **"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
    echo "** $1 / $2 / $3"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    48
    show "" "working to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    49
    show "--rev 0" "working to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    50
    show "--rev 2" "working to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
    show "--rev 0 --rev ." "root to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
    show "--rev . --rev 0" "parent to root"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
    show "--rev 2 --rev ." "branch to parent"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
    show "--rev . --rev 2" "parent to branch"
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    55
    echo
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
81e7112b07ae copies: add tests for status -C/diff --git
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    58
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
    59
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
    60
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
    61
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
    62
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
    63
tb "hg cp a b" "hg cp b c" "hg cp c d" "copy chain"