## Saturday, October 23, 2010

### Easier way to run Mercurial hgk (or hg view) on Windows (and Cygwin)

hgk, the Mercurial extension that allows the hg view command, is the graphical viewer for Mercurial repositories.

It's a bit messy to run it on Windows. The solution I came up with was easier than the others I found on the web, so ...

I downloaded the Mercurial 1.6.4 main binary for Windows (making sure to install the "contributed scripts" so that I got hgk), and ActiveState's ActiveTcl 8.4. I installed them. I then modified my Mercurial configuration as follows. You need to create one batch file in a directory of your choosing, in addition to installing these packages and modifying your configuration.

Added to Mercurial.ini (user or systemwide; probably would work with \$HOME/.hgrc as well):

[extensions]
hgext.hgk =

[hgk]
path=C:\wherever\you\want\hgk.bat

Created hgk.bat (at path indicated above):
(Note that this is a two-line script: wish.exe takes the hgk path as an argument. Not sure how to get Blogger to format this better.)

@echo off
set HG=C:\path\to\mercurial\hg.exe
start C:\path\to\tcl\bin\wish.exe C:\path\to\mercurial\contrib\hgk %*


And that's it! I don't know why the official instructions are so hard. And in any case, they did not work for me. YMMV.

## Thursday, October 21, 2010

### Ephemeral ports

Just learned about the so-called "ephemeral port range," which for years has been causing my servers on my local Windows machine to not start. Even after killing the process that has captured the server port, for whatever reason, I can't get a Java application to be able to listen on the newly closed port. This problem - not being able to use ports even when the netstat command reports them usable - seems to be a pretty common problem, and not Java-specific: see one of these five articles for more.

Anyway, the "traditional" (who knew? After running BSD all these years, I had no idea) "ephemeral port" range is 1024-4999. I knew ports below 1024 were essentially reserved for root on Unix systems, but I didn't know there were any other allocations. In the 1024-4999 range, applications (often client applications) claim ports for their own use.

Someone generously took the time to compose a very detailed overview of, and reference guide for, ephemeral ports on many operating systems. It certainly was helpful for me.

It is possible to reconfigure the ephemeral port range on Windows by hacking the registry. But simpler for me to just change my port numbers.