Add extra context for added and deleted empty files.

Review Request #5802 — Created May 12, 2014 and submitted — Latest diff uploaded

Information

RBTools
master
fb2d6fd...

Reviewers

Review Board could not handle added or deleted empty files in SVN, Mercurial,
and Perforce diffs since the diff output from svn diff/hg diff did not
provide enough context on empty files. This change adds extra processing in
RBTools to generate a diff with extra information on any added or deleted empty
files, if the Review Board server has the empty_files capability for the
SCM tool in question.

The original SVN diff output of an added/deleted empty file was:

Index: foo
===================================================================

After this change, the SVN diff of an added empty file becomes:

Index: foo\t(added)
===================================================================
--- foo\t(<base_revision>)
+++ foo\t(<tip_revision>)

For Mercurial, the diff of an added empty file is now:

diff -r <base_revision> -r <tip_revision> foo
--- /dev/null\tThu Jan 01 00:00:00 1970 +0000
+++ b/foo\t<date>

For Perforce, the diff of an added empty file is:

==== //depot/foo#0 ==A== //depot/foo ====

Ran rbt post on a RB server with the empty_files capabilities with different
SVN, Mercurial, and Perforce diffs, and verified that the modified diffs were
as expected:
- Diff with 1 added empty file
- Diff with 1 added empty file, 1 added non-empty file
- Diff with 1 deleted empty file
- Diff with 1 deleted empty file, 1 deleted non-empty file
- Diff with 1 added empty file, 1 deleted empty file
- Diff with 1 added empty file, 1 added non-empty file, 1 deleted empty file,
1 deleted non-empty file, 1 modified file

Ran rbt post on a RB server without the empty_files capabilities, and
verified that the generated diffs did not include any extra information on
added/deleted empty files. These added/deleted empty files were not included in
the review requests.

Ran unit tests. More testing was done in /r/5785 as well.