Commit 6f19a4d2 authored by Kai Willadsen's avatar Kai Willadsen

patchdialog: Hack around difflib not handling unicode file labels

parent 9d6fb085
......@@ -87,11 +87,16 @@ class PatchDialog(gnomeglade.Component):
names = [self.filediff.textbuffer[i].data.label for i in range(3)]
prefix = os.path.commonprefix(names)
names = [n[prefix.rfind("/") + 1:] for n in names]
# difflib doesn't handle getting unicode file labels
names = [n.encode('utf8') for n in names]
buf = self.textview.get_buffer()
text0, text1 = texts[indices[0]], texts[indices[1]]
name0, name1 = names[indices[0]], names[indices[1]]
diff_text = "".join(difflib.unified_diff(text0, text1, name0, name1))
diff = difflib.unified_diff(text0, text1, name0, name1)
unicodeify = lambda x: x.decode('utf8') if isinstance(x, str) else x
diff_text = "".join(unicodeify(d) for d in diff)
buf.set_text(diff_text)
def run(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment