Productive Rage

Dan's techie ramblings

Being a dirty GitHub-to-BitBucket turncoat

After having a bit of a run-in with GitHub a few weeks ago (GitHub and I might be having a falling-out) I was wondering if there was any easy migration route from GitHub over to BitBucket, which I'd been using to house a prototype project I've been doing related to work. We use Mercurial (with Kiln) and after getting over the initial CVS-to-Mercurial teething problems I'm well into it (though being better than CVS isn't that huge an undertaking! :)

The last straw was when I wanted to rename a project within a Visual Studio solution. Using TortoiseHg this is easy; perform the rename, use some "right-click / TortoiseHg / Guess renames" action. (Command line options also available!) But with Git I was struggling to find the best way to do it - I read a load of articles and a handful of StackOverflow posts. It seems like renaming files without changing their contents and then changing their contents will ensure the history is maintained. Usually. Except some times. Or during a full moon.

Ok, I admit, I didn't actually bother trying! And at this point I think I'm glad I didn't, since moving over to BitBucket turned out to be really easy with built-in tools.

A false start

After doing some initial reading around I found out about the BitBucket "Import Repository" functionality. Amazing! Point it at my GitHub repositories and import them into new BitBucket Mercurial repos - ideal! So I select "Git/GitHub" as the source and it set "Git" as the "Repository type", fair enough - it's realised that it has to import from Git! Selected Language as "C#" and hit "Import" and.. it all looked rosy!

I set up Username Aliases to my BitBucket user and had a poke around the history and found it all looked good. It even imported the tags from GitHub which I'd been concerned about since one of the articles I'd read had put some doubt in my mind regarding those.

Then I tried to clone the repository onto my computer. HTTP 501 "Not Implemented". Hmmm.. oh well, it was late, maybe I was doing something dumb.

So then I tried again the next day at work. Same issue. Not too reassuring :( I had a poke around the "My repositories" section and saw that the import repo was marked as being "Git". I tried cloning it and it worked. So imported yes, converted to Mercurial no. Back to the drawing board.

Hg Convert

Thankfully the solution I've ended up with wasn't much more complicated and uses a standard Mercurial Extension (Convert). The quick-fire version is to:

  1. Ensure the "convert" extension is enabled by going into Global Settings in TortoiseHg (or adding "convert=" to the "[extensions]" section of your mercurial.ini file manually if you're Tortoise-adverse)
  2. Open a command prompt
  3. Enter "hg convert c:\folder\name\of\git\repo" (quoting the location if there are any spaces)
  4. This will create a new folder in the command prompt's current location, taking the Git repo's name and suffixing with "-hg" (so "repo-hg" in this example)
  5. Move into folder and enter "hg update" to pull in the files
  6. Profit! :)

I created a new (Mercurial!) repository in BitBucket and pushed from the local repo up to it. Easy!

The repository I was playing with here had various commits by me under different usernames. I set up aliases to my BitBucket account for these but the convert extension offers options to remap author names so that these aliases aren't required (see the Convert docs).

Looking back

I must admit that part of the reason I started up the GitHub account was to build up a portfolio of demo code for when the day comes that I decide I want to look for alternative employment. And for some reason having a GitHub account just sounds cooler than BitBucket! But maybe that's just been engrained into me by the many many references to a GitHub portfolio that I've heard made on Hacker News over the years. Plus I'm going to miss the GitHub cat logo - BitBucket just doesn't seem quite as friendly without it!

Posted at 20:44

Comments

Mercurial on Windows - Changing filename case

At work today, in a fit of madness, I decided to rename a file in a BitBucket (ie. Mercurial) repository from RSSController.cs to RssController.cs for consistency with the casing in other files. At the time I wondered if this rename was a good idea, but everything seemed to go well.

When I got home and tried to update my repository there, seemed became the operative word. I was greeted with a "case folding collision" error and the start of 90 minutes of my life that feel wasted and aren't ever going to come back.

I'm not sure if there's a good way to do this and a lot of information out there about resolving this sort of mess starts with "On the Linux/FreeBSD machine.." or "On a case sensitive OS.." which is not very useful when all my computers run Windows!

Long story short; this page helped me out a lot - http://mercurial.selenic.com/wiki/FixingCaseCollisions. I haven't tried the CaseFoldExtension but following the instructions in there sorted me out. The only issue I encountered was one of the commands complained that it didn't have a username, including an additional -u"user@wherever.com" sorted that out.

This has tired me out! :S

Posted at 20:50

Comments

Mercurial and Dropbox

We've moved over to using Mercurial at work (thank god; life in a post-CVS world it good!) so I've been playing around with that. I've used Git before so it's not been too painless - in fact I think the Windows integration and TortoiseHg tool are pretty good (which is one of the claimed benefits of using Mercurial over Git in a Windows environment, apparently).

I've had a work-related idea that I've been trying to hash out that I've been doing mostly at home but playing round a bit with at work too. The Mercurial web server we've set up is for internal use only so I thought I'd try stuffing a repository into my Dropbox folder - since I already use that for some casual file sharing between work and home. The plan was to work on a local clone at home and at work and push / pull to the Dropbox repo as required.

I'm far from the first person to think of this and initial research looked promising:

Mercurial (hg) with Dropbox

Mercurial and Dropbox

Personal Version Control with Mercurial + Dropbox

However..

I've been happily using this for a couple of weeks, it's only me doing the work - from home and from the office; doing my commits locally and pushing up at the end of the day or whenever. Then pulling and updating from my other PC. But this morning the pull request failed at work; something about integrity errors. I did more some reading around and ran "hg verify" against the repository in Dropbox and got back a dozen errors along the lines of

SomeFile.cs@?: rev 5 points to unexpected changeset 26

.. which didn't really mean a lot to me, to be honest.

I tried to find out how easy it would or wouldn't be to recover but didn't make major inroads and in the end decided I'd wait until I got home and checked my local clone, the one that I was pushing from to the Dropbox clone. That should be fine, right?

Happily (and logically, from what I understand), the local clone was absolutely fine and "hg verify" reported no issues. Happy days!

As I look further into it, there is more information recommending against this Mercurial (or Git) with Dropbox combination..

Using Mercurial with Dropbox

Mercurial (and, I guess GIT) with Dropbox: any drawbacks?

And now..

If this was purely a personal project that I was happy to share with the world then I probably would have gone straight for BitBucket - I know one of the guys from work uses it for his personal bits & bobs - but knowing that GitHub doesn't support private accounts for free I presumed BitBucket was the same.. but they aren't! They'll let you have one free private repository with your account so once I'd checked the integrity of my local source I pushed it up to a new private BitBucket repository and that'll look after it from now on!

In the long run - for this particular project - this is only going to be a short-term solution; either we'll pick up development at work or I'll decide that it wasn't as good an idea as I'd first thought. And I suppose I could have chucked it on a file share on one of the work servers since I can get VPN access.. but really I wanted to see if this Mercurial / Dropbox combo would be any good. And now I do know! :)

Posted at 19:06

Comments