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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 To be used by the try server. | 136 To be used by the try server. |
137 """ | 137 """ |
138 def prepare(self, revision): | 138 def prepare(self, revision): |
139 """Stubbed out.""" | 139 """Stubbed out.""" |
140 pass | 140 pass |
141 | 141 |
142 def apply_patch(self, patches, post_processors=None): | 142 def apply_patch(self, patches, post_processors=None): |
143 """Ignores svn properties.""" | 143 """Ignores svn properties.""" |
144 post_processors = post_processors or self.post_processors or [] | 144 post_processors = post_processors or self.post_processors or [] |
145 for p in patches: | 145 for p in patches: |
| 146 logging.debug('Applying %s' % p.filename) |
146 try: | 147 try: |
147 stdout = '' | 148 stdout = '' |
148 filename = os.path.join(self.project_path, p.filename) | 149 filename = os.path.join(self.project_path, p.filename) |
149 if p.is_delete: | 150 if p.is_delete: |
150 os.remove(filename) | 151 os.remove(filename) |
151 else: | 152 else: |
152 dirname = os.path.dirname(p.filename) | 153 dirname = os.path.dirname(p.filename) |
153 full_dir = os.path.join(self.project_path, dirname) | 154 full_dir = os.path.join(self.project_path, dirname) |
154 if dirname and not os.path.isdir(full_dir): | 155 if dirname and not os.path.isdir(full_dir): |
155 os.makedirs(full_dir) | 156 os.makedirs(full_dir) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 # Will checkout if the directory is not present. | 295 # Will checkout if the directory is not present. |
295 assert self.svn_url | 296 assert self.svn_url |
296 if not os.path.isdir(self.project_path): | 297 if not os.path.isdir(self.project_path): |
297 logging.info('Checking out %s in %s' % | 298 logging.info('Checking out %s in %s' % |
298 (self.project_name, self.project_path)) | 299 (self.project_name, self.project_path)) |
299 return self._revert(revision) | 300 return self._revert(revision) |
300 | 301 |
301 def apply_patch(self, patches, post_processors=None): | 302 def apply_patch(self, patches, post_processors=None): |
302 post_processors = post_processors or self.post_processors or [] | 303 post_processors = post_processors or self.post_processors or [] |
303 for p in patches: | 304 for p in patches: |
| 305 logging.debug('Applying %s' % p.filename) |
304 try: | 306 try: |
305 # It is important to use credentials=False otherwise credentials could | 307 # It is important to use credentials=False otherwise credentials could |
306 # leak in the error message. Credentials are not necessary here for the | 308 # leak in the error message. Credentials are not necessary here for the |
307 # following commands anyway. | 309 # following commands anyway. |
308 stdout = '' | 310 stdout = '' |
309 if p.is_delete: | 311 if p.is_delete: |
310 stdout += self._check_output_svn( | 312 stdout += self._check_output_svn( |
311 ['delete', p.filename, '--force'], credentials=False) | 313 ['delete', p.filename, '--force'], credentials=False) |
312 else: | 314 else: |
313 # svn add while creating directories otherwise svn add on the | 315 # svn add while creating directories otherwise svn add on the |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 Ignores svn properties and raise an exception on unexpected ones. | 502 Ignores svn properties and raise an exception on unexpected ones. |
501 """ | 503 """ |
502 post_processors = post_processors or self.post_processors or [] | 504 post_processors = post_processors or self.post_processors or [] |
503 # It this throws, the checkout is corrupted. Maybe worth deleting it and | 505 # It this throws, the checkout is corrupted. Maybe worth deleting it and |
504 # trying again? | 506 # trying again? |
505 if self.remote_branch: | 507 if self.remote_branch: |
506 self._check_call_git( | 508 self._check_call_git( |
507 ['checkout', '-b', self.working_branch, | 509 ['checkout', '-b', self.working_branch, |
508 '%s/%s' % (self.remote, self.remote_branch), '--quiet']) | 510 '%s/%s' % (self.remote, self.remote_branch), '--quiet']) |
509 for index, p in enumerate(patches): | 511 for index, p in enumerate(patches): |
| 512 logging.debug('Applying %s' % p.filename) |
510 try: | 513 try: |
511 stdout = '' | 514 stdout = '' |
512 if p.is_delete: | 515 if p.is_delete: |
513 if (not os.path.exists(p.filename) and | 516 if (not os.path.exists(p.filename) and |
514 any(p1.source_filename == p.filename for p1 in patches[0:index])): | 517 any(p1.source_filename == p.filename for p1 in patches[0:index])): |
515 # The file could already be deleted if a prior patch with file | 518 # The file could already be deleted if a prior patch with file |
516 # rename was already processed. To be sure, look at all the previous | 519 # rename was already processed. To be sure, look at all the previous |
517 # patches to see if they were a file rename. | 520 # patches to see if they were a file rename. |
518 pass | 521 pass |
519 else: | 522 else: |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 def revisions(self, rev1, rev2): | 650 def revisions(self, rev1, rev2): |
648 return self.checkout.revisions(rev1, rev2) | 651 return self.checkout.revisions(rev1, rev2) |
649 | 652 |
650 @property | 653 @property |
651 def project_name(self): | 654 def project_name(self): |
652 return self.checkout.project_name | 655 return self.checkout.project_name |
653 | 656 |
654 @property | 657 @property |
655 def project_path(self): | 658 def project_path(self): |
656 return self.checkout.project_path | 659 return self.checkout.project_path |
OLD | NEW |