svn commit "unable to lock" error under Mac OS X

This will be interesting to approximately none of you, but I feel I need to spread the knowledge of hell to a wider world.

I will perhaps go into greater detail at a future date about all the other problems preceding this one while I used svn (and Maven, and Eclipse) under OS X. They all essentially stem from the fact that OS X’s filesystem is case-insensitive. … Or rather, not case-insensitive: you can’t do

(16:41) slaniel@Steve-Laniels-MacBook-Pro:~$ mkdir test_dir
(16:42) slaniel@Steve-Laniels-MacBook-Pro:~$ mkdir test_Dir
mkdir: test_Dir: File exists

But you can do

(16:42) slaniel@Steve-Laniels-MacBook-Pro:~$ mv test_dir test_Dir
(16:42) slaniel@Steve-Laniels-MacBook-Pro:~$ rm -rf test_dir

Since it’s not entirely case-insensitive, it is sometimes — but not always — a problem to have both ‘foo’ and ‘Foo’ in the same svn checkout. More to the point here: what if you have ‘Foo’ and want to rename it to ‘foo’? You’d want to do svn mv Foo foo. There will be bequeathed unto you a sadness:

(16:45) slaniel@Steve-Laniels-MacBook-Pro:~/svn/sandbox/slaniel$ svn mkdir foo
A         foo
(16:45) slaniel@Steve-Laniels-MacBook-Pro:~/svn/sandbox/slaniel$ svn mv foo Foo
svn: Unable to lock 'Foo'

The reason it can’t lock ‘Foo’ is that it already has ‘foo’ locked, and it thinks that ‘foo’ is the same as ‘Foo’. So it can’t move, in other words, because the filesystem is case-insensitive.

To redress this just now, I had to do something like

svn mv foo bar && 
svn ci -m "Temporarily moving foo to bar" && 
svn mv bar Foo && 
svn ci -m "Moving bar to Foo"

You need to do the commit after each move; you can’t just do

svn mv foo bar && svn mv bar Foo

Maybe all of this was obvious to all OS X svn users other than me. I assure you that it was not obvious to me.

Mac filesystem case-insensitivity just wasted an inordinate quantity of time and money from some of my company’s smartest engineers. I am displeased. Perhaps this post will save someone else some time in the future.

At a later date, after I’ve actually completed some work, perhaps I will explain all the other badness that resulted from this case-insensitivity.

The iPhone is a gateway Apple product

I bought an iPhone a year and a half ago. This made me really want to develop an iPhone app — something I’ve not yet done, but which I intend to start very soon. [1].

Now, the thing about the iPhone’s UI, which I don’t think you can fully grasp until you’ve actually used one, is that nearly everything — at every scale — works as it should. There is not a single sharp corner left in the product; everything has been rounded for your pleasure. The first place you see this is when you scroll to the end of a long list. When you hit the end, the iPhone doesn’t jarringly stop there. Instead, it bounces you, as though you just ran into a rubber wall on the way to catch a fly ball in the outfield.

It turns out that there is nothing jarring in the iPhone. If you’re rocking out to some tunes and a call comes in, the iPhone doesn’t just turn off your music and start ringing. Instead it gradually fades out the music, then starts ringing. When you’re done with the call, it gradually fades the music back in. Nothing about the product will ever put you ill at ease. That’s why I say you have to use it to understand this: in principle, written out like that, it seems like most products should and do behave like that, right? But they don’t. Getting all the details right — every detail, at every scale — is apparently so difficult that virtually no one does it. You really don’t notice how rare it is until you find yourself absolutely pleased with the iPhone, in a way that you’ve never been pleased with a piece of consumer technology before.

Having decided to do iPhone development, my terrific employer very graciously offered to buy me a MacBook Pro. The first couple days were a little difficult for me: I do a lot of command-line stuff, so I needed to get MacPorts or Fink going. And I had to get used to all the Mac OS X keyboard shortcuts.

