Skip to content

Commit ecb8345

Browse files
committed
fix the diff again
1 parent 4c76575 commit ecb8345

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

elixir/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ def get_diff(self, version, version_other, path):
272272
if len(line) == 0:
273273
continue
274274
elif line[0] == '+':
275-
line_num, changes = line[1:].split(':')
276-
result.append(('+', int(line_num), int(changes)))
275+
line_num_left, line_num_right, changes = line[1:].split(':')
276+
result.append(('+', int(line_num_left), int(line_num_right), int(changes)))
277277
elif line[0] == '-':
278-
line_num, changes = line[1:].split(':')
279-
result.append(('-', int(line_num), int(changes)))
278+
line_num_left, line_num_right, changes = line[1:].split(':')
279+
result.append(('-', int(line_num_left), int(line_num_right), int(changes)))
280280
elif line[0] == '=':
281281
line_num, changes, other_line_num, other_changes = line[1:].split(':')
282282
result.append(('=', int(line_num), int(changes), int(other_line_num), int(other_changes)))

elixir/web_utils.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@ def __init__(self, diff, left: bool, *args, **kwargs):
9090

9191
def get_next_diff_line(self, diff_num, next_diff_line):
9292
next_diff = self.diff[diff_num] if len(self.diff) > diff_num else None
93+
9394
if next_diff is not None:
94-
if next_diff[0] == '-' or next_diff[0] == '+':
95+
if self.left and (next_diff[0] == '-' or next_diff[0] == '+'):
9596
next_diff_line = next_diff[1]
97+
elif next_diff[0] == '-' or next_diff[0] == '+':
98+
next_diff_line = next_diff[2]
9699
elif self.left and next_diff[0] == '=':
97100
next_diff_line = next_diff[1]
98-
elif not self.left and next_diff[0] == '=':
101+
elif next_diff[0] == '=':
99102
next_diff_line = next_diff[3]
103+
else:
104+
raise Exception("invlaid next diff mode")
100105

101106
return next_diff, diff_num+1, next_diff_line
102107

@@ -128,20 +133,20 @@ def wrap_diff(self, source):
128133
except StopIteration:
129134
break
130135

131-
yield line
136+
yield line[0], str(linenum) + ':' + str(next_diff_line) + ':' + line[1]
132137

133138
if linenum == next_diff_line:
134139
if next_diff is not None:
135140
if self.left and next_diff[0] == '+':
136-
yield from self.yield_empty(next_diff[2])
141+
yield from self.yield_empty(next_diff[3])
137142
elif next_diff[0] == '+':
138-
yield from self.mark_lines(source, next_diff[2], 'line-added')
139-
linenum += next_diff[2]
140-
elif not self.left and next_diff[0] == '-':
141-
yield from self.yield_empty(next_diff[2])
143+
yield from self.mark_lines(source, next_diff[3], 'line-added')
144+
linenum += next_diff[3]
145+
elif self.left and next_diff[0] == '-':
146+
yield from self.mark_lines(source, next_diff[3], 'line-removed')
147+
linenum += next_diff[3]
142148
elif next_diff[0] == '-':
143-
yield from self.mark_lines(source, next_diff[2], 'line-removed')
144-
linenum += next_diff[2]
149+
yield from self.yield_empty(next_diff[3])
145150
elif next_diff[0] == '=':
146151
total = max(next_diff[2], next_diff[4])
147152
to_print = next_diff[2] if self.left else next_diff[4]

script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ get_diff()
100100
v_other=`echo $opt2 | version_rev`
101101
diff \
102102
--unchanged-group-format= \
103-
--new-group-format="+%de:%dN%c'\012'" \
104-
--old-group-format="-%dE:%dn%c'\012'" \
103+
--new-group-format="+%de:%dE:%dN%c'\012'" \
104+
--old-group-format="-%de:%dE:%dn%c'\012'" \
105105
--changed-group-format="=%de:%dn:%dE:%dN%c'\012'" \
106106
<(git cat-file blob "$v:`denormalize $opt3`" 2>/dev/null) \
107107
<(git cat-file blob "$v_other:`denormalize $opt3`" 2>/dev/null)

0 commit comments

Comments
 (0)