| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 282     match = re.match(r'^(rename|copy) to (.+)$', line) | 282     match = re.match(r'^(rename|copy) to (.+)$', line) | 
| 283     if match: | 283     if match: | 
| 284       if self.filename != match.group(2): | 284       if self.filename != match.group(2): | 
| 285         self._fail('Unexpected git diff output name for line %s.' % line) | 285         self._fail('Unexpected git diff output name for line %s.' % line) | 
| 286       if not last_line.startswith('%s from ' % match.group(1)): | 286       if not last_line.startswith('%s from ' % match.group(1)): | 
| 287         self._fail( | 287         self._fail( | 
| 288             'Confused %s from/to git diff for line %s.' % | 288             'Confused %s from/to git diff for line %s.' % | 
| 289                 (match.group(1), line)) | 289                 (match.group(1), line)) | 
| 290       return | 290       return | 
| 291 | 291 | 
| 292     # Ignore "deleted file mode 100644" since it's not needed. | 292     match = re.match(r'^deleted file mode (\d{6})$', line) | 
|  | 293     if match: | 
|  | 294       # It is necessary to parse it because there may be no hunk, like when the | 
|  | 295       # file was empty. | 
|  | 296       self.is_delete = True | 
|  | 297       return | 
|  | 298 | 
| 293     match = re.match(r'^new(| file) mode (\d{6})$', line) | 299     match = re.match(r'^new(| file) mode (\d{6})$', line) | 
| 294     if match: | 300     if match: | 
| 295       mode = match.group(2) | 301       mode = match.group(2) | 
| 296       # Only look at owner ACL for executable. | 302       # Only look at owner ACL for executable. | 
| 297       # TODO(maruel): Add support to remove a property. | 303       # TODO(maruel): Add support to remove a property. | 
| 298       if bool(int(mode[4]) & 1): | 304       if bool(int(mode[4]) & 1): | 
| 299         self.svn_properties.append(('svn:executable', '*')) | 305         self.svn_properties.append(('svn:executable', '*')) | 
|  | 306       return | 
| 300 | 307 | 
| 301     match = re.match(r'^--- (.*)$', line) | 308     match = re.match(r'^--- (.*)$', line) | 
| 302     if match: | 309     if match: | 
| 303       if last_line[:3] in ('---', '+++'): | 310       if last_line[:3] in ('---', '+++'): | 
| 304         self._fail('--- and +++ are reversed') | 311         self._fail('--- and +++ are reversed') | 
| 305       if match.group(1) == '/dev/null': | 312       if match.group(1) == '/dev/null': | 
| 306         self.is_new = True | 313         self.is_new = True | 
| 307       elif self.mangle(match.group(1)) != old: | 314       elif self.mangle(match.group(1)) != old: | 
| 308         # git patches are always well formatted, do not allow random filenames. | 315         # git patches are always well formatted, do not allow random filenames. | 
| 309         self._fail('Unexpected git diff: %s != %s.' % (old, match.group(1))) | 316         self._fail('Unexpected git diff: %s != %s.' % (old, match.group(1))) | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 407   def __iter__(self): | 414   def __iter__(self): | 
| 408     for patch in self.patches: | 415     for patch in self.patches: | 
| 409       yield patch | 416       yield patch | 
| 410 | 417 | 
| 411   def __getitem__(self, key): | 418   def __getitem__(self, key): | 
| 412     return self.patches[key] | 419     return self.patches[key] | 
| 413 | 420 | 
| 414   @property | 421   @property | 
| 415   def filenames(self): | 422   def filenames(self): | 
| 416     return [p.filename for p in self.patches] | 423     return [p.filename for p in self.patches] | 
| OLD | NEW | 
|---|