With that out of the way, I fell into the same feeling of comfort with OS X that I have with the iPhone. The first step was realizing that every piece of the Mac UI is exactly as it should be. The second step, having gained such confidence in Apple’s UI design, was to ponder how I would do something in OS X, then ask, “If everything worked as it should, how would I perform this task?” It turns out, uniformly, that OS X’s UI always behaves the way it should. This gives you the confidence, as a friend pointed out to me last night, to go forth and try new things, and to really engage with the product in a way that you wouldn’t with some (forgive me) Microsoft piece of shit.

The first time this really took hold for me was when I asked whether I could plug my iPhone headset into my MacBook Pro and use it there the way I use it on my iPhone. For those who don’t know, the iPhone headset has a little clicky piece that performs two functions: it’s the microphone through which you carry out phone conversations, and it’s a control device for iTunes on the phone. Click the microphone once to pause the music you’re listening to or hang up the phone call you’re on; click it twice to advance to the next track. (It probably does other things as well.) If Apple designed its products the way you should expect (but which you’ve come not to expect from any consumer-electronics company), you should be able to pause iTunes on the laptop, advance to the next track and so forth using the iPhone headset. It turns out that you can do exactly that. And I’m not even using an Apple-manufactured headset: I’m using an incredible pair of Sennheiser MM 50 earbuds. It must just be that Apple requires single clicks to issue a certain signal and double-clicks to issue another, which both the iPhone and the MacBook Pro are programmed to respond to in the same way (namely firing off an event in iTunes). I don’t trust any other company to manage this amount of integration.

Stephanie and I discovered yesterday that there’s an app called Keynote Remote that lets you control Apple’s presentation software from your iPhone via WiFi. This is integration that everyone can use, and of course it helps Apple: the more Apple products you buy, the more value you get out of any one of them.

I’m probably going to buy a Time Capsule, which (so I gather) is so thoroughly integrated with OS X that you never even have to think about backing up; it just does it automatically. I gather that you could use other remote-backup devices in place of a Time Capsule (I believe the Time Machine software works with any number of devices), but — again — experience shows that Apple has integrated its devices spectacularly well; why would I want to use anyone else’s? Yes, I know that this is Kool-Aid drinking, but it’s Kool-Aid drinking based on a lot of positive experiences.

The final step in Apple fanboydom is to proselytize, which I unashamedly do now. But it’s proselytizing to those who could actually get a lot out of the product. Take my girlfriend, for instance (not literally; I enjoy dating her). She needed to make a movie on her ThinkPad, running Vista, so she used the built-in Microsoft Movie Maker. She spent a large fraction of a day trying to convert from the QuickTime-formatted movie that nearly every point-and-shoot camera generates to something that Movie Maker could process. Having never used iMovie, I nonetheless knew its reputation as the product you use when you want to make movies. So I brought the MacBook Pro up to New Hampshire one night, we plugged her camera into the USB port, and within a minute she was editing video. 24 hours later, she had bought a MacBook Pro of her own. People want to get shit done; they don’t care that Microsoft lacks QuickTime support because it wants to screw one of its competitors.

As a friend pointed out: Apple knows that you want to look cool. Even if Microsoft had made it easy to import .MOV files into Movie Maker, you know that it would have botched the execution after that; you would not look cool when it was done. It would offer you “wizards,” which would lead to very boring videos resembling animated PowerPoint. And those wizards would somehow, miraculously, not make your life any easier. They’d be a needless abstraction piled on top of a crummy user experience. Apple would fix the user experience so you wouldn’t need the wizard.

A coworker was giving me some good-natured ribbing the other day about using a Mac. He, like me, grew up during the Mac-versus-Windows wars of the early 90s. News flash: those wars are over, and the Mac has unquestionably won. I would be shocked if anyone who’s considered the matter actually believed that Windows was more usable, or more technically well-assembled, than OS X. (Though I’m fairly certain that Windows is easier to manage for enterprise installations than either OS X or Linux. But that’s not the realm that my coworker was arguing in.)

If there is still an OS battle going on, it is Linux-versus-Mac. But that battle has nothing to do with UI; again, no one could seriously assert that Linux’s UI is better than Apple’s. If there’s a Linux-Mac battle, it’s a battle over the open Linux model versus the closed OS X model. Windows is not seriously in competition with OS X for its end-user experience; it succeeds because it has succeeded. Windows is the Martha Coakley of operating systems: you hold your nose and use it because you have to, not because you want to.

