Skip to content
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

Branch mapping not working with quotation mark #292

Closed
ruku320 opened this issue Oct 20, 2022 · 6 comments
Closed

Branch mapping not working with quotation mark #292

ruku320 opened this issue Oct 20, 2022 · 6 comments
Labels
user-support Help to users, can turn into a verfied bug if it turns out to be a problem with fast-export verified-bug A confirmed bug in fast-export

Comments

@ruku320
Copy link

ruku320 commented Oct 20, 2022

I have a branch with the name Feature- 12V Vac "Venom". I have a branch map file to rename this branch with the following mapping:
"Feature- 12V Vac \"Venom\""="Feature-_12V_Vac_Venom"

Branch mapping doesn't seem to recognize the escaped quotes correctly to rename the branch since I get the following error when I run the script to convert the repo:

Feature- 12V Vac "Venom": Exporting simple delta revision 3530/4034 with 0/5/0 added/changed/removed files
Traceback (most recent call last):
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 728, in
sys.exit(hg2git(options.repourl,m,options.marksfile,options.mappingfile,
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 581, in hg2git
c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 372, in export_commit
export_file_contents(ctx,man,changed,hgtags,fn_encoding,plugins)
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 238, in export_file_contents
wr(d)
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 54, in wr
wr_no_nl(msg)
File "C:\git_convert\hg-export-tool-master\fast-export\hg-fast-export.py", line 51, in wr_no_nl
stdout_buffer.write(msg)
BrokenPipeError: [Errno 32] Broken pipe
error!!!!

@frej
Copy link
Owner

frej commented Oct 21, 2022

Fast-export feeds git-fast-import through a pipe. When fast-import dies because of an error and closes its end of the pipe, fast-export crashes when it cannot write to the pipe. As fast export runs asynchronously from fast-import, the actual error that trips up fast-import is not necessarily related to what fast-export outputs to stderr right before the backtrace triggered by the broken pipe.

Git fast-import will have produced a crash log (check the CRASH REPORTS section in git-fast-import's man page) before it died, and that should give you a clue to what's wrong. My guess is that you have a dodgy author or branch name, but probably not the one you think. You didn't provide the full output from fast export, so also check the "Frequent Problems" section in the README, particularly the issue "My mapping file does not seem to work when I rename the branch git fast-import crashes on!" to eliminate that error source.

@frej frej added user-support Help to users, can turn into a verfied bug if it turns out to be a problem with fast-export need-more-info The maintainer waits for a reply from the ticket creator labels Oct 21, 2022
@ruku320
Copy link
Author

ruku320 commented Oct 21, 2022

I am using the unmangled branch name in the map file.

This is what's in the crash log:

fast-import crash report:
fast-import process: 27940
parent process : 1
at 2022-10-21 16:56:46 +0000

fatal: Branch name doesn't conform to GIT standards: refs/heads/Feature- 12V Vac "Venom"

@frej frej added verified-bug A confirmed bug in fast-export patches-welcome The reporter is welcome to submit a patch to fix the reported issue and removed need-more-info The maintainer waits for a reply from the ticket creator labels Oct 22, 2022
@frej
Copy link
Owner

frej commented Oct 22, 2022

It looks like the hack in process_unicode_escape_sequences in hg-fast-export.py has stopped working and what ends in the internal mapping is b'Feature- 12V Vac \\"Venom\\"' and not the b'Feature- 12V Vac "Venom"' we want. @chrisjbillington you came up with this trick, are we so lucky you already have a solution that works on a modern Python?

Unfortunately I have very little time to spend on fast-export, so patches welcome.

@chrisjbillington
Copy link
Contributor

The problem still seems to occur back on Python 2.7 and 3.6, so I'm not sure when it stopped working, or if it never worked as intended (I suspect the latter).

In any case, .encode('unicode-escape') is not doing what we want, it is adding extra escapes for backslashes, such that they round-trip .decode('unicode-escape').encode('unicode-escape'). But we want them to pass through the .encode() unchanged and be interpreted as the character they represent upon .decode().

PR here: #293

@frej frej closed this as completed in 6700b16 Oct 23, 2022
@frej
Copy link
Owner

frej commented Oct 23, 2022

@ruku320, please reopen if @chrisjbillington's patch doesn't resolve the problem. I'll hold off creating a new release for a couple of days until you can confirm that it works for you too (it works in my tests).

@frej frej removed the patches-welcome The reporter is welcome to submit a patch to fix the reported issue label Oct 23, 2022
@ruku320
Copy link
Author

ruku320 commented Oct 24, 2022

I can confirm that the patch fixes the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user-support Help to users, can turn into a verfied bug if it turns out to be a problem with fast-export verified-bug A confirmed bug in fast-export
Projects
None yet
Development

No branches or pull requests

3 participants