Closed asergunov closed 2 years ago
Same behaviour on non bare repo
I found I had an error
error: cannot lock ref 'refs/heads/TA836_-_Add_checkbox_Export>Output>End_Wall_Profile_Extention': Unable to create 'repo.git/./refs/heads/TA836_-_Add_checkbox_Export>Output>End_Wall_Profile_Extention.lock': Invalid argument
A branch mapping file -B
is probably what you want for handling this. Feel free to close this issue if that resolves your problem.
Thank you for reply @frej You right. This will solve that problem.
Usability wise: Was trying with branches.map (by error message)
"TA836_-_Add_checkbox_Export>Output>End_Wall_Profile_Extention"="TA836_-_Add_checkbox_Export-Output-End_Wall_Profile_Extention"```
But it needs original branch name. And only way to find which branch it was is to remove repo and start again. I mean it will be nice to have kind-of log file somewhere with branch mapping.
Also it's not clear what to do if it will happen again with other branch or other error. Documentation says I should use
hg-reset.sh -R <revision>
But is it any way to find out what revision I should reset to? I mean is the latest successful revision stored anywhere?
Fast-export doesn't update its state files unless git fast-import
terminates successfully, that's why you ended up with a missing hg2git-heads
.
To create a branch-map, your best bet is to ask Mercurial about the name of the branches: hg branches
in the Mercurial repo.
But is it any way to find out what revision I should reset to?
In this case you have not had a single successful conversion so your only solution is to start from scratch. Personally I have never used hg-reset
as it is something I inherited with the project, sorry. I guess you could use the latest Mercurial revision (hg log
) and see what it says.
I want to use this script as migration solution to let developers work with mercurial but let CICD use git. So plan is to run jobs by timer. Job should :
hg pull
<hg-fast-export-magic-here>
git push
So it's something like
SUCCESSFULL_REVISION=0
if [ -f $GIT_REPO_PATH/hg2git-mapping ]; then
SUCCESSFULL_REVISION=$(tac $GIT_REPO_PATH/hg2git-mapping | awk '{print $2; exit}')
fi
(cd $GIT_REPO_PATH && $SCRIPT_DIR/fast-export/hg-fast-export.sh -r $HG_REPO_PATH -A $SCRIPT_DIR/authors.map -B $SCRIPT_DIR/branches.map --hgtags && git push $GIT_REMOTE_REPO --all || echo Rollback to revision $SUCCESSFULL_REVISION && $SCRIPT_DIR/fast-export/hg-reset.sh -R $SUCCESSFULL_REVISION)
But you right again hg-reset.sh
doesn't really work
Rollback to revision 6666
Using last hg repository "<>"
Traceback (most recent call last):
File "<>\fast-export\hg-reset.py", line 118, in <module>
stale,changed,unchanged=get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,options.revision+1)
File "<>\fast-export\hg-reset.py", line 46, in get_branches
del stale[branch]
KeyError: b'<original branch name here>'
So here it should be transformed branch name but used original one https://github.com/frej/fast-export/blob/5b7ca5aaece48e3d05b63a393f5011df1d8ec69d/hg-reset.py#L46
So I'm using full copy of repo
echo "Backup repo..." && cp -r $GIT_REPO_PATH $GIT_REPO_PATH.backup && echo
(\
cd $GIT_REPO_PATH && \
$SCRIPT_DIR/fast-export/hg-fast-export.sh -r $HG_REPO_PATH -A $SCRIPT_DIR/authors.map -B $SCRIPT_DIR/branches.map --hgtags && \
git push $GIT_REMOTE_REPO --all && \
rm -rf $GIT_REPO_PATH.backup \
) || \
(\
echo Rollback... && \
rm -rf $GIT_REPO_PATH && \
mv $GIT_REPO_PATH.backup $GIT_REPO_PATH \
)
To reproduce on 5b7ca5a (current master)
So second call gives me an error