Chromium Code Reviews| 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 commands = [ | |
| 197 (['remote', 'set-url', 'origin', url], None), | |
| 198 (['fetch', 'origin', '--prune'], '--quiet'), | |
| 199 (['reset', '--hard', 'origin/master'], '-q'), | |
| 200 ] | |
| 201 for cmd, quiet_arg in commands: | |
|
M-A Ruel
2011/03/24 17:17:02
It's funny but the following is still less lines (
TVL
2011/03/24 17:43:11
Done. (help didn't list --quiet as valid for rese
| |
| 202 if not options.verbose and quiet_arg: | |
| 203 cmd.append(quiet_arg) | |
| 204 self._Run(cmd, options, cwd=self.checkout_path) | |
| 205 # List the tree in the file list | |
| 206 files = self._Capture(['ls-files']).split() | |
|
M-A Ruel
2011/03/24 17:17:02
splitlines() ?
TVL
2011/03/24 17:43:11
I just copied what 222-223 do for a fresh clone, s
| |
| 207 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | |
| 208 return | |
| 209 | |
| 189 if revision.startswith('refs/heads/'): | 210 if revision.startswith('refs/heads/'): |
| 190 rev_type = "branch" | 211 rev_type = "branch" |
| 191 elif revision.startswith('origin/'): | 212 elif revision.startswith('origin/'): |
| 192 # For compatability with old naming, translate 'origin' to 'refs/heads' | 213 # For compatability with old naming, translate 'origin' to 'refs/heads' |
| 193 revision = revision.replace('origin/', 'refs/heads/') | 214 revision = revision.replace('origin/', 'refs/heads/') |
| 194 rev_type = "branch" | 215 rev_type = "branch" |
| 195 else: | 216 else: |
| 196 # hash is also a tag, only make a distinction at checkout | 217 # hash is also a tag, only make a distinction at checkout |
| 197 rev_type = "hash" | 218 rev_type = "hash" |
| 198 | 219 |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 | 925 |
| 905 This method returns a new list to be used as a command.""" | 926 This method returns a new list to be used as a command.""" |
| 906 new_command = command[:] | 927 new_command = command[:] |
| 907 if revision: | 928 if revision: |
| 908 new_command.extend(['--revision', str(revision).strip()]) | 929 new_command.extend(['--revision', str(revision).strip()]) |
| 909 # --force was added to 'svn update' in svn 1.5. | 930 # --force was added to 'svn update' in svn 1.5. |
| 910 if ((options.force or options.manually_grab_svn_rev) and | 931 if ((options.force or options.manually_grab_svn_rev) and |
| 911 scm.SVN.AssertVersion("1.5")[0]): | 932 scm.SVN.AssertVersion("1.5")[0]): |
| 912 new_command.append('--force') | 933 new_command.append('--force') |
| 913 return new_command | 934 return new_command |
| OLD | NEW |