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

Unified Diff: rietveld.py

Issue 7840003: Make rietveld status handling saner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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 | « no previous file | tests/rietveld_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 df529ad6efb02bef5d3cbf9ee017d8edfee103ed..2320f3d2b974c31840c3ac3899443dfeea7d957b 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -125,13 +125,13 @@ class Rietveld(object):
raise patch.UnsupportedPatchFormat(
filename, 'File\'s status is None, patchset upload is incomplete.')
- # TODO(maruel): That's bad, it confuses property change.
- status = status.strip()
-
- if status == 'D':
+ if status[0] == 'D':
+ if status[0] != status.strip():
Dirk Pranke 2011/09/06 20:21:48 Nit: wonder if this might be clearer with 'if stat
M-A Ruel 2011/09/06 20:23:59 No because status is a svn status line, which cont
Dirk Pranke 2011/09/06 22:35:36 Ah, right. LGTM, then.
+ raise patch.UnsupportedPatchFormat(
+ filename, 'Deleted file shouldn\'t have property change.')
# Ignore the diff.
out.append(patch.FilePatchDelete(filename, state['is_binary']))
- elif status in ('A', 'M'):
+ elif status[0] in ('A', 'M'):
svn_props = self.parse_svn_properties(
state.get('property_changes', ''), filename)
if state['is_binary']:
@@ -142,20 +142,27 @@ class Rietveld(object):
is_new=(status[0] == 'A')))
else:
# Ignores num_chunks since it may only contain an header.
+ diff = None
try:
diff = self.get_file_diff(issue, patchset, state['id'])
except urllib2.HTTPError, e:
if e.code == 404:
raise patch.UnsupportedPatchFormat(
filename, 'File doesn\'t have a diff.')
+ raise
+ # It may happen on property-only change or svn copy without diff.
+ if not diff:
+ # Support this use case if it ever happen.
+ raise patch.UnsupportedPatchFormat(
+ filename, 'Empty diff is not supported yet.\n')
out.append(patch.FilePatchDiff(filename, diff, svn_props))
if status[0] == 'A':
# It won't be set for empty file.
out[-1].is_new = True
else:
- # TODO(maruel): Add support for MM, A+, etc. Rietveld removes the svn
- # properties from the diff.
- raise patch.UnsupportedPatchFormat(filename, status)
+ raise patch.UnsupportedPatchFormat(
+ filename, 'Change with status \'%s\' is not supported.' % status)
+
return patch.PatchSet(out)
@staticmethod
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698