Files
Fast-Export/t/main.t
Frank Zingsheim bd707b5d6e Fix: Largefiles ignored #141
Import mercurial large files as ordinary files into git

The basic idea to this fix is based on
https://github.com/planestraveler/fast-export/tree/add-lfs-support-v2
from PR #65

Closes #141
2025-03-29 18:39:27 +01:00

145 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2023 Felipe Contreras
#
test_description='Main tests'
. "${SHARNESS_TEST_SRCDIR-$(dirname "$0")/sharness}"/sharness.sh || exit 1
check() {
echo "$3" > expected &&
git -C "$1" show -q --format='%s' "$2" > actual &&
test_cmp expected actual
}
git_clone() {
(
git init -q "$2" &&
cd "$2" &&
git config core.ignoreCase false &&
hg-fast-export.sh --repo "../$1"
)
}
setup() {
cat > "$HOME"/.hgrc <<-EOF
[ui]
username = H G Wells <wells@example.com>
EOF
}
setup
test_expect_success 'basic' '
test_when_finished "rm -rf hgrepo gitrepo" &&
(
hg init hgrepo &&
cd hgrepo &&
echo zero > content &&
hg add content &&
hg commit -m zero
) &&
git_clone hgrepo gitrepo &&
check gitrepo @ zero
'
test_expect_success 'merge' '
test_when_finished "rm -rf hgrepo gitrepo" &&
(
hg init hgrepo &&
cd hgrepo &&
echo a > content &&
echo a > file1 &&
hg add content file1 &&
hg commit -m "origin" &&
echo b > content &&
echo b > file2 &&
hg add file2 &&
hg rm file1 &&
hg commit -m "right" &&
hg update -r0 &&
echo c > content &&
hg commit -m "left" &&
HGMERGE=true hg merge -r1 &&
hg commit -m "merge"
) &&
git_clone hgrepo gitrepo &&
cat > expected <<-EOF &&
left
c
tree @:
content
file2
EOF
(
cd gitrepo
git show -q --format='%s' @^ &&
git show @:content &&
git show @:
) > actual &&
test_cmp expected actual
'
test_expect_success 'hg large file' '
test_when_finished "rm -rf hgrepo gitrepo" &&
(
hg init hgrepo &&
cd hgrepo &&
echo "[extensions]" >> .hg/hgrc
echo "largefiles =" >> .hg/hgrc
echo a > content &&
echo a > file1 &&
hg add content &&
hg add --large file1 &&
hg commit -m "origin" &&
echo b > content &&
echo b > file2 &&
hg add --large file2 &&
hg rm file1 &&
hg commit -m "right" &&
hg update -r0 &&
echo c > content &&
hg commit -m "left" &&
HGMERGE=true hg merge -r1 &&
hg commit -m "merge"
) &&
git_clone hgrepo gitrepo &&
cat > expected <<-EOF &&
left
c
tree @:
content
file2
EOF
(
cd gitrepo
git show -q --format='%s' @^ &&
git show @:content &&
git show @:
) > actual &&
test_cmp expected actual
'
test_done