2011-02-17

BitBug and BitBugPy

Another pair of C#/Python programs. This time it’s an idea branched from BugBare, my distributed bug tracker. The real problem with distributed bug trackers is their complete lack of utility and visibility for people who aren’t programmers on the project in question. BitBug dumps the distributed part and is really just a command line interface to BitBucket. All bugs are stored in BitBucket’s issues database. They obviously don’t work offline, but they’re as quick to use as BugBare and come with a ready-made web interface.

The two programs are here:

Of the two, BitBugPy is the tidier program. It uses the BitBucketAPI library for all BitBucket interaction, so the script itself is tiny. Again, it uses Python 3.2 (release candidate) so I’m sure 99% of the world won’t be able to use it. I’d look into making it a Mercurial extension, but - shock! - Mercurial is written in Python 2, not 3, and I’m not interesting in backporting it.

The C# version - BitBug - uses my MurkyCommando library as its command line UI. Since playing with the various command line argument parsers in Python I’m a lot less happy with it now.

They are both rather limited at the moment, mainly because the API offered by BitBucket is still a work in (very slow) progress.

2011-02-17

BitSyncPy

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.

2011-02-04

BitSync

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.