Silasvb
Silasvb

Reputation: 332

Regular expression based searching for Mercurial changeset

I would like to be able to perform regular expression-type searches on Mercurial changesets and display results using log.

I've come up with the following function, which seems to work, but has a number of possible bugs (e.g. $1 is in line of text containing the word changeset).

function hgs { hg log `hg log | grep changeset | grep "$1" \
    | sed 's/changeset: *//g' | sed 's/:.*$//g' | \
    awk '{print " -r " $0}'`; }

export -f hgs

Am I trying to recreate something here that already exists as a well-tested solution elsewhere?

Upvotes: 0

Views: 661

Answers (1)

planetmaker
planetmaker

Reputation: 6044

It pretty much looks like a combination of using hg grep, making use revsets and templated output could possibly help you (check hg help revsets, hg help templates, hg help grep and possibly also hg help fileset).

E.g. to find all changes to config.lib or where the commit message contains 'pkgconfig' which were made after 2010:

hg log -r"(file('config.lib') or desc('pkgconfig')) and date('>2010')"

revsets are very powerful. You can also sort, limit to a certain number of changesets, combine different requirements...

Using the --template argument to hg log can be used to format the output in any pattern you desire.

Upvotes: 1

Related Questions