[1] — One thing I’ve realized about my work style, and maybe about work styles more generally, is that I need to get something utterly trivial but functional done ASAP, and can move from there to getting something real working. As of now, I know nothing about iPhone development, so the field seems vast and intimidating. The point is to kill that feeling of intimidation as fast as I can. The way to kill it is to just get something, anything, done in the platform so that it no longer seems beyond my grasp. Had I used this technique in college, I think I would be a far better mathematician than I am.

An update on Diamond DVI-to-USB adapters and Belkin USB hubs

All is not rosy in the land of multi-monitor MacBook Pros. As I mentioned there, I’m driving two large external monitors through USB, using Diamond adapters to connect USB to DVI; the USB plugs run into a Belkin USB hub, which runs into a single USB port on the side of the MacBook Pro with which my employer generously supplied me. (I will give you guys an iPhone app very soon; promise.) The dream is then that I can then run a bunch of other USB devices off the hub as well: iPhone, mouse, camera, etc.

It sadly hasn’t worked out that well, for reasons that illustrious Stevereads commentator mrz explained in comments to that post:

  1. There’s just not enough bandwidth in USB — much less in a USB hub, which has to split one USB port’s worth of bandwidth across seven devices — to power a high-resolution monitor (much less two high-resolution monitors). My monitors would periodically slow to a crawl, and would slowly repaint the screen from top to bottom. I had to unplug the USB hub at this point, so that OS X could shift everything onto the built-in monitor; once it did that, the speed returned to where it should have been.

  2. The USB hub — possibly because of item 1 — has died. None of the components plugged into it work, individually or together. When I unplug any of them — say, the mouse or a monitor — and plug them directly into the MacBook Pro, they return to life.

I can live with item 1: sure, I move windows around, and the rendering doesn’t really keep up with the movement, but it’s better by far to have two slow monitors than only a built-in MacBook Pro screen. Obviously I can’t live with item 2: I can’t stand to have a hub die after only a few days of use.

I tried to call Belkin support, but it’s another Indian call center. I find few things more disheartening than finding Indian tech support on the other end of the call; it speaks of a tech company that wants to save money (hmm: flimsy, cheap product?) and doesn’t care at all about helping its customers.

I may try to find another, better, more reliable USB hub, but the Belkin one gets fine reviews on Amazon. I’ll have to look around more closely.

Driving two external monitors off a MacBook Pro

Thanks to my employer for hooking me up with a beautiful MacBook Pro and two huge external monitors.

If you’re trying to do the thing mentioned in the title of this post, you’ve probably already found the perfectly comprehensive post I’m going to link to. If not, it’s this guy right here. The Cliffs Notes version is as follows:

  • Your MacBook Pro has one Mini-DVI port. You want to drive two external monitors. Problem.
  • So buy two Diamond BVU195 USB display adapters. These allow you to connect DVI cables to USB cables, of which your MacBook Pro has a few.
  • “But wait!” you might say here, “I only have two or so USB ports, and I want to drive two external monitors. How will I plug in an external mouse and an iPod/iPhone, and those two monitors?” Fear not: here’s where you buy a USB hub. I got a 7-port Belkin external USB hub for $28. I run a cable from there to a USB port on the MacBook Pro, and I’m done.

To review: up to here, you’re running one DVI cable from each of your monitors into a DVI-to-USB adapter from Diamond. Then you run the resulting USB cables into a USB hub. Then you run one cable from the hub into your MacBook Pro. Now both your monitors, in summary, are being run off a single USB port on your MacBook Pro. Sexy.

The final step, again as detailed in that article, is

  • Download and install the DisplayLink OS X drivers. Now you can use System Preferences to arrange your three monitors — two external, one built-in — in any configuration you like.


I would include pictures of how these things all work on my end, but the fellow who wrote that piece included everything I would have.

My only question now is how to get control of the ridiculous quantities of cabling I have laying on my desk at work as a result of these contortions:

Messy desk, lots of cables

Performance debugging OS X?

I only recently started using OS X (starting to write iPhone apps once I get my feet fully under me at work), so I’ve not yet touched on higher-level tasks like performance debugging. It seems as though I need to start on this, because the performance of this laptop — MacBook Pro, 2.66-GHz dual core, 4 gigs of RAM — is becoming unacceptable. Most of the time it’s fine, but very often it hangs for a couple seconds in the middle of whatever I’m doing. At that point I get the spinning OS X beach umbrella of death. Eventually it comes back. But those delays are really annoying when you’re in the middle of, say, watching a YouTube video.

I have a small array of standard techniques at my disposal to debug this sort of problem. The main one would be “Start with no applications open and keep opening apps until the problem appears.” Does anyone know of a faster way to zoom in on whatever is causing my system to hang at those moments? Profiling tools, etc.?

Throw 'em all in "Archives" and let Spotlight sort 'em out

I’ve had a cumbersome, carefully organized collection of mail folders for well over a decade now. At the moment, there are about 300 of them. Typically they’re organized by sender, though sometimes it’s by subject (e.g., if I send out a party invitation, I gather up all the responses in a folder for that party). There are probably other rules that I’m forgetting. Within those 300 folders are, if I’m counting correctly, about 153,000 mail messages. On the order of 14,000 of those are from Adam.

Clearly my organizational scheme is suboptimal. It has become noticeably so in the last year, ever since I’ve owned an iPhone. Partly this is the iPhone’s fault: I should be able to jump to a folder by its first letter, just as I can jump to the first letter of a contact’s name or the first letter of an album title. Without the ability to jump around from folder to folder, I have to flick through page upon page of folders. Really annoying.

This scheme has always caused me troubles, though. In particular, if I ever want to send someone the full contents of a thread between myself and someone else, I need to jump back and forth between my ‘sent’ folder and the recipient’s folder, copy those messages off somewhere else, thread-order them, and send the thread-ordered collection off.

Thunderbird and other modern mail clients help out with this: they build a client-side cache of all your IMAP messages, which are then rapidly searchable. In general, this is obviously where things are going — or, indeed, where things already are: put everything in a text index and be done with it.

A client-side text index won’t help with my iPhone, which doesn’t have enough disk space to store such an index. Really what I need to do is what Gmail already does: put everything in a single folder called ‘Archive’ when I’m done with it. Maybe GTD up my mail and create folders for Do/Defer/Delegate/Delete. (I already have a Trash folder, so that last one is already done.) But in any case, radically reduce the number of folders. Then my iPhone could just consult the server-side IMAP text cache when it needs to search for something. Done and done.

So that’s what I’m doing right now. I’m watching spin its wheels moving those 14,000 messages from the ‘kessel’ folder into ‘Archives’. Because I’m curious how IMAP works, I’ve got a Wireshark window open, showing me all the packets heading to the secure-IMAP port on my mail server. Here’s where I’m curious: why are there so many packets flowing that way? I would have expected not very many packets at all: one COPY command per set of, say, ten messages, a STORE command to tag those messages “Deleted”, and an EXPUNGE to delete them from the source mailbox. Instead there have been many thousands of packets sent back and forth thus far. I can’t look into the details of those packets, though, because they’re TLSv1-encrypted. Once this folder is done moving, I’ll switch to unencrypted IMAP and watch the packets to see what they’re containing. Stay tuned, you fascinated audience, you.

Swapping delete and backspace in Snow Leopard's Terminal

This was driving me nuts: in Snow Leopard’s Terminal, hitting the Delete key deletes the character in front of the cursor. This is at least consistent with the name on the key, but it’s not consistent with the key’s behavior in every other application; everywhere else, that key deletes behind the cursor. So it’s labeled ‘Delete’, but it acts like ‘Backspace’, except in the Terminal.

In earlier versions of OS X, there was an option within the Terminal that said explicitly “swap Delete and Backspace,” or something similar. That very clear name has apparently gone away. To do the swap under Snow Leopard, you need to go to the Terminal menu, then Preferences, then Settings tab, then Advanced, and check “Delete sends Ctrl+H”.

Our long national nightmare is over.