Blame
Posted: Tue Jan 31, 2006 6:39 pm
How would I go about implementing Subversion style blame command (annotate in CVS) with a, say, an array of fulltext revisions in PHP?
My thought process
The first part of the process is diff'ing the files. I would preparse the array by forming an array of deltas/diffs between each fulltext revision. Then, I would scroll through the array, starting with the most recent diff. Here's where it gets tricky.
The program would have to identify, from the diff, which lines were changed/added in the later revision. The first iteration, it's easy: there's a one-to-one relationship between the lines in the diff, and the lines in the most current revision. But as you scroll back further, line numbers shift as lines are added and removed. I'm not exactly sure how I would keep track. (so this is the trickiest part). During all this, I'd be assigning authors/revision numbers to the lines. Then it all gets output.
Once again, the hardest part is tying the result lines in the deltas to the current revision. Anyone do something like this, or intimately familiar with revision systems?
My thought process
The first part of the process is diff'ing the files. I would preparse the array by forming an array of deltas/diffs between each fulltext revision. Then, I would scroll through the array, starting with the most recent diff. Here's where it gets tricky.
The program would have to identify, from the diff, which lines were changed/added in the later revision. The first iteration, it's easy: there's a one-to-one relationship between the lines in the diff, and the lines in the most current revision. But as you scroll back further, line numbers shift as lines are added and removed. I'm not exactly sure how I would keep track. (so this is the trickiest part). During all this, I'd be assigning authors/revision numbers to the lines. Then it all gets output.
Once again, the hardest part is tying the result lines in the deltas to the current revision. Anyone do something like this, or intimately familiar with revision systems?