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

yet another issue on unnamed heads #220

Closed
rob975 opened this issue Apr 19, 2020 · 4 comments
Closed

yet another issue on unnamed heads #220

rob975 opened this issue Apr 19, 2020 · 4 comments
Labels
user-support Help to users, can turn into a verfied bug if it turns out to be a problem with fast-export

Comments

@rob975
Copy link

rob975 commented Apr 19, 2020

We started migrating our mercurial repositories to git ones and we got stuck into the problem of unnamed heads. This problem has been discussed in closed issue #9 but i think it's related to open issue #61. Basically we have been using mercurial bookmarks as git branches.
To migrate those repositories we are emulating forks to have a git branch for each mercurial head.
The process is based on getting the common ancestors of the heads (using mercurial APIs), clone and fork them, The forks are then added as remote repositories just to get their branches and removed afterwards. It does not uses the force option and does not require extra commits, which avoids closed mercurial branches to pop up.

Down below are the commands executed to successfully export a repository with revisions 849 and 879 as heads and revision 827 as common ancestor. I guess they can be simplified and automated.

Note: We brutally copied the folders as a work-around to issue #114.

# clone up to common ancestor
hg clone hg-repo hg-repo-ancestor -r 827
# export to git
git init git-repo-ancestor
cd git-repo-ancestor
../fast-export/hg-fast-export.sh -r ../hg-repo-ancestor
cd ..
# copy common ancestors to 2 new repository
cp -a hg-repo-ancestor hg-repo-v15.x
cp -a hg-repo-ancestor hg-repo-master
cp -a git-repo-ancestor git-repo-v15.x
cp -a git-repo-ancestor git-repo
# for each copied ancestor pull one head and export to git
hg -R hg-repo-v15.x pull -r 849 -u
cd git-repo-v15.x
../fast-export/hg-fast-export.sh -r ../hg-repo-v15.x
cd ..
hg -R hg-repo-master pull -r 879 -u
cd git-repo
../fast-export/hg-fast-export.sh -r ../hg-repo-master
# add the other repositority as a remote
git remote add v15.x ../git-repo-v15.x
# fetch from the other repository
git fetch v15.x master
# create branch
git branch v15.x v15.x/master
# remove the other repository
git remote remove v15.x
# checkout master branch
git checkout HEAD
# clean up
cd ..
rm -fr hg-repo-ancestor hg-repo-v15.x hg-repo-master \
        git-repo-ancestor git-repo-v15.x
@frej frej added the user-support Help to users, can turn into a verfied bug if it turns out to be a problem with fast-export label Apr 30, 2020
@frej
Copy link
Owner

frej commented Apr 30, 2020

Are you aware if @chrisjbillington's hg-export-tool (it is mentioned in the Notes/Limitations section of the readme)? I think it will give you a git branch for each Mercurial head .

@sschaap
Copy link

sschaap commented Apr 30, 2020

We have a similar issue on a third-party repo that has loads of unnamed heads, mostly due to closed/reused branches. Was considering whether to add a --tag-heads switch to create heads/{branch}/{hash} tags for each hg head and disables the unnamed heads check.

Thoughts?

@dedabob Have you considered extending hg-fast-export to create additional branches for hg bookmarks?

@rob975
Copy link
Author

rob975 commented May 4, 2020

Are you aware if @chrisjbillington's hg-export-tool (it is mentioned in the Notes/Limitations section of the readme)? I think it will give you a git branch for each Mercurial head .

Pro Git book pointed me to this tool, so I didn't look for alternatives.

I gave @chrisjbillington's tool a try. It amends head commits, which means it strips those commits and creates new ones, so it's fine if changing the history is not a problem.

I'm going to try hg-git. It seems to ignore branches and just export mercurial bookmarks to git branches without changing the history, which is the feature of issue #61. @sschaap, check if it's suitable for your requirements.

@frej
Copy link
Owner

frej commented May 6, 2020

As this basically seems to be a duplicate of the feature request in #61, I'll close this issue.

@frej frej closed this as completed May 6, 2020
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
Projects
None yet
Development

No branches or pull requests

3 participants