| OLD | NEW |
| 1 # coding=utf8 | 1 # coding=utf8 |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 logging | 10 import logging |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 def _update_committer(self, revision, new_author): | 110 def _update_committer(self, revision, new_author): |
| 111 """Changes the author of a commit a posteriori. | 111 """Changes the author of a commit a posteriori. |
| 112 | 112 |
| 113 This is necessary since the actual commit is done with a "commit-bot" | 113 This is necessary since the actual commit is done with a "commit-bot" |
| 114 credential but the original patch author needs to be assigned authorship | 114 credential but the original patch author needs to be assigned authorship |
| 115 of the revision. | 115 of the revision. |
| 116 """ | 116 """ |
| 117 self._check_call_svn( | 117 self._check_call_svn( |
| 118 ['propset', '--revprop', 'svn:author', | 118 ['propset', '--revprop', 'svn:author', |
| 119 '-r', revision, | 119 '-r', str(revision), |
| 120 new_author, | 120 new_author, |
| 121 self.svn_url]) | 121 self.svn_url]) |
| 122 | 122 |
| 123 | 123 |
| 124 class SvnCheckout(CheckoutBase, SvnMixIn): | 124 class SvnCheckout(CheckoutBase, SvnMixIn): |
| 125 """Manages a subversion checkout. | 125 """Manages a subversion checkout. |
| 126 | 126 |
| 127 Commit is not fully implemented yet. Reimplementing all the commands is | 127 Commit is not fully implemented yet. Reimplementing all the commands is |
| 128 slightly complex, svn add with history needs to be done with svn | 128 slightly complex, svn add with history needs to be done with svn |
| 129 copy/rename/move and the situation quickly becomes harder when directories are | 129 copy/rename/move and the situation quickly becomes harder when directories are |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if self.working_branch in branches: | 243 if self.working_branch in branches: |
| 244 self._call_git(['branch', '-D', self.working_branch]) | 244 self._call_git(['branch', '-D', self.working_branch]) |
| 245 | 245 |
| 246 def apply_patch(self, patch_data): | 246 def apply_patch(self, patch_data): |
| 247 """Applies a patch on 'working_branch'.""" | 247 """Applies a patch on 'working_branch'.""" |
| 248 self._check_call_git( | 248 self._check_call_git( |
| 249 ['checkout', '-b', self.working_branch, | 249 ['checkout', '-b', self.working_branch, |
| 250 '%s/%s' % (self.remote, self.remote_branch)]) | 250 '%s/%s' % (self.remote, self.remote_branch)]) |
| 251 self._check_call_git(['apply', '--index', '-p0'], stdin=patch_data) | 251 self._check_call_git(['apply', '--index', '-p0'], stdin=patch_data) |
| 252 self._check_call_git(['commit', '-m', 'Committed patch']) | 252 self._check_call_git(['commit', '-m', 'Committed patch']) |
| 253 return True |
| 253 | 254 |
| 254 def commit(self, commit_message, user): | 255 def commit(self, commit_message, user): |
| 255 """Updates the commit message. | 256 """Updates the commit message. |
| 256 | 257 |
| 257 Subclass needs to dcommit or push.""" | 258 Subclass needs to dcommit or push.""" |
| 258 self._check_call_git(['commit', '--amend', '-m', commit_message]) | 259 self._check_call_git(['commit', '--amend', '-m', commit_message]) |
| 259 | 260 |
| 260 def _check_call_git(self, args, **kwargs): | 261 def _check_call_git(self, args, **kwargs): |
| 261 kwargs.setdefault('cwd', self.project_path) | 262 kwargs.setdefault('cwd', self.project_path) |
| 262 return subprocess2.check_call(['git'] + args, **kwargs) | 263 return subprocess2.check_call(['git'] + args, **kwargs) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 user, message)) | 432 user, message)) |
| 432 return 'FAKE' | 433 return 'FAKE' |
| 433 | 434 |
| 434 @property | 435 @property |
| 435 def project_name(self): | 436 def project_name(self): |
| 436 return self.checkout.project_name | 437 return self.checkout.project_name |
| 437 | 438 |
| 438 @property | 439 @property |
| 439 def project_path(self): | 440 def project_path(self): |
| 440 return self.checkout.project_path | 441 return self.checkout.project_path |
| OLD | NEW |