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

Unified Diff: patch.py

Issue 7828017: Improve is_delete detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase against HEAD Created 9 years, 4 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/patch_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: patch.py
diff --git a/patch.py b/patch.py
index 8bdeddb1e67e56c89dffed7f0aa0a7e106d546d4..333cbb9f61815521ff83f1b14539f2a14a7b7a17 100644
--- a/patch.py
+++ b/patch.py
@@ -269,9 +269,9 @@ class FilePatchDiff(FilePatchBase):
if not last_line.startswith('---'):
self._fail('Unexpected git diff: --- not following +++.')
# TODO(maruel): new == self.filename.
- if new != self.mangle(match.group(1)) and '/dev/null' != match.group(1):
- # TODO(maruel): Can +++ be /dev/null? If so, assert self.is_delete ==
- # True.
+ if '/dev/null' == match.group(1):
+ self.is_delete = True
+ elif new != self.mangle(match.group(1)):
self._fail('Unexpected git diff: %s != %s.' % (new, match.group(1)))
if lines:
self._fail('Crap after +++')
@@ -323,10 +323,9 @@ class FilePatchDiff(FilePatchBase):
if match:
if not last_line.startswith('---'):
self._fail('Unexpected diff: --- not following +++.')
- if (self.mangle(match.group(1)) != self.filename and
- match.group(1) != '/dev/null'):
- # TODO(maruel): Can +++ be /dev/null? If so, assert self.is_delete ==
- # True.
+ if match.group(1) == '/dev/null':
+ self.is_delete = True
+ elif self.mangle(match.group(1)) != self.filename:
self._fail('Unexpected diff: %s.' % match.group(1))
if lines:
self._fail('Crap after +++')
« no previous file with comments | « no previous file | tests/patch_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698