Fix git cl format --python --full

Make `git cl format --python -full --dry-run` return non-zero exit code if
files are not well formatted.

Make `git cl format --python -full --diff` print diff, rather than new file
contents.

Change-Id: I666d360051563898d3508d776817bf9a61433cb0
Reviewed-on: https://chromium-review.googlesource.com/1081340
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 3d4f476..71d3b81 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -5851,12 +5851,15 @@
 
     if opts.full:
       if python_diff_files:
-        cmd = [yapf_tool]
-        if not opts.dry_run and not opts.diff:
-          cmd.append('-i')
-        stdout = RunCommand(cmd + python_diff_files, cwd=top_dir)
-        if opts.diff:
-          sys.stdout.write(stdout)
+        if opts.dry_run or opts.diff:
+          cmd = [yapf_tool, '--diff'] + python_diff_files
+          stdout = RunCommand(cmd, error_ok=True, cwd=top_dir)
+          if opts.diff:
+            sys.stdout.write(stdout)
+          elif len(stdout) > 0:
+            return_value = 2
+        else:
+          RunCommand([yapf_tool, '-i'] + python_diff_files, cwd=top_dir)
     else:
       # TODO(sbc): yapf --lines mode still has some issues.
       # https://github.com/google/yapf/issues/154