Fix newline warning overwriting final line
In the case that the final line of a file only had a newline change, the line would be omitted from the old side of the diff. Change-Id: I1e2e67fda4943ea38152a3ddd0004aa9210a9fa5 Story: 158
This commit is contained in:
parent
473088474c
commit
9d215d4942
@ -265,10 +265,10 @@ class Repo(object):
|
|||||||
prevstyle = None
|
prevstyle = None
|
||||||
output_old = []
|
output_old = []
|
||||||
output_new = []
|
output_new = []
|
||||||
#socket.send('startold' + repr(old)+'\n')
|
#self.log.debug('startold' + repr(old))
|
||||||
#socket.send('startnew' + repr(new)+'\n')
|
#self.log.debug('startnew' + repr(new))
|
||||||
for line in self.differ.compare(old, new):
|
for line in self.differ.compare(old, new):
|
||||||
#socket.sendall('diff output: ' + line+'\n')
|
#self.log.debug('diff output: ' + line)
|
||||||
key = line[0]
|
key = line[0]
|
||||||
rest = line[2:]
|
rest = line[2:]
|
||||||
if key == '?':
|
if key == '?':
|
||||||
@ -281,7 +281,7 @@ class Repo(object):
|
|||||||
indicator = ' '
|
indicator = ' '
|
||||||
else:
|
else:
|
||||||
indicator = rest[i]
|
indicator = rest[i]
|
||||||
#socket.sendall('%s %s %s %s %s\n' % (i, c, indicator, emphasis, accumulator))
|
#self.log.debug('%s %s %s %s %s' % (i, c, indicator, emphasis, accumulator))
|
||||||
if indicator != ' ' and not emphasis:
|
if indicator != ' ' and not emphasis:
|
||||||
# changing from not emph to emph
|
# changing from not emph to emph
|
||||||
if accumulator:
|
if accumulator:
|
||||||
@ -307,24 +307,25 @@ class Repo(object):
|
|||||||
prevline = None
|
prevline = None
|
||||||
continue
|
continue
|
||||||
if prevline is not None:
|
if prevline is not None:
|
||||||
if prevstyle == 'added':
|
if prevstyle == 'added' or prevstyle == 'context':
|
||||||
output_new.append((prevstyle+'-line', prevline))
|
output_new.append((prevstyle+'-line', prevline))
|
||||||
elif prevstyle == 'removed':
|
if prevstyle == 'removed' or prevstyle == 'context':
|
||||||
output_old.append((prevstyle+'-line', prevline))
|
output_old.append((prevstyle+'-line', prevline))
|
||||||
if key == '+':
|
if key == '+':
|
||||||
prevstyle = 'added'
|
prevstyle = 'added'
|
||||||
elif key == '-':
|
elif key == '-':
|
||||||
prevstyle = 'removed'
|
prevstyle = 'removed'
|
||||||
|
elif key == ' ':
|
||||||
|
prevstyle = 'context'
|
||||||
prevline = rest
|
prevline = rest
|
||||||
#socket.sendall('prev'+repr(prevline)+'\n')
|
#self.log.debug('prev'+repr(prevline))
|
||||||
if prevline is not None:
|
if prevline is not None:
|
||||||
if prevstyle == 'added':
|
if prevstyle == 'added':
|
||||||
output_new.append((prevstyle+'-line', prevline))
|
output_new.append((prevstyle+'-line', prevline))
|
||||||
elif prevstyle == 'removed':
|
elif prevstyle == 'removed':
|
||||||
output_old.append((prevstyle+'-line', prevline))
|
output_old.append((prevstyle+'-line', prevline))
|
||||||
#socket.sendall(repr(output_old)+'\n')
|
#self.log.debug(repr(output_old))
|
||||||
#socket.sendall(repr(output_new)+'\n')
|
#self.log.debug(repr(output_new))
|
||||||
#socket.sendall('\n')
|
|
||||||
return output_old, output_new
|
return output_old, output_new
|
||||||
|
|
||||||
header_re = re.compile('@@ -(\d+)(,\d+)? \+(\d+)(,\d+)? @@')
|
header_re = re.compile('@@ -(\d+)(,\d+)? \+(\d+)(,\d+)? @@')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user