| OLD | NEW |
| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 # 'diff' header. That the only remaining invariant. | 266 # 'diff' header. That the only remaining invariant. |
| 267 if not self.filename in self.diff_header: | 267 if not self.filename in self.diff_header: |
| 268 self._fail('Diff seems corrupted.') | 268 self._fail('Diff seems corrupted.') |
| 269 | 269 |
| 270 | 270 |
| 271 class PatchSet(object): | 271 class PatchSet(object): |
| 272 """A list of FilePatch* objects.""" | 272 """A list of FilePatch* objects.""" |
| 273 | 273 |
| 274 def __init__(self, patches): | 274 def __init__(self, patches): |
| 275 self.patches = patches | 275 self.patches = patches |
| 276 for p in self.patches: |
| 277 assert isinstance(p, FilePatchBase) |
| 276 | 278 |
| 277 def set_relpath(self, relpath): | 279 def set_relpath(self, relpath): |
| 278 """Used to offset the patch into a subdirectory.""" | 280 """Used to offset the patch into a subdirectory.""" |
| 279 for patch in self.patches: | 281 for patch in self.patches: |
| 280 patch.set_relpath(relpath) | 282 patch.set_relpath(relpath) |
| 281 | 283 |
| 282 def __iter__(self): | 284 def __iter__(self): |
| 283 for patch in self.patches: | 285 for patch in self.patches: |
| 284 yield patch | 286 yield patch |
| 285 | 287 |
| 286 @property | 288 @property |
| 287 def filenames(self): | 289 def filenames(self): |
| 288 return [p.filename for p in self.patches] | 290 return [p.filename for p in self.patches] |
| OLD | NEW |