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

Side by Side Diff: gclient_scm.py

Issue 262813002: gclient_scm: Only _DeleteOrMove if _Clone fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 7 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 from __future__ import print_function 7 from __future__ import print_function
8 8
9 import logging 9 import logging
10 import os 10 import os
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 # Rewrite remote refs to their local equivalents. 345 # Rewrite remote refs to their local equivalents.
346 revision = 'refs/remotes/' + revision 346 revision = 'refs/remotes/' + revision
347 rev_type = "branch" 347 rev_type = "branch"
348 else: 348 else:
349 # hash is also a tag, only make a distinction at checkout 349 # hash is also a tag, only make a distinction at checkout
350 rev_type = "hash" 350 rev_type = "hash"
351 351
352 if (not os.path.exists(self.checkout_path) or 352 if (not os.path.exists(self.checkout_path) or
353 (os.path.isdir(self.checkout_path) and 353 (os.path.isdir(self.checkout_path) and
354 not os.path.exists(os.path.join(self.checkout_path, '.git')))): 354 not os.path.exists(os.path.join(self.checkout_path, '.git')))):
355 if (os.path.isdir(self.checkout_path) and 355 try:
356 not os.path.exists(os.path.join(self.checkout_path, '.git')) and 356 self._Clone(revision, url, options)
357 os.listdir(self.checkout_path)): 357 except subprocess2.CalledProcessError:
358 # This is a little hack to work around checkouts which are created 358 self._DeleteOrMove(options.force)
359 # using "gclient config --name ." 359 self._Clone(revision, url, options)
360 if not self.relpath == '.':
361 self._DeleteOrMove(options.force)
362 self._Clone(revision, url, options)
363 self._UpdateBranchHeads(options, fetch=True) 360 self._UpdateBranchHeads(options, fetch=True)
364 if file_list is not None: 361 if file_list is not None:
365 files = self._Capture(['ls-files']).splitlines() 362 files = self._Capture(['ls-files']).splitlines()
366 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 363 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
367 if not verbose: 364 if not verbose:
368 # Make the output a little prettier. It's nice to have some whitespace 365 # Make the output a little prettier. It's nice to have some whitespace
369 # between projects when cloning. 366 # between projects when cloning.
370 self.Print('') 367 self.Print('')
371 return self._Capture(['rev-parse', '--verify', 'HEAD']) 368 return self._Capture(['rev-parse', '--verify', 'HEAD'])
372 369
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 new_command.append('--force') 1454 new_command.append('--force')
1458 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1455 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1459 new_command.extend(('--accept', 'theirs-conflict')) 1456 new_command.extend(('--accept', 'theirs-conflict'))
1460 elif options.manually_grab_svn_rev: 1457 elif options.manually_grab_svn_rev:
1461 new_command.append('--force') 1458 new_command.append('--force')
1462 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1459 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1463 new_command.extend(('--accept', 'postpone')) 1460 new_command.extend(('--accept', 'postpone'))
1464 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1461 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1465 new_command.extend(('--accept', 'postpone')) 1462 new_command.extend(('--accept', 'postpone'))
1466 return new_command 1463 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