This was originally fixed by Mateusz Kwapich for the metaedit command in
fb-hgext with a test for the metaedit command. It didn't get upstreamed
because metaedit was not in core.
This patch fixes the crash and adds a test about metadataonlyctx to
avoid future regressions.