Exchanging Work in Progress with Mercurial

The Problem

I work with other people on software projects. Sometimes it would be really handy to be able to exchange unstable work in progress with other developers, without having to commit the work as a permanent changeset in our version control repository.

My Solution

I’ve written a Mercurial extension that lets you do just that. Here’s the intended workflow:

  1. You do some work in your repository. You want to share it, but it’s not ready to commit.
  2. You type hg draft , which stores your work in a draft changeset.
  3. You push your draft changeset to your collaborators.
  4. You do some more work, and type  hg draft  again. This amends the previous draft changeset.
  5. You push the new draft to your collaborators.
  6. When you’re ready, you type  hg commit  as usual, and it replaces the draft changeset with a real one.

Get the Code

I’ve published my code at https://bitbucket.org/talljosh/tallhg but before you start using it, there is one caveat: for this extension to work as described above, you need to set up your repository so that changes to history can propagate between repositories. This means you must:

  • enable the (incredibly cool) evolve extension
  • set up your repository to be non-publishing by adding the following snippet to your repository’s  .hg/hgrc  file:
    [phases]
    publish = False

To use my extension, simply get the code:

hg clone ssh://hg@bitbucket.org/talljosh/tallhg

Then enable it in your  .hgrc  file.

[extensions]
draft = /path/to/tallhg/hgext/draft.py

My extension has been tested with mercurial 2.8.2.

How it Works

This extension works by storing metadata which marks your draft commits as work in progress. When further commits are added, this metadata is detected, and the new commit amends the old one.

A Caution

I’ve called the commits this extension creates “draft commits”, but this is very different from the commits being draft phase commits. I realise that this could cause confusion, but I couldn’t think of a better description of what this extension does. If you think of one, please let me know!

Posted in midlength | Tagged , , , , | Leave a comment

I Grieve for Mozilla

I don’t know how many of my readers have been following this, but it’s been a big thing in the tech world this past fortnight: Mozilla appointed Brendan Eich as CEO; three board members stepped down; there was outrage on the internet over the appointment and many people claimed they would stop using Firefox; Brendan Eich stepped down; there was outrage on the internet over Eich being “forced out” and many other people claimed they would stop using Firefox.

As far as I can see, the end result is that Mozilla has lost a skilled and respected chief technical officer, and it has lost a lot of goodwill.

I am neither a Mozilla employee nor contributor, but as far as I can see, Mozilla was the only major internet company that clearly stood for something other than their own selfish ambitions. Mozilla cared about their users in a way that Google, Microsoft and Apple do not seem to. Mozilla stood for putting control of the web in the hands of users. It was Mozilla that really introduced competition and innovation into the web browser market. Now they are trying to do the same with the smart phone market. They do this because as a community Mozilla believes that giving people access to better, open technology will lead to better access to information and therefore a better standard of living for people all over the world.

Whatever you think of Mozilla’s choices and responses in the past few weeks, Mozilla seems to have suffered a huge blow. This grieves me. As long as Mozilla still stands for what it stands for, I want to support them as much as I can; as far as I can see no-one else is standing up for these values.

Posted in midlength | Tagged , , , , , | 1 Comment

Storytime with Josh

I’ve started a YouTube channel where I tell Bible stories. The first video was published last week.

I won’t be posting all the videos here, so if you’re interested, you should head on over to YouTube and add the feed to your reader, or subscribe, or whatever it is that people do these days.

Posted in short | Tagged , , | Comments Off

I Wonder If I Could

Be warned: this article is a personal reflection.

A Park with Railings

When I’m out walking, I often walk along the wooden park railings.

I’ve always said that I value being willing to try new things. But I realised the other day that this doesn’t actually explain all of the unusual things that I do. For example, when I’m out walking, it’s not uncommon for me to jump up and walk along the park railings. I do this despite the fact that there’s a loud voice in my head saying “What will people think if they see you?”

Why would I do such an unusual thing? It’s not about trying something new—not after the first time, anyway. Do I do it to show off? Or because I think that having good balance is a skill worth cultivating? Or perhaps I value being unusual?

Some honest self reflection tells me that none of these reasons explain it. If I was showing off, or enjoyed being different, I wouldn’t be so worried about what others might think. I have no reason to believe that balance will be helpful for my future. I have come to the conclusion that I am motivated by “I wonder if I could”. I often wonder about things, and I often dream about what might be possible. And wondering is not enough for me. Once I have wondered about something, if the opportunity presents itself, I want to put that that thought to the test. I wonder if I would walk the whole way along this railing without falling off? I wonder how far along the railing I could get if I went at twice the pace? There’s only one way to find out.

Ultimately, I don’t consider my “What would people think?” or my “I wonder if I could” thought processes to be the most important things in life. But clearly “I wonder if I could” is powerful enough to trump “What would people think?” for me.

Posted in midlength | Tagged , , , , , | Comments Off

Using My PC as a Temporary Wifi Access Point

Last weekend there was an electrical storm which took out my wireless access point. My Ubuntu desktop PC is wired and also has a wireless card, so today I set my mind to a temporary wifi solution until I get a new AP.

The Basic Setup

In order to use my wireless card in master mode (that is, as an access point), I needed to use hostapd. In order to bridge the wireless interface to the LAN, I needed to install bridge-utils. Both of those things are in the Ubuntu repositories:

$ sudo apt-get install hostapd bridge-utils

My hostapd config file looks like this (with the SSID and passphrase not included):

interface=wlan0
driver=nl80211
ssid=[MySSID]
hw_mode=g
channel=11
wpa=1
wpa_passphrase=[MyPassphrase]
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600
bridge=br0

For this to work though, the interface  br0  needs to be set up. You can set this up in /etc/network/interfaces, but since this is a short-term fix, I chose to just do it manually from a script.

# Add bridge interface and add eth0 to it.
brctl addbr br0
brctl addif br0 eth0

# Start the wireless gateway
hostapd hostapd.wlan0.conf

The Catch

The setup above made the wireless work fine for me, but it meant that my desktop couldn’t access the network itself. After much hunting around, I figured out that I had to remove the IP addresses and routes from  eth0  and add them to  br0  for this to work. This article that pointed me in the right direction.

My final script is:

#!/bin/bash

# Add bridge interface and add eth0 to it.
brctl addbr br0
brctl addif br0 eth0

# Remove IP address from eth0, add a static one to br0
ip addr flush dev eth0
ip addr add 192.168.1.188/19 dev br0

# Bring the interface up and set the gateway.
ifconfig br0 up
ip route add default via 192.168.0.254

# Start the wireless gateway
hostapd hostapd.wlan0.conf

Now as long as my desktop is switched on and running this script, I have WiFi access to my network.

 

Posted in midlength | Tagged , , , | Comments Off