Search code examples
mercurialcommitchangeset

Find changeset using commit message mercurial


I was wondering if I can find, in mercurial, a changeset using a part of a commit message

for example I have some commits with following messages: "Test-254 modified some files" "Test-256 added logs"

And I want to find the changeset which has a commit containing Test-254 or Test-256


Solution

  • Mercurial supports advanced selection language called revset. You can access the help with hg help revset.

    It supports both predicates and operators.

    Predicates are for example all() to match all revision or desc(string) to match revisions containing string in their message.

    Operators are x:y for selecting a range or or for an or condition.

    By combining both, you can select the right commits you want:

    • hg log -r "desc('Test-254')" will matches all revision that includes Test-254 in their message.

    • hg log -r "desc('Test-256')" will matches all revision that includes Test-256 in their message.

    • hg log -r "desc('Test-254') or desc('Test-256')" will matches all revision that includes either Test-254 or Test-256 in their message.