Mercurial - Abort: path 'foo/' is inside repo 'foo'

A trailing slash can be hard to see.

This morning I tried to commit to a Mercurial repository which contained sub-repositories. One of those subrepos had been added a few days earlier, along with the corresponding .hgsub entry. .hgsub had been committed explicitly, without incident.

$ vi .hgsub
  # add entry for src/baz/foo
$ hg ci -m "Some comment." .hgsub

Today, for the first time since adding the subrepo, I tried an hg commit at the top-level of my repository. Mercurial responded with an error message:

$ hg ci -m "Blah."
abort: path 'src/baz/foo/' is inside repo 'src/baz/foo'

Say what?

It took a few minutes of quiet contemplation before I finally saw the problem:

abort: path 'src/baz/foo/' is inside repo 'src/baz/foo'

Once the extraneous slash was removed from .hgsub, everything was fine.