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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 # file was empty. | 399 # file was empty. |
400 self.is_delete = True | 400 self.is_delete = True |
401 return | 401 return |
402 | 402 |
403 match = re.match(r'^new(| file) mode (\d{6})$', line) | 403 match = re.match(r'^new(| file) mode (\d{6})$', line) |
404 if match: | 404 if match: |
405 mode = match.group(2) | 405 mode = match.group(2) |
406 # Only look at owner ACL for executable. | 406 # Only look at owner ACL for executable. |
407 if bool(int(mode[4]) & 1): | 407 if bool(int(mode[4]) & 1): |
408 self.svn_properties.append(('svn:executable', '*')) | 408 self.svn_properties.append(('svn:executable', '*')) |
409 else: | 409 elif not self.source_filename and self.is_new: |
| 410 # It's a new file, not from a rename/copy, then there's no property to |
| 411 # delete. |
410 self.svn_properties.append(('svn:executable', None)) | 412 self.svn_properties.append(('svn:executable', None)) |
411 return | 413 return |
412 | 414 |
413 match = re.match(r'^--- (.*)$', line) | 415 match = re.match(r'^--- (.*)$', line) |
414 if match: | 416 if match: |
415 if last_line[:3] in ('---', '+++'): | 417 if last_line[:3] in ('---', '+++'): |
416 self._fail('--- and +++ are reversed') | 418 self._fail('--- and +++ are reversed') |
417 if match.group(1) == '/dev/null': | 419 if match.group(1) == '/dev/null': |
418 self.is_new = True | 420 self.is_new = True |
419 elif self.mangle(match.group(1)) != old: | 421 elif self.mangle(match.group(1)) != old: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 def __iter__(self): | 523 def __iter__(self): |
522 for patch in self.patches: | 524 for patch in self.patches: |
523 yield patch | 525 yield patch |
524 | 526 |
525 def __getitem__(self, key): | 527 def __getitem__(self, key): |
526 return self.patches[key] | 528 return self.patches[key] |
527 | 529 |
528 @property | 530 @property |
529 def filenames(self): | 531 def filenames(self): |
530 return [p.filename for p in self.patches] | 532 return [p.filename for p in self.patches] |
OLD | NEW |