bottle: determine revision more reliably

Closes #25100.