Fix tab expansion in inter-patchset diff
There are some lines which were being read as byte arrays and were not decoded into strings which was causing them to bypass tab expansion (because they caused an exception which was caught and the un-expanded text was used instead). Correct those cases and disable the exception handler so that we can identify any other cases by triggering a crash. Change-Id: I4b34132290fc8611cc770d572068197b33c0789c
This commit is contained in:
parent
c4b7fc6e37
commit
cd2538e04a
@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -173,6 +174,8 @@ class DiffChangedChunk(DiffChunk):
|
||||
context = False
|
||||
|
||||
class DiffFile(object):
|
||||
log = logging.getLogger('gertty.gitrepo')
|
||||
|
||||
def __init__(self):
|
||||
self.newname = 'Unknown File'
|
||||
self.oldname = 'Unknown File'
|
||||
@ -219,7 +222,8 @@ class DiffFile(object):
|
||||
else:
|
||||
(a, b) = l
|
||||
return (a, re.sub(r'\t', replace, b))
|
||||
except:
|
||||
except Exception:
|
||||
self.log.exception("Error expanding tabs")
|
||||
return l
|
||||
|
||||
def addDiffLines(self, old, new):
|
||||
@ -537,7 +541,10 @@ class Repo(object):
|
||||
f.old_lineno = 1
|
||||
f.new_lineno = 1
|
||||
for line in blob.data_stream.read().splitlines():
|
||||
f.addContextLine(line)
|
||||
if isinstance(line, six.string_types):
|
||||
f.addContextLine(line)
|
||||
else:
|
||||
f.addContextLine(line.decode('utf8'))
|
||||
f.finalize()
|
||||
return files
|
||||
|
||||
@ -554,7 +561,10 @@ class Repo(object):
|
||||
except KeyError:
|
||||
return None
|
||||
for line in blob.data_stream.read().splitlines():
|
||||
f.addContextLine(line)
|
||||
if isinstance(line, six.string_types):
|
||||
f.addContextLine(line)
|
||||
else:
|
||||
f.addContextLine(line.decode('utf8'))
|
||||
f.finalize()
|
||||
return f
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user