tests/test-rename
author Robin Farine <robin.farine@terminus.org>
Thu, 01 Dec 2005 10:48:35 -0600
changeset 1565 4bcbc126b80b
parent 1515 3bd6d27cb81c
child 1633 94c179a92f4a
permissions -rwxr-xr-x
fix rename --after
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
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    18
echo "# rename --after a single file"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    19
mv d1/d11/a1 d2/c
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    20
hg rename --after d1/d11/a1 d2/c
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    21
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    22
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    23
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    24
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
    25
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
    26
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    27
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    28
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    29
echo "# move --after a single file to an existing directory"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    30
mv d1/d11/a1 d2
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    31
hg rename --after d1/d11/a1 d2
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    32
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    33
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    34
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    35
echo "# rename a file using a relative path"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    36
(cd d1/d11; hg rename ../../d2/b e)
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    37
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    38
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    39
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    40
echo "# rename --after a file using a relative path"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    41
(cd d1/d11; mv ../../d2/b e; hg rename --after ../../d2/b e)
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    42
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    43
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    44
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    45
echo "# rename directory d1 as d3"
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    46
hg rename d1/ d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    47
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    48
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    49
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    50
echo "# rename --after directory d1 as d3"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    51
mv d1 d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    52
hg rename --after d1 d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    53
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    54
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    55
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    56
echo "# move a directory using a relative path"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    57
(cd d2; mkdir d3; hg rename ../d1/d11 d3)
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    58
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    59
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    60
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    61
echo "# move --after a directory using a relative path"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    62
(cd d2; mkdir d3; mv ../d1/d11 d3; hg rename --after ../d1/d11 d3)
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    63
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    64
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    65
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    66
echo "# move directory d1/d11 to an existing directory d2 (removes empty d1)"
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    67
hg rename d1/d11/ d2
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    68
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    69
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    70
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    71
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
    72
mkdir d3
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    73
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
    74
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    75
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    76
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    77
echo "# move --after directories d1 and d2 to a new directory d3"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    78
mkdir d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    79
mv d1 d2 d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    80
hg rename --after d1 d2 d3
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    81
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    82
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    83
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    84
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
    85
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
    86
hg rename d1/* d2
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    87
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    88
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
    89
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    90
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    91
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
    92
echo "# directory"
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    93
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
    94
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    95
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
    96
mkdir d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    97
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
    98
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    99
hg update -C
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
   100
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   101
echo "# move --after some files under d1 to d2/d21 (glob)"
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   102
mkdir d2/d21
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   103
mv d1/a d1/d11/a1 d2/d21
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   104
hg rename --after 'glob:d1/**' d2/d21
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   105
hg status
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   106
hg update -C
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
   107
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
   108
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
   109
mkdir d2/d21
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
   110
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
   111
hg status
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
   112
hg update -C
1513
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   113
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   114
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
   115
echo "ca" > d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   116
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
   117
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   118
hg update -C
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   119
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   120
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
   121
echo "ca" > d1/ca
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   122
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
   123
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   124
hg update -C
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   125
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   126
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
   127
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
   128
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
   129
hg status
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
   130
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
   131
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
   132
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
   133
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
   134
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
   135
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
   136
hg update -C