Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: gclient_scm.py

Issue 10454088: Automatically update submodule config entries on sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 The patch file is generated from a diff of the merge base of HEAD and 188 The patch file is generated from a diff of the merge base of HEAD and
189 its upstream branch. 189 its upstream branch.
190 """ 190 """
191 merge_base = self._Capture(['merge-base', 'HEAD', 'origin']) 191 merge_base = self._Capture(['merge-base', 'HEAD', 'origin'])
192 gclient_utils.CheckCallAndFilter( 192 gclient_utils.CheckCallAndFilter(
193 ['git', 'diff', merge_base], 193 ['git', 'diff', merge_base],
194 cwd=self.checkout_path, 194 cwd=self.checkout_path,
195 filter_fn=GitDiffFilterer(self.relpath).Filter) 195 filter_fn=GitDiffFilterer(self.relpath).Filter)
196 196
197 def UpdateSubmoduleConfig(self):
198 submod_cmd = ['git', 'config', '-f', '$toplevel/.git/config',
199 'submodule.$name.ignore', '||',
M-A Ruel 2012/05/31 01:35:52 '||' probably doesn't work on windows.
szager1 2012/05/31 06:39:45 I tried it. Works for me. git-submodule is a she
200 'git', 'config', '-f', '$toplevel/.git/config',
201 'submodule.$name.ignore', 'dirty']
202 cmd = ['submodule', '--quiet', 'foreach', ' '.join(submod_cmd)]
203 self._Run(cmd, options=None, cwd=self.checkout_path, print_stdout=True)
204
197 def update(self, options, args, file_list): 205 def update(self, options, args, file_list):
198 """Runs git to update or transparently checkout the working copy. 206 """Runs git to update or transparently checkout the working copy.
199 207
200 All updated files will be appended to file_list. 208 All updated files will be appended to file_list.
201 209
202 Raises: 210 Raises:
203 Error: if can't get URL for relative path. 211 Error: if can't get URL for relative path.
204 """ 212 """
205 if args: 213 if args:
206 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) 214 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 rev_type = "branch" 255 rev_type = "branch"
248 else: 256 else:
249 # hash is also a tag, only make a distinction at checkout 257 # hash is also a tag, only make a distinction at checkout
250 rev_type = "hash" 258 rev_type = "hash"
251 259
252 if not os.path.exists(self.checkout_path) or ( 260 if not os.path.exists(self.checkout_path) or (
253 os.path.isdir(self.checkout_path) and 261 os.path.isdir(self.checkout_path) and
254 not os.listdir(self.checkout_path)): 262 not os.listdir(self.checkout_path)):
255 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) 263 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path))
256 self._Clone(revision, url, options) 264 self._Clone(revision, url, options)
265 self.UpdateSubmoduleConfig()
257 files = self._Capture(['ls-files']).splitlines() 266 files = self._Capture(['ls-files']).splitlines()
258 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 267 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
259 if not verbose: 268 if not verbose:
260 # Make the output a little prettier. It's nice to have some whitespace 269 # Make the output a little prettier. It's nice to have some whitespace
261 # between projects when cloning. 270 # between projects when cloning.
262 print('') 271 print('')
263 return 272 return
264 273
265 if not managed: 274 if not managed:
266 print ('________ unmanaged solution; skipping %s' % self.relpath) 275 print ('________ unmanaged solution; skipping %s' % self.relpath)
(...skipping 16 matching lines...) Expand all
283 print('_____ switching %s to a new upstream' % self.relpath) 292 print('_____ switching %s to a new upstream' % self.relpath)
284 # Make sure it's clean 293 # Make sure it's clean
285 self._CheckClean(rev_str) 294 self._CheckClean(rev_str)
286 # Switch over to the new upstream 295 # Switch over to the new upstream
287 self._Run(['remote', 'set-url', 'origin', url], options) 296 self._Run(['remote', 'set-url', 'origin', url], options)
288 quiet = [] 297 quiet = []
289 if not options.verbose: 298 if not options.verbose:
290 quiet = ['--quiet'] 299 quiet = ['--quiet']
291 self._Run(['fetch', 'origin', '--prune'] + quiet, options) 300 self._Run(['fetch', 'origin', '--prune'] + quiet, options)
292 self._Run(['reset', '--hard', 'origin/master'] + quiet, options) 301 self._Run(['reset', '--hard', 'origin/master'] + quiet, options)
302 self.UpdateSubmoduleConfig()
293 files = self._Capture(['ls-files']).splitlines() 303 files = self._Capture(['ls-files']).splitlines()
294 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 304 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
295 return 305 return
296 306
297 cur_branch = self._GetCurrentBranch() 307 cur_branch = self._GetCurrentBranch()
298 308
299 # Cases: 309 # Cases:
300 # 0) HEAD is detached. Probably from our initial clone. 310 # 0) HEAD is detached. Probably from our initial clone.
301 # - make sure HEAD is contained by a named ref, then update. 311 # - make sure HEAD is contained by a named ref, then update.
302 # Cases 1-4. HEAD is a branch. 312 # Cases 1-4. HEAD is a branch.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 if not re.match('Already up-to-date.', merge_output) or verbose: 464 if not re.match('Already up-to-date.', merge_output) or verbose:
455 if not printed_path: 465 if not printed_path:
456 print('\n_____ %s%s' % (self.relpath, rev_str)) 466 print('\n_____ %s%s' % (self.relpath, rev_str))
457 printed_path = True 467 printed_path = True
458 print(merge_output.strip()) 468 print(merge_output.strip())
459 if not verbose: 469 if not verbose:
460 # Make the output a little prettier. It's nice to have some 470 # Make the output a little prettier. It's nice to have some
461 # whitespace between projects when syncing. 471 # whitespace between projects when syncing.
462 print('') 472 print('')
463 473
474 self.UpdateSubmoduleConfig()
464 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 475 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
465 476
466 # If the rebase generated a conflict, abort and ask user to fix 477 # If the rebase generated a conflict, abort and ask user to fix
467 if self._IsRebasing(): 478 if self._IsRebasing():
468 raise gclient_utils.Error('\n____ %s%s\n' 479 raise gclient_utils.Error('\n____ %s%s\n'
469 '\nConflict while rebasing this branch.\n' 480 '\nConflict while rebasing this branch.\n'
470 'Fix the conflict and run gclient again.\n' 481 'Fix the conflict and run gclient again.\n'
471 'See man git-rebase for details.\n' 482 'See man git-rebase for details.\n'
472 % (self.relpath, rev_str)) 483 % (self.relpath, rev_str))
473 484
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 new_command.append('--force') 1181 new_command.append('--force')
1171 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1182 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1172 new_command.extend(('--accept', 'theirs-conflict')) 1183 new_command.extend(('--accept', 'theirs-conflict'))
1173 elif options.manually_grab_svn_rev: 1184 elif options.manually_grab_svn_rev:
1174 new_command.append('--force') 1185 new_command.append('--force')
1175 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1186 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1176 new_command.extend(('--accept', 'postpone')) 1187 new_command.extend(('--accept', 'postpone'))
1177 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1188 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1178 new_command.extend(('--accept', 'postpone')) 1189 new_command.extend(('--accept', 'postpone'))
1179 return new_command 1190 return new_command
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698