Skip to content

Instantly share code, notes, and snippets.

@ngaranko
Last active April 29, 2016 09:37
Show Gist options
  • Save ngaranko/6b96f9f180b7b2003e8a79d496594bd5 to your computer and use it in GitHub Desktop.
Save ngaranko/6b96f9f180b7b2003e8a79d496594bd5 to your computer and use it in GitHub Desktop.
Hg add branch name to commits
def prefix_commit_message(repo, **kwargs):
commitctx = repo.commitctx
def rewrite_ctx(ctx, error):
branch_name = ctx.branch()
old_text = ctx._text
if branch_name not in old_text:
ctx._text = "{}: {}".format(branch_name, old_text)
return commitctx(ctx, error)
repo.commitctx = rewrite_ctx
[hooks]
precommit = python:~/.hgco.py:prefix_commit_message
[alias]
co = commit -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment