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

Side by Side Diff: gclient_scm.py

Issue 743083002: Make gclient ready for the Blink (DEPS to main project) transition (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix tests Created 6 years 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
« no previous file with comments | « gclient.py ('k') | scm.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 errno 9 import errno
10 import logging 10 import logging
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 # always specify branches as they are in the upstream repo. 383 # always specify branches as they are in the upstream repo.
384 rev_type = "branch" 384 rev_type = "branch"
385 else: 385 else:
386 # hash is also a tag, only make a distinction at checkout 386 # hash is also a tag, only make a distinction at checkout
387 rev_type = "hash" 387 rev_type = "hash"
388 388
389 mirror = self._GetMirror(url, options) 389 mirror = self._GetMirror(url, options)
390 if mirror: 390 if mirror:
391 url = mirror.mirror_path 391 url = mirror.mirror_path
392 392
393 # If we are going to introduce a new project, there is a possibility that
394 # we are syncing back to a state where the project was originally a
395 # sub-project rolled by DEPS (realistic case: crossing the Blink merge point
396 # syncing backwards, when Blink was a DEPS entry and not part of src.git).
397 # In such case, we might have a backup of the former .git folder, which can
398 # be used to avoid re-fetching the entire repo again (useful for bisects).
399 backup_dir = self.GetGitBackupDirPath()
400 target_dir = os.path.join(self.checkout_path, '.git')
401 if os.path.exists(backup_dir) and not os.path.exists(target_dir):
402 gclient_utils.safe_makedirs(self.checkout_path)
403 os.rename(backup_dir, target_dir)
404 # Reset to a clean state
405 self._Run(['reset', '--hard', 'HEAD'], options)
406
393 if (not os.path.exists(self.checkout_path) or 407 if (not os.path.exists(self.checkout_path) or
394 (os.path.isdir(self.checkout_path) and 408 (os.path.isdir(self.checkout_path) and
395 not os.path.exists(os.path.join(self.checkout_path, '.git')))): 409 not os.path.exists(os.path.join(self.checkout_path, '.git')))):
396 if mirror: 410 if mirror:
397 self._UpdateMirror(mirror, options) 411 self._UpdateMirror(mirror, options)
398 try: 412 try:
399 self._Clone(revision, url, options) 413 self._Clone(revision, url, options)
400 except subprocess2.CalledProcessError: 414 except subprocess2.CalledProcessError:
401 self._DeleteOrMove(options.force) 415 self._DeleteOrMove(options.force)
402 self._Clone(revision, url, options) 416 self._Clone(revision, url, options)
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 '#Initial_checkout' ) % rev) 807 '#Initial_checkout' ) % rev)
794 808
795 return sha1 809 return sha1
796 810
797 def FullUrlForRelativeUrl(self, url): 811 def FullUrlForRelativeUrl(self, url):
798 # Strip from last '/' 812 # Strip from last '/'
799 # Equivalent to unix basename 813 # Equivalent to unix basename
800 base_url = self.url 814 base_url = self.url
801 return base_url[:base_url.rfind('/')] + url 815 return base_url[:base_url.rfind('/')] + url
802 816
817 def GetGitBackupDirPath(self):
818 """Returns the path where the .git folder for the current project can be
819 staged/restored. Use case: subproject moved from DEPS <-> outer project."""
820 return os.path.join(self._root_dir,
821 'old_' + self.relpath.replace(os.sep, '_')) + '.git'
822
803 def _GetMirror(self, url, options): 823 def _GetMirror(self, url, options):
804 """Get a git_cache.Mirror object for the argument url.""" 824 """Get a git_cache.Mirror object for the argument url."""
805 if not git_cache.Mirror.GetCachePath(): 825 if not git_cache.Mirror.GetCachePath():
806 return None 826 return None
807 mirror_kwargs = { 827 mirror_kwargs = {
808 'print_func': self.filter, 828 'print_func': self.filter,
809 'refs': [] 829 'refs': []
810 } 830 }
811 # TODO(hinoka): This currently just fails because lkcr/lkgr are branches 831 # TODO(hinoka): This currently just fails because lkcr/lkgr are branches
812 # not tags. This also adds 20 seconds to every bot_update 832 # not tags. This also adds 20 seconds to every bot_update
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 new_command.append('--force') 1623 new_command.append('--force')
1604 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1624 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1605 new_command.extend(('--accept', 'theirs-conflict')) 1625 new_command.extend(('--accept', 'theirs-conflict'))
1606 elif options.manually_grab_svn_rev: 1626 elif options.manually_grab_svn_rev:
1607 new_command.append('--force') 1627 new_command.append('--force')
1608 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1628 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1609 new_command.extend(('--accept', 'postpone')) 1629 new_command.extend(('--accept', 'postpone'))
1610 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1630 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1611 new_command.extend(('--accept', 'postpone')) 1631 new_command.extend(('--accept', 'postpone'))
1612 return new_command 1632 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698