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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 'Couldn\'t make sense out of svn commit message:\n' + out) | 472 'Couldn\'t make sense out of svn commit message:\n' + out) |
473 return int(match.group(1)) | 473 return int(match.group(1)) |
474 | 474 |
475 def _revert(self, revision): | 475 def _revert(self, revision): |
476 """Reverts local modifications or checks out if the directory is not | 476 """Reverts local modifications or checks out if the directory is not |
477 present. Use depot_tools's functionality to do this. | 477 present. Use depot_tools's functionality to do this. |
478 """ | 478 """ |
479 flags = ['--ignore-externals'] | 479 flags = ['--ignore-externals'] |
480 if revision: | 480 if revision: |
481 flags.extend(['--revision', str(revision)]) | 481 flags.extend(['--revision', str(revision)]) |
482 if not os.path.isdir(self.project_path): | 482 if os.path.isdir(self.project_path): |
| 483 # This may remove any part (or all) of the checkout. |
| 484 scm.SVN.Revert(self.project_path, no_ignore=True) |
| 485 |
| 486 if os.path.isdir(self.project_path): |
| 487 # Revive files that were deleted in scm.SVN.Revert(). |
| 488 self._check_call_svn(['update', '--force'] + flags) |
| 489 else: |
483 logging.info( | 490 logging.info( |
484 'Directory %s is not present, checking it out.' % self.project_path) | 491 'Directory %s is not present, checking it out.' % self.project_path) |
485 self._check_call_svn( | 492 self._check_call_svn( |
486 ['checkout', self.svn_url, self.project_path] + flags, cwd=None) | 493 ['checkout', self.svn_url, self.project_path] + flags, cwd=None) |
487 else: | |
488 scm.SVN.Revert(self.project_path, no_ignore=True) | |
489 # Revive files that were deleted in scm.SVN.Revert(). | |
490 self._check_call_svn(['update', '--force'] + flags) | |
491 return self._get_revision() | 494 return self._get_revision() |
492 | 495 |
493 def _get_revision(self): | 496 def _get_revision(self): |
494 out = self._check_output_svn(['info', '.']) | 497 out = self._check_output_svn(['info', '.']) |
495 revision = int(self._parse_svn_info(out, 'revision')) | 498 revision = int(self._parse_svn_info(out, 'revision')) |
496 if revision != self._last_seen_revision: | 499 if revision != self._last_seen_revision: |
497 logging.info('Updated to revision %d' % revision) | 500 logging.info('Updated to revision %d' % revision) |
498 self._last_seen_revision = revision | 501 self._last_seen_revision = revision |
499 return revision | 502 return revision |
500 | 503 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 def revisions(self, rev1, rev2): | 727 def revisions(self, rev1, rev2): |
725 return self.checkout.revisions(rev1, rev2) | 728 return self.checkout.revisions(rev1, rev2) |
726 | 729 |
727 @property | 730 @property |
728 def project_name(self): | 731 def project_name(self): |
729 return self.checkout.project_name | 732 return self.checkout.project_name |
730 | 733 |
731 @property | 734 @property |
732 def project_path(self): | 735 def project_path(self): |
733 return self.checkout.project_path | 736 return self.checkout.project_path |
OLD | NEW |