Words in Boxes

Nouns, verbs, and occasionally adjectives.

Thursday, March 22, 2012

What I’ve Been Reading

  1. Haruki Murakami, 1Q84. Entertaining even at 900+ pages. Top seed (and my favorite) in this year’s Tournament of Books.

  2. George Dyson, Turing’s Cathedral: The Origins of the Digital Universe. I’m listening to the audiobook during late-night baby calming sessions, which is a new experience for me (on both counts, I suppose). Still in progress, but good so far.

  3. Sara Wheeler, Cherry: A Life of Apsley Cherry-Garrard. Continuing my Heroic-Age-of-Antarctic-Exploration reading, this is a biography of the youngest member of Scott’s last expedition and the author of The Worst Journey in the World. Interesting, but not worth your time unless you’re into this stuff.

  4. Neal Stephenson, Reamde. Great but long page-turner. You can tell he had fun writing this one. Recommended.

  5. Michael S. Malone, Infinite Loop. I picked it up after hearing John Siracusa’s recommendation. It’s a detailed history of Apple from founding to 1998. Since it ends right as Jobs introduces the iMac, it’s an interesting perspective - for example it takes for granted that Apple should have allowed clones to use MacOS. Out of print, but you can probably find it at your library.

  6. Vernor Vinge, Children of the Sky. The long-awaited sequel to the A Fire Upon the Deep. Vinge is one of the most imaginative science-fiction writers at creating and depicting alien species. Recommended if you’re into sci-fi (as are the two previous novels - ignore the heinous covers).

Sunday, February 05, 2012

Migrating repositories from Bitbucket to Github

A few years ago, I decided to use Mercurial & Bitbucket instead of Git & Github for my public repositories, because Mercurial seemed simpler and worked better on Windows. But times have changed. I use OS X now, and Github has become both overwhelmingly better and more popular. So it’s time to pick up and move.

This is a guide on how to do just that. It assumes that your repos have a small number of committers, and that you’re comfortable with the command line.

1. Clean up your Mercurial repository

Chances are your Bitbucket and Github usernames are not the same. Or if you’re like me, you didn’t keep your ~/.hgrc settings the same across machines, so your commit usernames aren’t consistent even if they’re all actually yours. The migration is a chance to tidy up.

To do this, we can use Mercurial’s convert extension, which can create a new, ‘filtered’ repository from an existing repository. In our case, we’ll alter the usernames to match what we want to appear on Github.

The convert extension is enabled by adding these lines to our ~/.hgrc:

[extensions]
hgext.convert=

Next, we’ll create a text file that maps old usernames to our new usernames. This is easy with some bash magic. Go to your repository directory and on the command line type:

hg log | grep user: | sort | uniq | sed ’s/user: *//‘ > users.txt

users.txt contains a sorted and filtered list of all the usernames attached to commits, like this:

username
username@localhost
username <username@gmail.com>

Edit this file so it maps old usernames to new usernames. If you have any existing Github repositories, I recommend running git logto get the exact username / email pair Github expects.

username=Username Fullname <username@gmail.com>
username@localhost=Username Fullname <username@gmail.com>
username <username@gmail.com>=Username Fullname <username@gmail.com>

We’re ready to convert (replace SOURCE_HG_REPO and CLEAN_HG_REPO with real directory names, of course):

cd ..
hg convert --authors SOURCE_HG_REPO/users.txt SOURCE_HG_REPO CLEAN_HG_REPO

And bam, you have a new, tidied mercurial repository in CLEAN_HG_REPO.

2. Convert the repository to Git

Converting a repository from Mercurial to Git is simple. We’ll use a script called fast-export. The following instructions are adapted from Dan Benjamin’s.

The easiest way to get fast-export is to clone it from its Git repository:

cd ~/tmp
git clone git://repo.or.cz/fast-export.git 

Now we’ll create a new, empty Git repository, and use fast-export to populate it.

git init DEST_GIT_REPO
cd DEST_GIT_REPO
~/tmp/fast-export/hg-fast-export.sh -r CLEAN_HG_REPO
git checkout HEAD

And bam, you have a new Git repository, complete with your entire commit history. Don’t forget: you’ll need to convert your .hgignore into .gitignore.

3. Push the new repository to Github

Now it’s time take your shiny new Git repository and slap it up on Github. Go to your Github profile page, and click “New Repository.” Fill out the form, and follow the instructions to import an existing Git repo, which goes something like this:

cd DEST_GIT_REPO
git remote add origin git@github.com:username/REPO_NAME.git
git push -u origin master

4. Don’t forget to migrate other data

I haven’t found a way to automatically migrate them, but don’t forget about:

  • Issues
  • Wiki. I tended to use a one-page Wiki as a landing page. The Github convention is to use a readme.md markdown document. You’ll have to convert the Wiki markup to Markdown.

5. Deleting your Bitbucket repository

On the “Admin” tab of your Bitbucket repository page, you can choose to delete the repository. Make sure to enter the url of your new Github repository in the “Redirect to” field!

Wednesday, December 21, 2011

Wordcycler 2.0 Released

It’s been a long time coming, but I’ve released a new version of Wordcycler, the program for two-way Instapaper sync for Windows and your e-book reader. There is only one major change — now, instead of scraping the site, Wordcycler uses the offical Instapaper full API.

This means two things for current users:

  1. Wordcycler will be more reliable and future-proof. Since Wordcycler was nothing but a glorified site scraper, it has always been one minor Instapaper site upgrade away from being completely broken. We’ve been lucky so far, but it’s a bomb waiting to go off. The official API is guarranteed to keep working.

  2. To use Wordcycler, you must be an Instapaper subscriber. Only subscriber accounts have access the full API. It’s only $1 a month and helps keep Instapaper running, so I recommend you subscribe if you haven’t already.

I realize this is a trade-off, so if this is a deal-breaker you should not upgrade. But I will not be updating the 1.x versions of Wordcycler, so if Marco Arment changes the HTML and breaks Wordcycler, you will be on your own. Using the full API is the right thing to do, if only just to be a good Instapaper citizen.

The Future of Wordcycler

The fact is, I don’t use Wordcycler myself much anymore. I own a Mac now, and I do most of my Instapaper reading on my iPhone. Wordcycler is not a money-making project, so my time and attention has been spent on my day job, my personal life, and other projects – the usual reasons. Wordcycler 2.0 has been sitting on my drive half-finished for about six months, but I wanted to finish it up to leave things in a good spot.

So that’s a long way of saying that this could be the last release of Wordcycler. It’s been a fun ride, and it’s been very gratifying to see so many people get use out of it. But it’s time to stop kidding myself that I have the time to maintain it, especially now that I’m no longer an active user myself. I’m exploring the possibility of open-sourcing Wordcycler, but no promises yet.

I'm James Sulak, a software developer in Houston, Texas.

You can also find me on Twitter, or if you're curious, on my old-fashioned home page. If you want to contact me directly, you can e-mail comments@wordsinboxes.com.