Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1791)

Unified Diff: rietveld.py

Issue 7054057: Add support for empty files, __init__.py is a common example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « checkout.py ('k') | tests/patch_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rietveld.py
diff --git a/rietveld.py b/rietveld.py
index 56e0a441912b038faefacf1fc1caf14f1eb6ddef..c2045ac3311ea7375b496cd7473c4fd2bf1cedfb 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -142,12 +142,17 @@ class Rietveld(object):
props,
is_new=(status[0] == 'A')))
else:
- if state['num_chunks']:
+ # Ignores num_chunks since it may only contain an header.
+ try:
diff = self.get_file_diff(issue, patchset, state['id'])
- else:
- raise patch.UnsupportedPatchFormat(
- filename, 'File doesn\'t have a diff.')
+ except urllib2.HTTPError, e:
+ if e.code == 404:
+ raise patch.UnsupportedPatchFormat(
+ filename, 'File doesn\'t have a diff.')
out.append(patch.FilePatchDiff(filename, diff, props))
+ if status[0] == 'A':
+ # It won't be set for empty file.
+ out[-1].is_new = True
else:
# Line too long (N/80)
# pylint: disable=C0301
« no previous file with comments | « checkout.py ('k') | tests/patch_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698