Fossil

View Ticket
Login
Ticket UUID: f0f9aff371f26b4eebb1ded3cabc70c956c6cae7
Title: 'annotate' misses changes.
Status: Closed Type: Code_Defect
Severity: Important Priority:
Subsystem: Resolution: Fixed
Last Modified: 2011-10-19 20:16:18
Version Found In: [047e06193b] 2011-04-13
Description:
I've a branch where I'm interested on the source of this line of code, at point
2011-04-28:
<verbatim>
const bool debugErrorToFile = true;
</verbatim>

Looking at annotate, I see:
<verbatim>
ad13e86e1e 2010-09-28  llbatlle:     const bool debugErrorToFile = true;
</verbatim>

I don't trust it.. and I find a commit in the same branch, on 2011-04-08, that
introduced the change. So, annotate was not showing it.

I write a commit today (2011-05-05), setting back the debugErrorToFile to
false. Then I test annotate again, expecting to see the very recent commit. But
I get:
<verbatim>
8c918ba0e2 2010-10-25  llbatlle:     const bool debugErrorToFile = false;
</verbatim>

So, annotate is getting confused somehow. I can completely reproduce it, but I
cannot give the repository as it contains private files.

<hr /><i>viriketo added on 2011-05-05 15:16:35 UTC:</i><br />
Just testing the most recent commit in this repository: [74c86dd1da6]

Notice that the diff says:
<verbatim>
+  if( showClosed ){
+    db_prepare(&q,
+      "SELECT value FROM tagxref"
+      " WHERE tagid=%d AND value NOT NULL "
+      "EXCEPT "
</verbatim>

while annotate says
<verbatim>
74c86dd1da 2011-05-04       drh:   if( showClosed ){
518439507a 2010-08-15       drh:     db_prepare(&q,        <== This line
74c86dd1da 2011-05-04       drh:       "SELECT value FROM tagxref"
74c86dd1da 2011-05-04       drh:       " WHERE tagid=%d AND value NOT NULL "
74c86dd1da 2011-05-04       drh:       "EXCEPT "
</verbatim>

<hr /><i>viriketo added on 2011-05-05 21:43:57 UTC:</i><br />
I think the problem has to do with line numbering. Look at this: [/artifact/99f393dce665c790?ln|version of the branch.c above] looking at all the lines and their numbers. There are many wrong line numbers.

<hr /><i>viriketo added on 2011-05-05 21:48:17 UTC:</i><br />
Sorry. Reloading the page I see the line numbers fine. I think my previous comment misleads, as I think it was due to a problem in my browser, and not in fossil.

<hr /><i>viriketo added on 2011-05-05 22:00:38 UTC:</i><br />
From what I see in [/artifact/d9bd197c10a97fb9e7f3f8d88be457738b3cc7b1?ln=688|diff.c:688] and [/artifact/d9bd197c10a97fb9e7f3f8d88be457738b3cc7b1?ln=771|diff.c:771], the annotate procedure goes by looking at older and older commits, and when parts of the lines are equal, the older commit is taken.

I think that this makes the 'annotate' show, sometimes, "the earliest commit with that change", instead of "the last commit with that change".

Other VCS show in 'annotate' the last change in every given line. This is the behaviour I'd prefer, but I barely know anything about diff algorithms, so I hope someone takes the job of implementing this usual kind of annotate.

<hr /><i>viriketo added on 2011-05-06 19:15:41 UTC:</i><br />
Sorry, but I reopen the ticket.

I'm trying the fossil version [9a63d1f048] 2011-05-06, which should have the changes that brought the ticket into Fixed.

As I said in the initial ticket entry, I had committed <kbd>const bool debugErrorToFile = false;</kbd> in 2011-05-05. If I use 'annotate' on that file with the new fossil version, I get:
<verbatim>
f794dd718d 2011-03-01  llbatlle:     const bool debugErrorToFile = false;
</verbatim>

which is different than before your changes, but still wrong.

<hr /><i>viriketo added on 2011-05-06 19:18:48 UTC:</i><br />
I'm trying <code>fossil annotate --limit 1 FILE</code>, and although the file was modified on 2011-05-05, it shows all the file annotations in 2011-03-01. So there may be a problem on getting the initial version.

<hr /><i>viriketo added on 2011-05-06 19:27:18 UTC:</i><br />
I just noticed that the *web* annotate shows good results. It's only the *commandline* annotate showing the troubles.

<hr /><i>viriketo added on 2011-05-07 14:14:54 UTC:</i><br />
I investigated a bit more... the terminal 'annotate' uses a query like this:
<verbatim>
  mid = db_int(0, "SELECT mid FROM mlink WHERE fid=%d AND fnid=%d", fid, fnid);
</verbatim>

that does not give a SINGLE result. Different checkins may have the very same file artifact, and it needs further code to decide what checkin is of interest.

Then, it needs some code to choose what is of the interest of the requester.

<hr /><i>viriketo added on 2011-10-19 20:16:18 UTC:</i><br />
Merged to trunk on [e161670939].