The commit log glowed red with a mistake. An email address sat in plain text, stamped into history. You can’t rewrite every developer’s memory. But you can stop it from happening again.
Masking email addresses in logs for Mercurial is not optional. It’s a safeguard against leaking personal data in a repository that lives forever. Mercurial stores author and committer information in changesets. By default, that includes the full email address. Once pushed, it spreads to every clone.
To mask email addresses, configure Mercurial to sanitize before commit. Use the [hooks] section in your .hgrc file to run a pre-commit script. This script can parse HGUSER and replace the email part with a placeholder or hashed value. Example:
[hooks]
precommit.maskemail = python:/path/to/mask_email.py
mask_email.py would inspect environment variables and commit metadata, replace username@example.com with username@masked, and ensure that change propagates to the commit object before it’s written.