[PATCH 3 of 3 V2] revset: add a changes(file, fromline, toline[, rev]) revset

Denis Laxalde denis at laxalde.org
Thu Dec 29 04:50:35 EST 2016


Danek Duvall a écrit :
> Denis Laxalde wrote:
>
>> # HG changeset patch
>> # User Denis Laxalde <denis.laxalde at logilab.fr>
>> # Date 1480086890 -3600
>> #      Fri Nov 25 16:14:50 2016 +0100
>> # Node ID 5e5ec2ade2cfc829cffba145193da5801c5b20e7
>> # Parent  c8dfd10c5865cfe882a00595743f3f709f41317f
>> # EXP-Topic linerange-log/revset
>> revset: add a changes(file, fromline, toline[, rev]) revset
>
> What's the use-case for this?  Being able to track changes to some sort of
> syntax block (like a function, paragraph, etc) seems far more valuable than
> a fixed line range (albeit substantially more difficult to implement).

Yes, that's a use case. Being more clever would require understanding of
the syntax of the file at stake, which we currently do not have in diff
algorithm as far as I can tell. Also, relying on syntax would probably
not cover all use cases either. So line numbers range is a first step.

>> +  $ hg log -r 'changes(baz, 2, 40)'
>> +  abort: line range exceeds file size
>> +  [255]
>
> This test seems a bit odd, since a file might change its size over time,
> and you might want to track lines 2-40, even though the file might not have
> at least 40 lines over the course of its history.

Specified line range (2-40 here) should be consistent with the state of
the file at specified revision (current working directory here): the
user is expected to know this information. This message really indicates
invalid input.
Evolution of line range over history is taken into account so that the
span may grow or decrease during ancestors lookup.

> Perhaps the revset simply needs more user-facing documentation for those of
> us without enough imagination?
>

I'll add a note about line range and file size, thanks.


More information about the Mercurial-devel mailing list