From 0d6c35a85b49a01663da48a2e9d54345dc684fbe Mon Sep 17 00:00:00 2001 From: David Trowbridge Date: Mon, 5 Oct 2009 01:12:15 -0700 Subject: Don't produce broken diff files with files that don't end in a newline. Some people have source files that don't end in a newline. In this case, it's possible for us to create a diff file where the end of one file is joined on the same line as the header for the next file. This change adds an extra check to _do_diff to make sure that we don't make broken diffs when people have broken files. Fixes bug 1340. --- rbtools/postreview.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rbtools/postreview.py b/rbtools/postreview.py index fd98e7e..76c6be5 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -1756,6 +1756,11 @@ class PerforceClient(SCMClient): dl[0] = "--- %s\t%s#%s\n" % (local_path, depot_path, base_revision) dl[1] = "+++ %s\t%s\n" % (local_path, timestamp) + # Not everybody has files that end in a newline (ugh). This ensures + # that the resulting diff file isn't broken. + if dl[-1][-1] != '\n': + dl.append('\n') + return dl def _write_file(self, depot_path, tmpfile): -- cgit v1.2.3