Confusing "hg grep" results

Steve Borho steve at borho.org
Thu Jul 28 05:13:13 UTC 2011


On Wed, Jul 27, 2011 at 5:30 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Mike Meyer <mwm <at> mired.org> writes:
>>
>> > > "hg grep" returns revisions which don't seem to involve the requested
>> > string:
>> > >
>> > > $ hg grep ESHUTDOWN
>> > > [...]
>> > > Modules/errnomodule.c:69885:#ifdef ESHUTDOWN
>>
>> > > [...]
>> > >
>> > > $ hg log -r 69885 -vp | grep ESHUTDOWN
>> > > $
>> > > Am I misunderstanding what "hg grep" is supposed to do?
>> > From `hg help grep`:
>> >
>> >     [...] grep only prints output for the first revision of a file in
>> >     which it finds a match.
>> >
>> > As I understand it, `hg grep` doesn't search the _diffs_ for the given
>> > string; it searches for the given string in the entire _tree_ at the
>> > given revision (or at the most recent revision that contains the
>> > string).
>> >
>> > The help is a bit confusing though.
>> Sure, but if revision X has the string and revision X-1 does not, then
> shouldn't the diffs for revision X show the string being added?
>>
>> Yes, but it shows you the most *recent* revision with that string in it.
>
> I'm not sure I understand. The help mentions "the first revision". Is "first"
> equivalent to "most recent" here?
>
> Besides, the displayed revision is *not* the most recent revision in which the
> query string appears in this file (since it's there in tip anyway), so I'm still
> clueless as to how this command behaves.

It was most likely the last revision to touch the file.

-- 
Steve Borho



More information about the Mercurial mailing list