Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What to do with your Mercurial repos when Bitbucket sunsets support

531 comments

Anatoli Babenia April 24, 2020

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 # people like this
clach04
Contributor
April 25, 2020


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 # people like this
crobar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 26, 2020

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

 

Not sure what you mean only partially imports the project

philipstarkey
Contributor
April 26, 2020

@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
clach04
Contributor
April 26, 2020

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

Anatoli Babenia April 27, 2020

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

Jerry Gardner April 28, 2020

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?

cbillington April 28, 2020

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

Steven Peters
Contributor
April 28, 2020

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.

Phil Bloxom
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 28, 2020

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

Eric Green
Contributor
April 28, 2020

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?

Eric Green
Contributor
April 28, 2020

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

Phil Bloxom
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 29, 2020

@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

Jerry Gardner April 30, 2020

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?

philipstarkey
Contributor
April 30, 2020

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

Like Steffen Opel [Utoolity] likes this
Klaus Rennecke May 6, 2020

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.

hlopetz May 6, 2020

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.

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 6, 2020

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 May 6, 2020

great idea, thank you @Marek Parfianowicz 

brent_schiestl
Contributor
May 7, 2020

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.    

Peter Koppstein
Contributor
May 7, 2020

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

CharlieC
Contributor
May 8, 2020

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

brent_schiestl
Contributor
May 11, 2020

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

brent_schiestl
Contributor
May 12, 2020

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

marmoute
Contributor
May 12, 2020

@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
AUG Leaders

Atlassian Community Events