On Wed, Jun 12, 2013 at 2:25 PM, Julian Foad <julianfoad_at_btopenworld.com> wrote:
> Markus Schaber wrote:
>
>> On Mon, Jun 10, 2013 at 01:38:48PM -0000, danielsh_at_apache.org wrote:
>>> It would have been easy to find what revision removed the line break if we
>>> had a reverse blame --- that is, a blame that walks the chain of diffs from
>>> newerto older, rather than from older to newer.
>>
>> +1
>>
>>> While we're talking about blame improvements, another one is blame a line
>>> range: stop as soon as every line in a given [X, Y] range is accounted for
>>> (use-case: svn blame | grep -5 '/line I am looking at/'). Bert says that
>>> stop as soon as "at least one" line in a given range would be useful for
>>> him (use-case: "which revision last changed [this function definition]?")
>>> and suggests that API users would find a callback that allows them to decide
>>> when to stop gathering further blame information.
>>
>> Agreed.
>>
>> May be this way also allows to do queries for deleted lines by making the
>> callback stop when he finds a deleted line in a given range.
>
> I have thought before that it would sometimes be useful to include blame information on the gaps between lines. For each gap between adjacent lines (and before the first and after the last line), there is a revision in which any text between these two lines was deleted.
>
> Example: blame -r1:30 foo.c_at_30 could produce these (revnum | line-text) pairs:
> r20 | "int main()"
> r20 | "{"
> r25 | NULL
> r30 | " return 0;"
> r20 | "}"
>
> where NULL means some line(s) were at this position in r24 but nothing was here in r25 up to the revision being blamed.
>
I'm not sure about your idea, Julian (still have to wrap my head
around it), but I'll try to give some more context about Daniel's
suggestion:
Just to clarify: there are now two notions of "reverse blame".
1) Give me normal blame output (i.e. "show me the lines of the working
file (or the youngest file in the given revision range), and show me
at each line the revnumber where it was last added"), *but* do it
walking the history backwards. So the output should be exactly the
same as "normal blame" (no visible effect for the user), but we
optimize the algorithm, and (possibly) have the ability to give
partial information to the user early (e.g. a GUI could gradually show
the revnumbers next to the lines, as they come in, calculated by the
"backwards walking" algorithm). Also, we'd have the ability to stop
the calculation early, if all the lines have been "blamed".
2) Give me "reverse blame" output, meaning: show me lines of the
oldest file in the given revision range, and show me at each line the
revnumber where the line was last present. That allows you to see
where a line was deleted. So in this case the user is actually asking
the reverse question (it's like you change the direction of the time
arrow, and then request a "normal blame").
Perhaps 1 should grow another name, like "backward walking blame
algorithm" or .... It's really an implementation detail, most users
will be unaware of it. It'll be important for API users though (at
least if we want to expose the partial information stuff).
The two notions are perfectly orthogonal. The "algorithm reversion"
can also be applied to the "reverse blame".
--
Johan
Received on 2013-06-12 17:01:16 CEST