It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What to do with your Mercurial repos when Bitbucket sunsets support

405 comments

https://github.com/new/import is the GitHub way to import Mercurial repositories into Git.

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.

Like akademy likes this


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.
 
 

Like hlopetz likes this

Importing private bitbucjed repos to a private GitHub repo worked fine for me.

 

Not sure what you mean only partially imports the project

@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.

Like # people like this

@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?

@Jerry_Gardner They do not match.

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:

https://github.com/chrisjbillington/hg-export-tool

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:

git log --branches --show-notes=hg --format="format:%H %N"

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.

Is there a way to not lose our bug tracking traceability with JIRA during this conversion?

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)

How do we keep the branch ancestry when migrating? Git does not keep branch ancestry like Mercurial does.

Once branch ancestry is solved in git, I would be okay with migrating. Otherwise, relocate.

hey there,

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.

Hi @hlopetz! When you are deleting a repository in Bitbucket, you can specify a redirect URL. I hope this helps a bit. Cheers

Like hlopetz likes this
hlopetz I'm New Here May 06, 2020

great idea, thank you @Marek Parfianowicz 

Hi @Peter_Koppstein@torohill, and @Ruslan_Berezyuk - Happy to report that we just released the 2020.1 update to Helix TeamHub which now includes the ability to create project wikis that are Hg-backed (and are indexed for code search as well).  Thanks for your input as we've continued to improve the product!  You can check out our 2020.1 release overview here: https://www.perforce.com/products/helix-teamhub/whats-new-helix-teamhub.    

@brent_schiestl Excellent timing!  Any recommendations for migrating mercurial repo+wiki together? Thank you.

@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).

@Peter_Koppstein: the best place to start would be here: https://www.perforce.com/manuals/teamhub-user/Content/HTH-User/mercurial.html#Migrating_existing_Mercurial_(HG)_repositories_to_Helix_TeamHub.  Please feel free to email me directly at bschiestl@perforce.com if you need additional advice.  Thank you. 

@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/ .

(For commercial hosting on Heptapod see https://about.heptapod.host/ )

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Bitbucket

Bitbucket Server 7.0 is here!

Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...

1,110 views 6 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you