Quite sad that the project that started out as a Mercurial hosting platform ends up without an own way to let its users to convert from Mercurial to Git, or at least allow them to download archives of their repositories. Well done Atlassian. Still, thanks for these 9.56 years of service. It must have been hard.
I'm glad GitHub import works for you but for many people that approach either doesn't work at all (private repos) or it only partially imports the project. This thread is rather long and is now difficult to read so I posted https://github.com/clach04/bitbucket_tools
In an attempt to document all known options as there isn't a best all round solution.
@crobar Issues, pull request history, commit comments, downloads, wikis, issue attachments, branches with multiple heads, etc. are not transferred without extra effort. I've also found the GitHub source importer does not handle UTF8 characters in commit messages well.
There are a variety of tools in previous posts (including ones I've written or collaborated on) which solve several of these issues, for people either moving to GitHub or staying with BitBucket, mostly documented in the link @clach04 provided. If you don't need those things, that's great! We're just trying to keep useful information posted regularly because there are consistently people posting "it's really easy, you just do X" when it really is not that simple for many people.
@crobar thanks for letting me know GitHub import support private imports now, I updated my readme about this.
If you are happy with repo imports and you have more to migrate, you might be interested in https://github.com/brunogfranca/bitbucket2github which takes advantage of GitHub's import and can be used to batch import.
As @philipstarkey mentioned this isn't a viable option for some projects.
I didn't want to give up controls over the process of conversion from Hg to Git to 3rd party tools, and created my own `bash` script that clones `hg-git` and does all the steps listed in `hg-git` repository. https://dev.to/abitrolly/script-to-move-from-bitbucket-hg-to-git-2icg
Anyone know if Mercurial Changeset IDs map into the same Changeset IDs after conversion to Git using hg-fast-export? If not, is there any way to establish a mapping between the two?
hg-fast-export saves a file in the .git directory storing the mapping that you might read programmatically to figure out the mapping.
Another option to include the hashes as repository data permenently is to use the --hg-hashes option to hg-fast-export, which will save the originating hg-hashes as git notes for each git commit.
There is a little bit more of an explanation about the --hg-hashes git notes here - they are fiddly as they are not pushed or pulled by default which can mean you'll lose them if you don't push them explicitly after first creating them:
If you were to actually use my hg-export-tool (which wraps hg-fast-export), the file within the .git directory will not be correct because my tool amends commits (of a temporary copy of the hg repo) to change branch names to ensure anonymous heads and bookmarks are converted (which hg-fast-export can't do presently). So this modifies the hash mapping compared to the original, unamended commits. The tool updates the git notes though, so they are correct, but not the file within the .git directory.
If you go the --hg-hashes route (via my tool or hg-fast-export directly), then you can get a list of all git --> hg hashes with the command:
> Anyone know if Mercurial Changeset IDs map into the same Changeset IDs after conversion to Git using hg-fast-export? If not, is there any way to establish a mapping between the two?
I've been using the https://github.com/philipstarkey/bitbucket-hg-exporter tool, and it creates a map between hg and git change sets that it uses when importing issues to GitHub and creating a GitHub-pages repository with archives of issues and pull request comments.
If you are going to GitHub, you can turn on the Jira integration, tell it the URL of your Jira account, and it'll automatically turn the tags in the checkin comments (e.g. "PR-1354") into links into your Jira bug tracking system. I presume that if you converted your project to git on Bitbucket there is similar functionality. Is that what you were asking for?
If you're asking for the opposite way -- e.g. you put Bitbucket changeset URL's into your bug tracking messages -- those are alas going to be useless because Bitbucket isn't going to maintain those. We would have stayed with Bitbucket if they'd given us a reason to do so, such as, e.g., in-place conversions to git that would maintain URL to changeset mapping so that changeset URLs in our Jira commit messages remained useful -- but they didn't, so we didn't. We made an on-premise copy of our Mercurial repositories so can look up a changeset there if we have to, but no clicky clicky alas (well, since we have a GUI mercurial browser you could put the changeset ID into that, but that's still not just a click away from the Jira issue).
@Eric Green thanks for the responses. I think you answered my question with the second response. I was worried that all the clicky clicky was going to be lost
We've moving a few dozen Mercurial repositories on BitBucket Cloud to Git on BitBucket Cloud. Many of these repositories have a few dozen Users and Groups -- is there any way to assign the same Users/Groups along with their permissions settings to the converted Git repositories, or will we have to do this manually for every repository?
@Jerry Gardner in theory you should be able to use the BitBucket API, but as far as I can see this can only be used to query permissions, not set them...which is pretty useless!
Are you sure you don't want to move to GitHub? 😁 A brief look at their REST API suggests you can use it to invite users to organisation repositories and specify the permission level (don't think you can do it for user owned repositories though)
seems i missed the news about deletion of mercurial repos earlier.
i have some of them i mostly used to clone en existing open-source repos and improve the code/fix some glitches to help others who did not see a proper code for a need.
for me personally deletion of the repos won't be a problem because i've soled my problems. but that's what i shared with the community to help them.
even if i would decide my persona time converting project what i've created for others the URLs of the repos won't match and all the links heading to my code from outside will be broken anyway.
i do not understand why there is no conversion button to keep the code and URLs in place?
poor decision quality, imo. bitbucket is not reliable after that. if so, why should i keep using it? there are plenty other reliable and free Git providers after all.
@brent_schiestlvery pleased to here that Perforce is doing such active development. I'd move my private projects there but, unless I'm mistaken, you don't have a solution for open source projects: the key thing really being that people can submit bug reports (and maybe even the odd PR).
@CharlieC thanks for the feedback. You are correct that the focus for Helix TeamHub is hosting private repositories. There are no future plans to change our focus at this time.
@CharlieCFor open source project, you can get free hosting on Heptapod (friendly fork of Gitlab with Mercurial support) See details at https://foss.heptapod.net/ .
531 comments