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

Side by Side Diff: patch.py

Issue 6825085: Add script to apply a patch from rietveld. (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 unified diff | Download patch | Annotate | Revision Log
« apply_issue.py ('K') | « apply_issue.py ('k') | rietveld.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Utility functions to handle patches.""" 5 """Utility functions to handle patches."""
6 6
7 import posixpath 7 import posixpath
8 import os 8 import os
9 import re 9 import re
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 def get(self): 83 def get(self):
84 return self.data 84 return self.data
85 85
86 86
87 class FilePatchDiff(FilePatchBase): 87 class FilePatchDiff(FilePatchBase):
88 """Patch for a single file.""" 88 """Patch for a single file."""
89 89
90 def __init__(self, filename, diff, svn_properties): 90 def __init__(self, filename, diff, svn_properties):
91 super(FilePatchDiff, self).__init__(filename) 91 super(FilePatchDiff, self).__init__(filename)
92 if not diff:
93 self._fail('File doesn\'t have a diff.')
92 self.diff_header, self.diff_hunks = self._split_header(diff) 94 self.diff_header, self.diff_hunks = self._split_header(diff)
93 self.svn_properties = svn_properties or [] 95 self.svn_properties = svn_properties or []
94 self.is_git_diff = self._is_git_diff_header(self.diff_header) 96 self.is_git_diff = self._is_git_diff_header(self.diff_header)
95 self.patchlevel = 0 97 self.patchlevel = 0
96 if self.is_git_diff: 98 if self.is_git_diff:
97 self._verify_git_header() 99 self._verify_git_header()
98 assert not svn_properties 100 assert not svn_properties
99 else: 101 else:
100 self._verify_svn_header() 102 self._verify_svn_header()
101 103
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 for patch in self.patches: 273 for patch in self.patches:
272 patch.set_relpath(relpath) 274 patch.set_relpath(relpath)
273 275
274 def __iter__(self): 276 def __iter__(self):
275 for patch in self.patches: 277 for patch in self.patches:
276 yield patch 278 yield patch
277 279
278 @property 280 @property
279 def filenames(self): 281 def filenames(self):
280 return [p.filename for p in self.patches] 282 return [p.filename for p in self.patches]
OLDNEW
« apply_issue.py ('K') | « apply_issue.py ('k') | rietveld.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698