How to link JIRA tickets to Mercurial commits and track time from command line

I’ve been working with issue tracking systems and really enjoy how you can connect commits directly to tickets. This makes the development process much smoother.

For instance, when I want to mark a ticket as resolved, I can include the ticket number in my commit message like this:

hg commit -m "Fixed login error - resolves PROJ-456"

I’m wondering if there’s a standard way to connect JIRA tickets to Mercurial commits using the command line. Can you include ticket references in commit messages that JIRA will automatically pick up?

Also, is it possible to log work hours directly through commit messages? That would be really helpful for time tracking.

What’s the most common approach developers use to link their Mercurial commits with JIRA issues? Any best practices or tools that make this integration work better?

yup, if everything’s set up correctly, jira can recognize your commit messages with the issue key. just put it in there and it’ll link automatically. but for logging time, you gotta use smart commits. make sure to ask your admin if they’re turned on, though!

It works through JIRA’s commit linking, but your repo needs to be set up right first. Your admin has to connect the Mercurial repository to JIRA - if they don’t, your commit messages won’t show up anywhere. For time logging, use smart commits. Structure your message like: hg commit -m "PROJ-456 #time 2h 30m Fixed authentication issue". The time part automatically logs those hours to the ticket. Heads up though - some companies disable smart commits because they’re worried about security. They don’t want people changing ticket status without review. I’ve worked with teams where only certain people can use smart commits. Commit linking usually shows up in a few minutes, but time logging takes longer depending on your setup. If nothing’s working, talk to your JIRA admin about the repository connection settings.

Been using JIRA with Mercurial for three years - here are the gotchas you’ll hit. Basic ticket linking works when you include the issue key in your commit message, but placement matters for readability. I start with the ticket number: PROJ-456: Implement user authentication validation. Time tracking with smart commits is finicky. The syntax must be exact or it fails silently. #time 1h30m works but #time 1h 30m doesn’t register. Typo in the issue key? Your time logs to nowhere and you’re manually fixing it in JIRA. Commit hooks on the repository saved our workflow. They validate the issue key exists before accepting commits, preventing silent failures. Have your Mercurial admin set this up if your team keeps hitting invalid reference problems.