mirror of
https://github.com/frej/fast-export.git
synced 2025-11-03 17:55:49 +01:00
When Plugins are used in a repository that contains largefiles,
the following exception is thrown as soon as the first largefile
is converted:
```
Traceback (most recent call last):
File "fast-export/hg-fast-export.py", line 728, in <module>
sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
File "fast-export/hg-fast-export.py", line 581, in hg2git
c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
File "fast-export/hg-fast-export.py", line 366, in export_commit
export_file_contents(ctx,man,modified,hgtags,fn_encoding,plugins)
File "fast-export/hg-fast-export.py", line 222, in export_file_contents
file_data = {'filename':filename,'file_ctx':file_ctx,'data':d}
UnboundLocalError: local variable 'file_ctx' referenced before assignment
```
This commit fixes the error by:
* initializing the file_ctx before the largefile handling takes place
* Providing a new `is_largefile` value for plugins so they can detect
if largefile handling was applied (and therefore the file_ctx
object may no longer be in sync with the git version of the file)
70 lines
1.4 KiB
Bash
Executable File
70 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2023 Felipe Contreras
|
|
# Copyright (c) 2023 Frej Drejhammar
|
|
# Copyright (c) 2025 Günther Nußmüller
|
|
#
|
|
# Check that plugin invocation works with largefiles.
|
|
# This test uses the echo_file_data_test_plugin to verify that the
|
|
# file data is passed correctly, including the largefile status.
|
|
#
|
|
|
|
test_description='Largefiles and plugin test'
|
|
|
|
. "${SHARNESS_TEST_SRCDIR-$(dirname "$0")/sharness}"/sharness.sh || exit 1
|
|
|
|
|
|
git_create() {
|
|
git init -q "$1" &&
|
|
git -C "$1" config core.ignoreCase false
|
|
}
|
|
|
|
git_convert() {
|
|
(
|
|
cd "$2" &&
|
|
hg-fast-export.sh --repo "../$1" \
|
|
-s --hgtags -n \
|
|
--plugin ../../plugins/echo_file_data_test_plugin
|
|
)
|
|
}
|
|
|
|
setup() {
|
|
cat > "$HOME"/.hgrc <<-EOF
|
|
[ui]
|
|
username = Grevious Bodily Harmsworth <gbh@example.com>
|
|
[extensions]
|
|
largefiles =
|
|
EOF
|
|
}
|
|
|
|
commit0() {
|
|
(
|
|
cd hgrepo &&
|
|
echo "a_file" > a.txt &&
|
|
echo "large" > b.txt
|
|
hg add a.txt &&
|
|
hg add --large b.txt &&
|
|
hg commit -d "2023-03-17 01:00Z" -m "r0"
|
|
)
|
|
}
|
|
|
|
setup
|
|
|
|
test_expect_success 'largefile and plugin' '
|
|
test_when_finished "rm -rf hgrepo gitrepo" &&
|
|
|
|
(
|
|
hg init hgrepo &&
|
|
commit0
|
|
) &&
|
|
git_create gitrepo &&
|
|
git_convert hgrepo gitrepo &&
|
|
|
|
git -C gitrepo fast-export --all > actual &&
|
|
|
|
test_cmp "$SHARNESS_TEST_DIRECTORY"/largefile_plugin.expected actual &&
|
|
test_cmp "$SHARNESS_TEST_DIRECTORY"/largefile_plugin_file_info.expected gitrepo/largefile_info.txt
|
|
'
|
|
|
|
test_done
|