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

Unified Diff: patch.py

Issue 6877038: Improve patch handling and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 8 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 f6b19aca2ebf5efb488b1135843ee7730247510c..316333f29bd158081791f8afa97a867700880b60 100644
--- a/patch.py
+++ b/patch.py
@@ -246,8 +246,14 @@ class FilePatchDiff(FilePatchBase):
match = re.match(r'^--- ([^\t]+).*$', lines.pop(0))
if not match:
continue
- if match.group(1) not in (self.filename, '/dev/null'):
- self._fail('Unexpected diff: %s.' % match.group(1))
+ # For copy and renames, it's possible that the -- line doesn't match +++,
+ # so don't check match.group(1) to match self.filename or '/dev/null', it
+ # can be anything else.
+ # TODO(maruel): Handle rename/copy explicitly.
+ # if match.group(1) not in (self.filename, '/dev/null'):
+ # self.source_file = match.group(1)
+ if not lines:
+ self._fail('Nothing after header.')
match = re.match(r'^\+\+\+ ([^\t]+).*$', lines.pop(0))
if not match:
self._fail('Unexpected diff: --- not following +++.')
« 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