mercurial: Re: Searching within all the changesets

Greg Lindahl greg at blekko.com
Mon May 17 00:09:43 UTC 2010


On Sun, May 16, 2010 at 12:21:54PM -0400, Harvey Chapman wrote:
> On May 16, 2010, at 10:34 AM, Giorgos Keramidas wrote:
> 
> > Try "hg grep PATTERN [FILE ...]"
> 
> Are there any webpages with examples of hg grep? I can see from the help kind of what it does, but it might be nice to have examples showing typical problems and how hg grep solves them.
> 

Here's an example, please feel free to add it to any wiki page:

I built an inventory and configuration database as follows: each day
every host in the cluster runs a script which collects configuration
information from dmidecode, smartctl, rpm -q -a, etc etc.

These are checked into a mercurial repo, each node's files in a
directory named 'nodename'.

Then to search the database, this script will do:

#!/bin/sh
hg grep --all -f -d $@

Now, if I want to find out where motherboard USE944N0J7 or
disk 9QJ5G3KV has ever been:

% find-sysinfo 9QJ5G3KV
t-211-11/smartctl_i:537:+:Fri Jan 22 08:30:42 2010 -0800:Serial number: 9QJ5G3KV            

% find-sysinfo USE944N0J7
t-211-11/dmidecode:518:+:Wed Dec 09 04:12:26 2009 -0800:	Serial Number: USE944N0J7

A disk or motherboard that moved around would have multiple matching
lines, + when added and - when removed.

-- greg






More information about the Mercurial mailing list