tests/test-rename
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 11 Nov 2005 15:34:09 -0800
changeset 1530 abfab59fce79
parent 1515 3bd6d27cb81c
child 1565 4bcbc126b80b
permissions -rwxr-xr-x
add a releasefn keyword to lock.lock releasefn is a function that will be executed when the lock is released
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     1
#!/bin/sh
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     3
hg init
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     4
mkdir d1 d1/d11 d2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     5
echo d1/a > d1/a
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     6
echo d1/ba > d1/ba
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     7
echo d1/a1 > d1/d11/a1
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     8
echo d1/b > d1/b
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
     9
echo d2/b > d2/b
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    10
hg add d1/a d1/b d1/ba d1/d11/a1 d2/b
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    11
hg commit -m "1" -d "0 0"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    12
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    13
echo "# rename a single file"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    14
hg rename d1/d11/a1 d2/c
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    15
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    16
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    17
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    18
echo "# move a single file to an existing directory"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    19
hg rename d1/d11/a1 d2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    20
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    21
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    22
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    23
echo "# rename directory d1 as d3"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    24
hg rename d1 d3
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    25
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    26
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    27
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    28
echo "# move directory d1/d11 to an existing directory d2 (removes empty d1)"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    29
hg rename d1/d11 d2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    30
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    31
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    32
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    33
echo "# move directories d1 and d2 to a new directory d3"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    34
mkdir d3
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    35
hg rename d1 d2 d3
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    36
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    37
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    38
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    39
echo "# move everything under directory d1 to existing directory d2, do not"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    40
echo "# overwrite existing files (d2/b)"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    41
hg rename d1/* d2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    42
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    43
diff d1/b d2/b
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    44
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    45
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    46
echo "# attempt to move potentially more than one file into a non-existent"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    47
echo "# directory"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    48
hg rename 'glob:d1/**' dx
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    49
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    50
echo "# move every file under d1 to d2/d21 (glob)"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    51
mkdir d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    52
hg rename 'glob:d1/**' d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    53
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    54
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    55
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    56
echo "# move every file under d1 starting with an 'a' to d2/d21 (regexp)"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    57
mkdir d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    58
hg rename 're:d1/([^a][^/]*/)*a.*' d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    59
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    60
hg update -C
1513
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    61
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    62
echo "# attempt to overwrite an existing file"
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    63
echo "ca" > d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    64
hg rename d1/ba d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    65
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    66
hg update -C
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    67
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    68
echo "# forced overwrite of an existing file"
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    69
echo "ca" > d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    70
hg rename --force d1/ba d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    71
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    72
hg update -C
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    73
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    74
echo "# replace a symlink with a file"
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    75
ln -s ba d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    76
hg rename --force d1/ba d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    77
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
    78
hg update -C
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    79
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    80
echo "# do not copy more than one source file to the same destination file"
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    81
mkdir d3
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    82
hg rename d1/* d2/* d3
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    83
hg status
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
    84
hg update -C