1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
#!/bin/sh
"$TESTDIR/hghave" git || exit 80
echo "[extensions]" >> $HGRCPATH
echo "convert=" >> $HGRCPATH
echo 'hgext.graphlog =' >> $HGRCPATH
GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
count=10
commit()
{
GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
count=`expr $count + 1`
}
mkdir git-repo
cd git-repo
git init-db >/dev/null 2>/dev/null
echo a > a
mkdir d
echo b > d/b
git add a d
commit -a -m t1
# Remove the directory, then try to replace it with a file
# (issue 754)
git rm -f d/b
commit -m t2
echo d > d
git add d
commit -m t3
echo b >> a
commit -a -m t4.1
git checkout -b other HEAD~ >/dev/null 2>/dev/null
echo c > a
echo a >> a
commit -a -m t4.2
git checkout master >/dev/null 2>/dev/null
git pull --no-commit . other > /dev/null 2>/dev/null
commit -m 'Merge branch other'
cd ..
hg convert --datesort git-repo
hg up -q -R git-repo-hg
hg -R git-repo-hg tip -v
count=10
mkdir git-repo2
cd git-repo2
git init-db >/dev/null 2>/dev/null
echo foo > foo
git add foo
commit -a -m 'add foo'
echo >> foo
commit -a -m 'change foo'
git checkout -b Bar HEAD~ >/dev/null 2>/dev/null
echo quux >> quux
git add quux
commit -a -m 'add quux'
echo bar > bar
git add bar
commit -a -m 'add bar'
git checkout -b Baz HEAD~ >/dev/null 2>/dev/null
echo baz > baz
git add baz
commit -a -m 'add baz'
git checkout master >/dev/null 2>/dev/null
git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
commit -m 'Octopus merge'
echo bar >> bar
commit -a -m 'change bar'
git checkout -b Foo HEAD~ >/dev/null 2>/dev/null
echo >> foo
commit -a -m 'change foo'
git checkout master >/dev/null 2>/dev/null
git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
commit -m 'Discard change to foo'
cd ..
glog()
{
hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
}
splitrepo()
{
msg="$1"
files="$2"
opts=$3
echo "% $files: $msg"
prefix=`echo "$files" | sed -e 's/ /-/g'`
fmap="$prefix.fmap"
repo="$prefix.repo"
for i in $files; do
echo "include $i" >> "$fmap"
done
hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
hg up -q -R "$repo"
glog -R "$repo"
hg -R "$repo" manifest --debug
}
echo '% full conversion'
hg -q convert --datesort git-repo2 fullrepo
hg up -q -R fullrepo
glog -R fullrepo
hg -R fullrepo manifest --debug
splitrepo 'octopus merge' 'foo bar baz'
splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
echo
echo '% test binary conversion (issue 1359)'
mkdir git-repo3
cd git-repo3
git init-db >/dev/null 2>/dev/null
python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
git add b
commit -a -m addbinary
cd ..
echo '% convert binary file'
hg convert git-repo3 git-repo3-hg
cd git-repo3-hg
hg up -C
python -c 'print len(file("b", "rb").read())'
cd ..
echo
echo '% test author vs committer'
mkdir git-repo4
cd git-repo4
git init-db >/dev/null 2>/dev/null
echo >> foo
git add foo
commit -a -m addfoo
echo >> foo
GIT_AUTHOR_NAME="nottest"
commit -a -m addfoo2
cd ..
echo '% convert author committer'
hg convert git-repo4 git-repo4-hg
hg -R git-repo4-hg log -v
echo '% --sourceorder should fail'
hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
echo '% damage git repository and convert again'
cat > damage.py <<EOF
import os
for root, dirs, files in os.walk('git-repo4/.git/objects'):
if files:
path = os.path.join(root, files[0])
os.remove(path)
break
EOF
python damage.py
hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
grep 'abort:' | sed 's/abort:.*/abort:/g'
true
|