Is there a way where I can send two choices for git/Mercurial commands?
I want to search the history of git repository and Mercurial repository for specific word, say "commit". However, I am not sure how is it written in commit message "commit" or "com-mit"? So, I want to send these options with the command. I know that if I want to search I will type:
In git:
git log --grep="commit"
In mercurial:
hg log --keyword commit
Any help?
The most flexible way to do this with Mercurial is to use revsets. For your example:
In Python regex syntax,
\b
indicates a word boundary, and the backslash needs to be escaped. The(a|b)
syntax is used to match one or the other. The single quotes surrounding the argument are there so that the shell won't interpret the metacharacters itself.You can also simplify the regular expression by combining revsets with
and
:If you don't need to match words exactly (e.g. if you want to match "committer" and "committed" too, not just "commit"), you can use the keyword revsets:
By using
and
instead ofor
, you can find revisions that match both rather than one of them; also, you can usereverse(...)
to list matches in the reverse order, e.g.: