Skip to content

Conversation

@igt-gteubl
Copy link
Contributor

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)

Copy link
Owner

@frej frej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but do I dare asking for a test-case? As largefile support was added before fast-export had a test suite, there isn't much to go on, but ad96531 contains a minimal stand alone test-case. You could copy it and extend it to create and convert largefiles.

setup

test_expect_success 'largefile and plugin' '
# test_when_finished "rm -rf hgrepo gitrepo" &&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something left over from testing? The test should clean up its scratch area when done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang. Sorry I missed this. Apparently the sharness module cleans it up anyway (the working directory stays clean even without this - at least when I run the tests, that's why I missed it), but I'll change it for good measure.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Thank you for your contribution, especially for taking the time to cook up a test case.

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)
@igt-gteubl igt-gteubl force-pushed the gteubl/fix-lf-plugin branch from 0bbcd8e to d77765a Compare August 11, 2025 06:34
@frej frej merged commit 8e1ba28 into frej:master Aug 16, 2025
2 checks passed
@igt-gteubl igt-gteubl deleted the gteubl/fix-lf-plugin branch August 18, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants