Confusing "hg grep" results
Steve Borho
steve at borho.org
Wed Jul 27 18:16:25 UTC 2011
On Wed, Jul 27, 2011 at 12:53 PM, Kevin Bullock
<kbullock+mercurial at ringworld.org> wrote:
> On Jul 27, 2011, at 12:15 PM, Haszlakiewicz, Eric wrote:
>
>>> -----Original Message-----
>>> From: mercurial-bounces at selenic.com [mailto:mercurial-
>>> On Jul 26, 2011, at 7:18 PM, Antoine Pitrou wrote:
>>>> "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 that's not what's going on here. If revision X-2 doesn't have the string, X-1 adds it, and X still has it, then X will still be the revision shown by `hg grep` even though `hg log -pr X` won't contain it.
Short summary: you probably want to use -a
Slightly longer summary: you might want to use thg grep
--
Steve Borho
More information about the Mercurial
mailing list