tests/test-convert-filemap
author Matt Mackall <mpm@selenic.com>
Wed, 28 Apr 2010 13:45:21 -0500
branchstable
changeset 11031 409c0e4d79e9
parent 10119 bb5ea66789e3
child 11680 7fefef3ce791
permissions -rwxr-xr-x
Merge with i18n
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     1
#!/bin/sh
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     3
HGMERGE=true; export HGMERGE
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     4
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     5
echo '[extensions]' >> $HGRCPATH
10119
bb5ea66789e3 tests: load with "ext =" instead of "hgext.ext ="
Martin Geisler <mg@lazybytes.net>
parents: 9885
diff changeset
     6
echo 'graphlog =' >> $HGRCPATH
bb5ea66789e3 tests: load with "ext =" instead of "hgext.ext ="
Martin Geisler <mg@lazybytes.net>
parents: 9885
diff changeset
     7
echo 'convert =' >> $HGRCPATH
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     8
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     9
glog()
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    10
{
8523
5b7da468531b tests: replace #...# syntax with {...}
Martin Geisler <mg@lazybytes.net>
parents: 6737
diff changeset
    11
    hg glog --template '{rev} "{desc}" files: {files}\n' "$@"
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    12
}
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    13
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    14
hg init source
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    15
cd source
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    16
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    17
echo foo > foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    18
echo baz > baz
9885
b1addc725998 test-convert-filemap: test improved filtering algorithm
Patrick Mezard <pmezard@gmail.com>
parents: 8523
diff changeset
    19
mkdir -p dir/subdir
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    20
echo dir/file >> dir/file
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    21
echo dir/file2 >> dir/file2
9885
b1addc725998 test-convert-filemap: test improved filtering algorithm
Patrick Mezard <pmezard@gmail.com>
parents: 8523
diff changeset
    22
echo dir/subdir/file3 >> dir/subdir/file3
b1addc725998 test-convert-filemap: test improved filtering algorithm
Patrick Mezard <pmezard@gmail.com>
parents: 8523
diff changeset
    23
echo dir/subdir/file4 >> dir/subdir/file4
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    24
hg ci -d '0 0' -qAm '0: add foo baz dir/'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    25
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    26
echo bar > bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    27
echo quux > quux
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    28
hg copy foo copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    29
hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    30
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    31
echo >> foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    32
hg ci -d '2 0' -m '2: change foo'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    33
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    34
hg up -qC 1
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    35
echo >> bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    36
echo >> quux
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    37
hg ci -d '3 0' -m '3: change bar quux'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    38
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    39
hg up -qC 2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    40
hg merge -qr 3
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    41
echo >> bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    42
echo >> baz
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    43
hg ci -d '4 0' -m '4: first merge; change bar baz'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    44
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    45
echo >> bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    46
echo 1 >> baz
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    47
echo >> quux
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    48
hg ci -d '5 0' -m '5: change bar baz quux'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    49
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    50
hg up -qC 4
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    51
echo >> foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    52
echo 2 >> baz
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    53
hg ci -d '6 0' -m '6: change foo baz'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    54
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    55
hg up -qC 5
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    56
hg merge -qr 6
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    57
echo >> bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    58
hg ci -d '7 0' -m '7: second merge; change bar'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    59
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    60
echo >> foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    61
hg ci -m '8: change foo'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    62
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    63
glog
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    64
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    65
echo '% final file versions in this repo:'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    66
hg manifest --debug
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    67
hg debugrename copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    68
echo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    69
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    70
cd ..
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    71
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    72
splitrepo()
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    73
{
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    74
    msg="$1"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    75
    files="$2"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    76
    opts=$3
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    77
    echo "% $files: $msg"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    78
    prefix=`echo "$files" | sed -e 's/ /-/g'`
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    79
    fmap="$prefix.fmap"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    80
    repo="$prefix.repo"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    81
    for i in $files; do
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    82
	echo "include $i" >> "$fmap"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    83
    done
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    84
    hg -q convert $opts --filemap "$fmap" --datesort source "$repo"
6737
7239e06e58e9 context: consistently return p1 context for None
Matt Mackall <mpm@selenic.com>
parents: 5379
diff changeset
    85
    hg up -q -R "$repo"
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    86
    glog -R "$repo"
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    87
    hg -R "$repo" manifest --debug
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    88
}
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    89
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    90
splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    91
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    92
splitrepo 'merges are not merges anymore' bar
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    93
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    94
splitrepo '1st merge is not a merge anymore; 2nd still is' baz
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    95
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    96
splitrepo 'we add additional merges when they are interesting' 'foo quux'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    97
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    98
splitrepo 'partial conversion' 'bar quux' '-r 3'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    99
splitrepo 'complete the partial conversion' 'bar quux'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   100
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   101
rm -r foo.repo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   102
splitrepo 'partial conversion' 'foo' '-r 3'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   103
splitrepo 'complete the partial conversion' 'foo'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   104
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   105
splitrepo 'copied file; source not included in new repo' copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   106
hg --cwd copied.repo debugrename copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   107
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   108
splitrepo 'copied file; source included in new repo' 'foo copied'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   109
hg --cwd foo-copied.repo debugrename copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   110
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   111
cat > renames.fmap <<EOF
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   112
include dir
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   113
exclude dir/file2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   114
rename dir dir2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   115
include foo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   116
include copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   117
rename foo foo2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   118
rename copied copied2
9885
b1addc725998 test-convert-filemap: test improved filtering algorithm
Patrick Mezard <pmezard@gmail.com>
parents: 8523
diff changeset
   119
exclude dir/subdir
b1addc725998 test-convert-filemap: test improved filtering algorithm
Patrick Mezard <pmezard@gmail.com>
parents: 8523
diff changeset
   120
include dir/subdir/file3
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   121
EOF
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   122
hg -q convert --filemap renames.fmap --datesort source renames.repo
6737
7239e06e58e9 context: consistently return p1 context for None
Matt Mackall <mpm@selenic.com>
parents: 5379
diff changeset
   123
hg up -q -R renames.repo
5379
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   124
glog -R renames.repo
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   125
hg -R renames.repo manifest --debug
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   126
hg --cwd renames.repo debugrename copied2
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   127
echo 'copied:'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   128
hg --cwd source cat copied
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   129
echo 'copied2:'
d3e51dc804f8 mercurial_source: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
   130
hg --cwd renames.repo cat copied2