Chromium Code Reviews| Index: gclient_scm.py |
| diff --git a/gclient_scm.py b/gclient_scm.py |
| index 473a1bde81224395e8cb0e2adc619f3533099f2c..fbec8af8b8d811d77a950baf0ea7c2b5a7e31aba 100644 |
| --- a/gclient_scm.py |
| +++ b/gclient_scm.py |
| @@ -30,6 +30,10 @@ GSUTIL_DEFAULT_PATH = os.path.join( |
| os.path.dirname(os.path.abspath(__file__)), 'gsutil.py') |
| +class NoUsableRevError(gclient_utils.Error): |
| + """Raised if requested revision isn't found in checkout.""" |
| + |
| + |
| class DiffFiltererWrapper(object): |
| """Simple base class which tracks which file is being diffed and |
| replaces instances of its file name in the original and |
| @@ -717,7 +721,12 @@ class GitWrapper(SCMWrapper): |
| deps_revision = default_rev |
| if deps_revision.startswith('refs/heads/'): |
| deps_revision = deps_revision.replace('refs/heads/', self.remote + '/') |
| - deps_revision = self.GetUsableRev(deps_revision, options) |
| + try: |
| + deps_revision = self.GetUsableRev(deps_revision, options) |
| + except NoUsableRevError: |
| + # If the DEPS entry's url and hash changed, try to update the origin. |
| + # See also http://crbug.com/520067. |
| + return self.update(options, [], file_list) |
| if file_list is not None: |
| files = self._Capture(['diff', deps_revision, '--name-only']).split() |
| @@ -755,7 +764,7 @@ class GitWrapper(SCMWrapper): |
| will be called on the source.""" |
| sha1 = None |
| if not os.path.isdir(self.checkout_path): |
| - raise gclient_utils.Error( |
| + raise NoUsableRevError( |
| ( 'We could not find a valid hash for safesync_url response "%s".\n' |
| 'Safesync URLs with a git checkout currently require the repo to\n' |
| 'be cloned without a safesync_url before adding the safesync_url.\n' |
| @@ -789,7 +798,7 @@ class GitWrapper(SCMWrapper): |
| 'the closest sane git revision, which is:\n' |
| ' %s\n' % (rev, e.message)) |
| if not sha1: |
| - raise gclient_utils.Error( |
| + raise NoUsableRevError( |
|
nodir
2015/08/12 17:20:08
Note that this was not catched before: it does not
tandrii(chromium)
2015/08/12 17:27:28
I am not sure about this case, but I thought PS2 i
|
| ( 'It appears that either your git-svn remote is incorrectly\n' |
| 'configured or the revision in your safesync_url is\n' |
| 'higher than git-svn remote\'s HEAD as we couldn\'t find a\n' |
| @@ -805,7 +814,7 @@ class GitWrapper(SCMWrapper): |
| sha1 = rev |
| if not sha1: |
| - raise gclient_utils.Error( |
| + raise NoUsableRevError( |
| ( 'We could not find a valid hash for safesync_url response "%s".\n' |
| 'Safesync URLs with a git checkout currently require a git-svn\n' |
| 'remote or a safesync_url that provides git sha1s. Please add a\n' |
| @@ -1590,7 +1599,7 @@ class SVNWrapper(SCMWrapper): |
| def GetUsableRev(self, rev, _options): |
| """Verifies the validity of the revision for this repository.""" |
| if not scm.SVN.IsValidRevision(url='%s@%s' % (self.url, rev)): |
| - raise gclient_utils.Error( |
| + raise NoUsableRevError( |
| ( '%s isn\'t a valid revision. Please check that your safesync_url is\n' |
|
nodir
2015/08/12 17:20:09
this too
tandrii(chromium)
2015/08/12 17:27:28
this is inside SVN scm block, so this was doesn't
|
| 'correct.') % rev) |
| return rev |