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 """Manages a project checkout. | 5 """Manages a project checkout. |
6 | 6 |
7 Includes support for svn, git-svn and git. | 7 Includes support for svn, git-svn and git. |
8 """ | 8 """ |
9 | 9 |
10 import ConfigParser | 10 import ConfigParser |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 cmd, stdin=p.get(False), cwd=self.project_path) | 350 cmd, stdin=p.get(False), cwd=self.project_path) |
351 elif p.is_new and not os.path.exists(filepath): | 351 elif p.is_new and not os.path.exists(filepath): |
352 # There is only a header. Just create the file if it doesn't | 352 # There is only a header. Just create the file if it doesn't |
353 # exist. | 353 # exist. |
354 open(filepath, 'w').close() | 354 open(filepath, 'w').close() |
355 if p.is_new and not p.source_filename: | 355 if p.is_new and not p.source_filename: |
356 # Do not run it if p.source_filename is defined, since svn copy was | 356 # Do not run it if p.source_filename is defined, since svn copy was |
357 # using above. | 357 # using above. |
358 stdout += self._check_output_svn( | 358 stdout += self._check_output_svn( |
359 ['add', p.filename, '--force'], credentials=False) | 359 ['add', p.filename, '--force'], credentials=False) |
360 for prop in p.svn_properties: | 360 for name, value in p.svn_properties: |
361 stdout += self._check_output_svn( | 361 if value is None: |
362 ['propset', prop[0], prop[1], p.filename], credentials=False) | 362 stdout += self._check_output_svn( |
| 363 ['propdel', '--quiet', name, p.filename], credentials=False) |
| 364 else: |
| 365 stdout += self._check_output_svn( |
| 366 ['propset', name, value, p.filename], credentials=False) |
363 for prop, values in self.svn_config.auto_props.iteritems(): | 367 for prop, values in self.svn_config.auto_props.iteritems(): |
364 if fnmatch.fnmatch(p.filename, prop): | 368 if fnmatch.fnmatch(p.filename, prop): |
365 for value in values.split(';'): | 369 for value in values.split(';'): |
366 if '=' not in value: | 370 if '=' not in value: |
367 params = [value, '*'] | 371 params = [value, '*'] |
368 else: | 372 else: |
369 params = value.split('=', 1) | 373 params = value.split('=', 1) |
370 stdout += self._check_output_svn( | 374 stdout += self._check_output_svn( |
371 ['propset'] + params + [p.filename], credentials=False) | 375 ['propset'] + params + [p.filename], credentials=False) |
372 for post in post_processors: | 376 for post in post_processors: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 os.makedirs(full_dir) | 525 os.makedirs(full_dir) |
522 if p.is_binary: | 526 if p.is_binary: |
523 with open(os.path.join(self.project_path, p.filename), 'wb') as f: | 527 with open(os.path.join(self.project_path, p.filename), 'wb') as f: |
524 f.write(p.get()) | 528 f.write(p.get()) |
525 stdout += self._check_output_git(['add', p.filename]) | 529 stdout += self._check_output_git(['add', p.filename]) |
526 else: | 530 else: |
527 # No need to do anything special with p.is_new or if not | 531 # No need to do anything special with p.is_new or if not |
528 # p.diff_hunks. git apply manages all that already. | 532 # p.diff_hunks. git apply manages all that already. |
529 stdout += self._check_output_git( | 533 stdout += self._check_output_git( |
530 ['apply', '--index', '-p%s' % p.patchlevel], stdin=p.get(True)) | 534 ['apply', '--index', '-p%s' % p.patchlevel], stdin=p.get(True)) |
531 for prop in p.svn_properties: | 535 for name, _ in p.svn_properties: |
532 # Ignore some known auto-props flags through .subversion/config, | 536 # Ignore some known auto-props flags through .subversion/config, |
533 # bails out on the other ones. | 537 # bails out on the other ones. |
534 # TODO(maruel): Read ~/.subversion/config and detect the rules that | 538 # TODO(maruel): Read ~/.subversion/config and detect the rules that |
535 # applies here to figure out if the property will be correctly | 539 # applies here to figure out if the property will be correctly |
536 # handled. | 540 # handled. |
537 if not prop[0] in ( | 541 if not name in ( |
538 'svn:eol-style', 'svn:executable', 'svn:mime-type'): | 542 'svn:eol-style', 'svn:executable', 'svn:mime-type'): |
539 raise patch.UnsupportedPatchFormat( | 543 raise patch.UnsupportedPatchFormat( |
540 p.filename, | 544 p.filename, |
541 'Cannot apply svn property %s to file %s.' % ( | 545 'Cannot apply svn property %s to file %s.' % ( |
542 prop[0], p.filename)) | 546 name, p.filename)) |
543 for post in post_processors: | 547 for post in post_processors: |
544 post(self, p) | 548 post(self, p) |
545 except OSError, e: | 549 except OSError, e: |
546 raise PatchApplicationFailed(p, '%s%s' % (stdout, e)) | 550 raise PatchApplicationFailed(p, '%s%s' % (stdout, e)) |
547 except subprocess.CalledProcessError, e: | 551 except subprocess.CalledProcessError, e: |
548 raise PatchApplicationFailed( | 552 raise PatchApplicationFailed( |
549 p, '%s%s' % (stdout, getattr(e, 'stdout', None))) | 553 p, '%s%s' % (stdout, getattr(e, 'stdout', None))) |
550 # Once all the patches are processed and added to the index, commit the | 554 # Once all the patches are processed and added to the index, commit the |
551 # index. | 555 # index. |
552 self._check_call_git(['commit', '-m', 'Committed patch']) | 556 self._check_call_git(['commit', '-m', 'Committed patch']) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 def revisions(self, rev1, rev2): | 647 def revisions(self, rev1, rev2): |
644 return self.checkout.revisions(rev1, rev2) | 648 return self.checkout.revisions(rev1, rev2) |
645 | 649 |
646 @property | 650 @property |
647 def project_name(self): | 651 def project_name(self): |
648 return self.checkout.project_name | 652 return self.checkout.project_name |
649 | 653 |
650 @property | 654 @property |
651 def project_path(self): | 655 def project_path(self): |
652 return self.checkout.project_path | 656 return self.checkout.project_path |
OLD | NEW |