-
Notifications
You must be signed in to change notification settings - Fork 266
Fix UnboundLocalError with plugins and largefiles #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
frej
left a comment
There was a problem hiding this 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.
0a05a8e to
0bbcd8e
Compare
t/largefile_plugin.t
Outdated
| setup | ||
|
|
||
| test_expect_success 'largefile and plugin' ' | ||
| # test_when_finished "rm -rf hgrepo gitrepo" && |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
0bbcd8e to
d77765a
Compare
When Plugins are used in a repository that contains largefiles, the following exception is thrown as soon as the first largefile is converted:
This commit fixes the error by:
is_largefilevalue 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)