Combining Python, the best parts of BitSync and BitBucketAPI has produced BitSyncPy. This is a very short Python 3 script that will:

  • Connect to BitBucket’s API using a user-supplied username and password;
  • Get a list of the remote repositories belonging to a specified user;
  • Get a list of local repositories in a specific path;
  • Print the total number of remote and local repositories;
  • List any repositories that are local but not remote;
  • Clone all repositories that are remote but not local;
  • Pull/update all repositories that are both local and remote.

It’s essentially the same utility as the C# version of BitSync, but it’s a fraction of the size and should be cross-platform. Note, however, that it uses the new argparse module included in Python 3.2 (yep, I’m running the release candidate) and so won’t work without modifications in the stable version of Python 3.1. It won’t work in Python 2 either.



I’ve been playing with the BitBucket API recently. It’s pretty neat - it’s a REST API that transmits data in JSON format. I can’t imagine a lower-friction way of getting at BitBucket’s data. It’s not complete, unfortunately, and does have some bugs, but hopefully it will improve over time.

My main reason for experimenting with it was to find a way of pulling down all Mercurial repositories belonging to a specific user. I’ve decided to take on curation duties for CaptainChemo’s repositories rather than leave them orphaned and unloved. I’m not sure what I’m going to do with them yet, though. There are a few private repositories in there that might contain proprietary code that I can’t open-source, but unfortunately I’m not in a position to find out.

Rather than use the command line to pull down the repositories one at a time, I knocked up a quick C# program to do it for me:

BitSync is command line driven. Example usage:

 bitsync /username ant512 /password mypassword
 /localpath C:\Mercurial /repoowner CaptainChemo

Note that the “repoowner” argument is case-sensitive.

BitSync will get a list of the repositories on the server and compare it with a list of repositories stored in the local destination path. If a repository already exists locally, BitSync will attempt to pull and update it. If a repository does not exist locally, BitSync will attempt to clone it.

Private repositories are only visible if the username and password combination have access to them.

The program uses a combination of Hammock and Json.NET for accessing the API, and my own PrettyConsole library developed in haste for the Woopsi font/bitmap tools.