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 """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 from __future__ import with_statement | 10 from __future__ import with_statement |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if self.commit_user: | 176 if self.commit_user: |
177 args.extend(['--username', self.commit_user]) | 177 args.extend(['--username', self.commit_user]) |
178 if self.commit_pwd: | 178 if self.commit_pwd: |
179 args.extend(['--password', self.commit_pwd]) | 179 args.extend(['--password', self.commit_pwd]) |
180 return args | 180 return args |
181 | 181 |
182 def _check_call_svn(self, args, **kwargs): | 182 def _check_call_svn(self, args, **kwargs): |
183 """Runs svn and throws an exception if the command failed.""" | 183 """Runs svn and throws an exception if the command failed.""" |
184 kwargs.setdefault('cwd', self.project_path) | 184 kwargs.setdefault('cwd', self.project_path) |
185 kwargs.setdefault('stdout', self.VOID) | 185 kwargs.setdefault('stdout', self.VOID) |
186 return subprocess2.check_call(self._add_svn_flags(args, False), **kwargs) | 186 return subprocess2.check_call_out( |
| 187 self._add_svn_flags(args, False), **kwargs) |
187 | 188 |
188 def _check_output_svn(self, args, **kwargs): | 189 def _check_output_svn(self, args, **kwargs): |
189 """Runs svn and throws an exception if the command failed. | 190 """Runs svn and throws an exception if the command failed. |
190 | 191 |
191 Returns the output. | 192 Returns the output. |
192 """ | 193 """ |
193 kwargs.setdefault('cwd', self.project_path) | 194 kwargs.setdefault('cwd', self.project_path) |
194 return subprocess2.check_output(self._add_svn_flags(args, True), **kwargs) | 195 return subprocess2.check_output(self._add_svn_flags(args, True), **kwargs) |
195 | 196 |
196 @staticmethod | 197 @staticmethod |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 """Updates the commit message. | 406 """Updates the commit message. |
406 | 407 |
407 Subclass needs to dcommit or push. | 408 Subclass needs to dcommit or push. |
408 """ | 409 """ |
409 self._check_call_git(['commit', '--amend', '-m', commit_message]) | 410 self._check_call_git(['commit', '--amend', '-m', commit_message]) |
410 return self._check_output_git(['rev-parse', 'HEAD']).strip() | 411 return self._check_output_git(['rev-parse', 'HEAD']).strip() |
411 | 412 |
412 def _check_call_git(self, args, **kwargs): | 413 def _check_call_git(self, args, **kwargs): |
413 kwargs.setdefault('cwd', self.project_path) | 414 kwargs.setdefault('cwd', self.project_path) |
414 kwargs.setdefault('stdout', self.VOID) | 415 kwargs.setdefault('stdout', self.VOID) |
415 return subprocess2.check_call(['git'] + args, **kwargs) | 416 return subprocess2.check_call_out(['git'] + args, **kwargs) |
416 | 417 |
417 def _call_git(self, args, **kwargs): | 418 def _call_git(self, args, **kwargs): |
418 """Like check_call but doesn't throw on failure.""" | 419 """Like check_call but doesn't throw on failure.""" |
419 kwargs.setdefault('cwd', self.project_path) | 420 kwargs.setdefault('cwd', self.project_path) |
420 kwargs.setdefault('stdout', self.VOID) | 421 kwargs.setdefault('stdout', self.VOID) |
421 return subprocess2.call(['git'] + args, **kwargs) | 422 return subprocess2.call(['git'] + args, **kwargs) |
422 | 423 |
423 def _check_output_git(self, args, **kwargs): | 424 def _check_output_git(self, args, **kwargs): |
424 kwargs.setdefault('cwd', self.project_path) | 425 kwargs.setdefault('cwd', self.project_path) |
425 return subprocess2.check_output(['git'] + args, **kwargs) | 426 return subprocess2.check_output(['git'] + args, **kwargs) |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 user, message)) | 617 user, message)) |
617 return 'FAKE' | 618 return 'FAKE' |
618 | 619 |
619 @property | 620 @property |
620 def project_name(self): | 621 def project_name(self): |
621 return self.checkout.project_name | 622 return self.checkout.project_name |
622 | 623 |
623 @property | 624 @property |
624 def project_path(self): | 625 def project_path(self): |
625 return self.checkout.project_path | 626 return self.checkout.project_path |
OLD | NEW |