OLD | NEW |
1 # coding=utf8 | 1 # coding=utf8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if match: | 384 if match: |
385 # It is necessary to parse it because there may be no hunk, like when the | 385 # It is necessary to parse it because there may be no hunk, like when the |
386 # file was empty. | 386 # file was empty. |
387 self.is_delete = True | 387 self.is_delete = True |
388 return | 388 return |
389 | 389 |
390 match = re.match(r'^new(| file) mode (\d{6})$', line) | 390 match = re.match(r'^new(| file) mode (\d{6})$', line) |
391 if match: | 391 if match: |
392 mode = match.group(2) | 392 mode = match.group(2) |
393 # Only look at owner ACL for executable. | 393 # Only look at owner ACL for executable. |
394 # TODO(maruel): Add support to remove a property. | |
395 if bool(int(mode[4]) & 1): | 394 if bool(int(mode[4]) & 1): |
396 self.svn_properties.append(('svn:executable', '*')) | 395 self.svn_properties.append(('svn:executable', '*')) |
| 396 else: |
| 397 self.svn_properties.append(('svn:executable', None)) |
397 return | 398 return |
398 | 399 |
399 match = re.match(r'^--- (.*)$', line) | 400 match = re.match(r'^--- (.*)$', line) |
400 if match: | 401 if match: |
401 if last_line[:3] in ('---', '+++'): | 402 if last_line[:3] in ('---', '+++'): |
402 self._fail('--- and +++ are reversed') | 403 self._fail('--- and +++ are reversed') |
403 if match.group(1) == '/dev/null': | 404 if match.group(1) == '/dev/null': |
404 self.is_new = True | 405 self.is_new = True |
405 elif self.mangle(match.group(1)) != old: | 406 elif self.mangle(match.group(1)) != old: |
406 # git patches are always well formatted, do not allow random filenames. | 407 # git patches are always well formatted, do not allow random filenames. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 def __iter__(self): | 506 def __iter__(self): |
506 for patch in self.patches: | 507 for patch in self.patches: |
507 yield patch | 508 yield patch |
508 | 509 |
509 def __getitem__(self, key): | 510 def __getitem__(self, key): |
510 return self.patches[key] | 511 return self.patches[key] |
511 | 512 |
512 @property | 513 @property |
513 def filenames(self): | 514 def filenames(self): |
514 return [p.filename for p in self.patches] | 515 return [p.filename for p in self.patches] |
OLD | NEW |