OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 rev_str = ' at %s' % revision | 179 rev_str = ' at %s' % revision |
180 files = [] | 180 files = [] |
181 | 181 |
182 printed_path = False | 182 printed_path = False |
183 verbose = [] | 183 verbose = [] |
184 if options.verbose: | 184 if options.verbose: |
185 print('\n_____ %s%s' % (self.relpath, rev_str)) | 185 print('\n_____ %s%s' % (self.relpath, rev_str)) |
186 verbose = ['--verbose'] | 186 verbose = ['--verbose'] |
187 printed_path = True | 187 printed_path = True |
188 | 188 |
| 189 # See if the url has changed |
| 190 current_url = self._Capture(['config', 'remote.origin.url']) |
| 191 if current_url != url: |
| 192 print('_____ switching %s to a new upstream' % self.relpath) |
| 193 # Make sure it's clean |
| 194 self._CheckClean(rev_str) |
| 195 # Switch over to the new upstream |
| 196 self._Run(['remote', 'set-url', 'origin', url], options) |
| 197 quiet = [] |
| 198 if not options.verbose: |
| 199 quiet = ['--quiet'] |
| 200 self._Run(['fetch', 'origin', '--prune'] + quiet, options) |
| 201 self._Run(['reset', '--hard', 'origin/master'] + quiet, options) |
| 202 files = self._Capture(['ls-files']).splitlines() |
| 203 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 204 return |
| 205 |
189 if revision.startswith('refs/heads/'): | 206 if revision.startswith('refs/heads/'): |
190 rev_type = "branch" | 207 rev_type = "branch" |
191 elif revision.startswith('origin/'): | 208 elif revision.startswith('origin/'): |
192 # For compatability with old naming, translate 'origin' to 'refs/heads' | 209 # For compatability with old naming, translate 'origin' to 'refs/heads' |
193 revision = revision.replace('origin/', 'refs/heads/') | 210 revision = revision.replace('origin/', 'refs/heads/') |
194 rev_type = "branch" | 211 rev_type = "branch" |
195 else: | 212 else: |
196 # hash is also a tag, only make a distinction at checkout | 213 # hash is also a tag, only make a distinction at checkout |
197 rev_type = "hash" | 214 rev_type = "hash" |
198 | 215 |
199 if not os.path.exists(self.checkout_path): | 216 if not os.path.exists(self.checkout_path): |
200 self._Clone(revision, url, options) | 217 self._Clone(revision, url, options) |
201 files = self._Capture(['ls-files']).split() | 218 files = self._Capture(['ls-files']).splitlines() |
202 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 219 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
203 if not verbose: | 220 if not verbose: |
204 # Make the output a little prettier. It's nice to have some whitespace | 221 # Make the output a little prettier. It's nice to have some whitespace |
205 # between projects when cloning. | 222 # between projects when cloning. |
206 print('') | 223 print('') |
207 return | 224 return |
208 | 225 |
209 if not os.path.exists(os.path.join(self.checkout_path, '.git')): | 226 if not os.path.exists(os.path.join(self.checkout_path, '.git')): |
210 raise gclient_utils.Error('\n____ %s%s\n' | 227 raise gclient_utils.Error('\n____ %s%s\n' |
211 '\tPath is not a git repo. No .git dir.\n' | 228 '\tPath is not a git repo. No .git dir.\n' |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 | 921 |
905 This method returns a new list to be used as a command.""" | 922 This method returns a new list to be used as a command.""" |
906 new_command = command[:] | 923 new_command = command[:] |
907 if revision: | 924 if revision: |
908 new_command.extend(['--revision', str(revision).strip()]) | 925 new_command.extend(['--revision', str(revision).strip()]) |
909 # --force was added to 'svn update' in svn 1.5. | 926 # --force was added to 'svn update' in svn 1.5. |
910 if ((options.force or options.manually_grab_svn_rev) and | 927 if ((options.force or options.manually_grab_svn_rev) and |
911 scm.SVN.AssertVersion("1.5")[0]): | 928 scm.SVN.AssertVersion("1.5")[0]): |
912 new_command.append('--force') | 929 new_command.append('--force') |
913 return new_command | 930 return new_command |
OLD | NEW |