简体   繁体   中英

Convert mercurial branches into bookmarks while migrating to git

I am trying to migrate a mercurial repo to git while using hg-git. I follow the tutorial here and I stumbled on an issue in the migration step when I push to the git repo. Some branches (who where converted to bookmarks) aren't migrated because they have spaces in their names.

So my solution to that is just to create bookmarks without spaces, I do it with this command (from git bash in win10 x64):

$ hg branches -T {branch}\\n | sed -e 's/.*/"&"/g;p;s/ /_/g;s/"//g' | xargs -d \\n -L 2 sh -c 'hg bookmark -r $0 $1_migrate'

But this fails with the following error:

hg: parse error at 1: unterminated string
("BTSR
  ^ here)
xargs: sh: exited with status 255; aborting

However, if I replace the bookmark command with echo, the output seems ok:

$ hg branches -T {branch}\\n | sed -e 's/.*/"&"/g;p;s/ /_/g;s/"//g' | xargs -d \\n -L 2 sh -c 'echo $0 $1_migrate'
"BTSR UF2" BTSR_UF2_migrate

So I don't understand what I'm doing wrong here. I must be doing something wrong with xargs I presume, but what?

Thanks in advance

Instead of stumbling with the spaces problem, I tried to find an alternative solution. Instead of bookmarking a branch by name, I bookmark it now by rev which circumvents the spaces problem:

$ hg branches -c -T {rev}\\n{branch}\\n | sed -e "s/ /_/g" | xargs -t -d \\n -L 2 sh -c 'hg bookmark -r $0 $1_migrate' 

If anyone knows the solution to the spaces problem, I would really like to know it. But I can live happily with this workaround.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM