Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

#2090 closed defect (fixed)

Incorrect diff line numbering in case of inserting at top of the file.

Reported by: Shunichi Goto <gotoh@…> Owned by: Christopher Lenz
Priority: normal Milestone: 0.9
Component: version control/changeset view Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

There's a bug of making line number (offset) of diff by hdf_diff() in case of insertion at the top of file.

See http://projects.edgewall.com/trac/changeset/2234#file1 for example. 'equal' part should be start as line number 1 and 8.

Here's a patch.

  • diff.py

     
    115115    nn = n + n
    116116    group = []
    117117    for tag, i1, i2, j1, j2 in opcodes:
    118         if tag == 'equal' and i1 == 0:
     118        if tag == 'equal' and i1 == 0 and j1 == 0:
    119119            i1, j1 = max(i1, i2 - n), max(j1, j2 - n)
    120         if tag == 'equal' and i2 - i1 > nn:
     120        elif tag == 'equal' and i2 - i1 > nn:
    121121            group.append((tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)))
    122122            yield group
    123123            group = []

Attachments (0)

Change History (2)

comment:1 by Christopher Lenz, 19 years ago

Milestone: 0.9
Owner: changed from Jonas Borgström to Christopher Lenz
Status: newassigned

Good catch, and thanks for the patch! :-)

comment:2 by Christopher Lenz, 19 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [2264].

Note that the patch didn't completely solve the problem, but was a good starting point. I've added a unit test to make sure this doesn't resurface. Thanks again!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.