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

Unified Diff: rietveld.py

Issue 7857006: Make the rietveld client code ignore file status more often. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: oops 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 9a70ee75eae074b09449f2d78092179764edeabf..0b88eb0eb746ba898d97991f43b5e1b00460ee1a 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -121,53 +121,49 @@ class Rietveld(object):
for filename, state in props.get('files', {}).iteritems():
logging.debug('%s' % filename)
status = state.get('status')
- if status is None:
+ if not status:
raise patch.UnsupportedPatchFormat(
filename, 'File\'s status is None, patchset upload is incomplete.')
+ if status[0] not in ('A', 'D', 'M'):
+ raise patch.UnsupportedPatchFormat(
+ filename, 'Change with status \'%s\' is not supported.' % status)
- if status[0] == 'D':
- if status[0] != status.strip():
- raise patch.UnsupportedPatchFormat(
- filename, 'Deleted file shouldn\'t have property change.')
- # Ignore the diff.
- out.append(patch.FilePatchDelete(filename, state['is_binary']))
- elif status[0] in ('A', 'M'):
- svn_props = self.parse_svn_properties(
- state.get('property_changes', ''), filename)
- if state['is_binary']:
+ svn_props = self.parse_svn_properties(
+ state.get('property_changes', ''), filename)
+
+ if state.get('is_binary'):
+ if status[0] == 'D':
+ if status[0] != status.strip():
+ raise patch.UnsupportedPatchFormat(
+ filename, 'Deleted file shouldn\'t have property change.')
+ out.append(patch.FilePatchDelete(filename, state['is_binary']))
+ else:
out.append(patch.FilePatchBinary(
filename,
self.get_file_content(issue, patchset, state['id']),
svn_props,
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')
- p = patch.FilePatchDiff(filename, diff, svn_props)
- out.append(p)
- if status[0] == 'A':
- # It won't be set for empty file.
- p.is_new = True
- if (len(status) > 1 and
- status[1] == '+' and
- not (p.source_filename or p.svn_properties)):
- raise patch.UnsupportedPatchFormat(
- filename, 'Failed to process the svn properties')
- else:
+ continue
+
+ 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
+
+ # FilePatchDiff() will detect file deletion automatically.
+ p = patch.FilePatchDiff(filename, diff, svn_props)
+ out.append(p)
+ if status[0] == 'A':
+ # It won't be set for empty file.
+ p.is_new = True
+ if (len(status) > 1 and
+ status[1] == '+' and
+ not (p.source_filename or p.svn_properties)):
raise patch.UnsupportedPatchFormat(
- filename, 'Change with status \'%s\' is not supported.' % status)
+ filename, 'Failed to process the svn properties')
return patch.PatchSet(out)
« 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