hg grep users, feedback wanted

Steve Borho steve at borho.org
Wed May 19 21:22:45 UTC 2010


On Wed, May 19, 2010 at 3:57 PM, Dan Villiom Podlaski Christiansen
<danchr at gmail.com> wrote:
> On 19 May 2010, at 22:42, Steve Borho wrote:
>
>> On Wed, May 19, 2010 at 3:22 PM, Dan Villiom Podlaski Christiansen
>> <danchr at gmail.com> wrote:
>>> How about adding option for the old behaviour? Something like --changes or --changed. Personally, I don't see the value of only inspecting changed files; wouldn't users be more likely to expect the search to be restricted to actual changes?
>>>
>>> Making -rN:M match the entire contents should be all *that* expensive. It would inspect the entire contents of the first changeset, and for every subsequent changest, only changes from the previous one would be inspected.
>
> Ehm, I didn't quite get it right, here. What I meant was:
> Making -rN:M match the entire contents *shouldn't*…
>
>> For a true search of the deltas in every changeset, you have to use
>> --all argument.  This essentially performs 'hg log -p | grep foo',
>> which is extremely useful.
>>
>> It's not clear to me what function the old revision range search
>> serves, after the new functionality is added.
>>
>> $ hg grep --all foo -r N:M
>>
>> shows every change made between N and M that modified a line with 'foo' in it.
>>
>> $ hg grep foo -rN:M
>>
>> reports all files that were modified between N and M and happened to
>> have 'foo' somewhere in their contents. ?WTF?
>
> I think we're pretty much in agreement here :) I don't see how that behaviour makes sense either. From my perspective, we could do it like this:
>
> We decide that the old behaviour doesn't make sense, but want to retain something similar. This could be a ‘--changes’ option which causes only the changes contained in a changeset to be inspected.
>
> Alternately, we decide that the old behaviour *does* make sense. This could be a ‘--changed’ option for inspecting changed files. If we want to offer both, we could make them something like ‘--only-changes’ and ‘--changed-files’.
>
>> If it was up to me, I would drop --all and make it implied when a
>> revision range is specified.  Leaving us with:
>>
>> $ hg grep foo - scan working copy
>> $ hg grep -r N foo - scan files at revision N
>
> I like this as well :)
>
>> $ hg grep -r N:M foo - scan changes between N and M
>
> This strikes me as somewhat odd. I'd expect it to scan — and possibly match — the entire contents of the changesets from N to M. As an implementation detail, it would only inspect actual changes relative to the previous changeset, but this would be transparent to the user.
>
> In my mind, a --changes/--changed/whatever would apply to all possible ways to call ‘grep’. Specifying a single revision, causes only the changes relative to its ancestors to be inspected. Not specifying a changeset effectively means inspecting the output of ‘hg diff’. Specifying a range mainly affects the first changeset, as well as any merge changesets.

Ok, now I follow your intent.  --changed is a good description of the
old behavior.  I'll have to mull this over for a bit.

--
Steve Borho



More information about the Mercurial mailing list