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

Side by Side Diff: gclient_scm.py

Issue 7918027: Add a --unmanaged flag to gclient config to allow the main solution to be unmanaged by the scm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 3 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 | « gclient.py ('k') | 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) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 """ 167 """
168 if args: 168 if args:
169 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) 169 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
170 170
171 self._CheckMinVersion("1.6.6") 171 self._CheckMinVersion("1.6.6")
172 172
173 default_rev = "refs/heads/master" 173 default_rev = "refs/heads/master"
174 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) 174 url, deps_revision = gclient_utils.SplitUrlRevision(self.url)
175 rev_str = "" 175 rev_str = ""
176 revision = deps_revision 176 revision = deps_revision
177 managed = True
177 if options.revision: 178 if options.revision:
178 # Override the revision number. 179 # Override the revision number.
179 revision = str(options.revision) 180 revision = str(options.revision)
181 if revision == 'unmanaged':
182 revision = None
183 managed = False
180 if not revision: 184 if not revision:
181 revision = default_rev 185 revision = default_rev
182 186
183 if gclient_utils.IsDateRevision(revision): 187 if gclient_utils.IsDateRevision(revision):
184 # Date-revisions only work on git-repositories if the reflog hasn't 188 # Date-revisions only work on git-repositories if the reflog hasn't
185 # expired yet. Use rev-list to get the corresponding revision. 189 # expired yet. Use rev-list to get the corresponding revision.
186 # git rev-list -n 1 --before='time-stamp' branchname 190 # git rev-list -n 1 --before='time-stamp' branchname
187 if options.transitive: 191 if options.transitive:
188 print('Warning: --transitive only works for SVN repositories.') 192 print('Warning: --transitive only works for SVN repositories.')
189 revision = default_rev 193 revision = default_rev
(...skipping 21 matching lines...) Expand all
211 if not os.path.exists(self.checkout_path): 215 if not os.path.exists(self.checkout_path):
212 self._Clone(revision, url, options) 216 self._Clone(revision, url, options)
213 files = self._Capture(['ls-files']).splitlines() 217 files = self._Capture(['ls-files']).splitlines()
214 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 218 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
215 if not verbose: 219 if not verbose:
216 # Make the output a little prettier. It's nice to have some whitespace 220 # Make the output a little prettier. It's nice to have some whitespace
217 # between projects when cloning. 221 # between projects when cloning.
218 print('') 222 print('')
219 return 223 return
220 224
225 if not managed:
226 print ('________ unmanaged solution; skipping %s' % self.relpath)
227 return
228
221 if not os.path.exists(os.path.join(self.checkout_path, '.git')): 229 if not os.path.exists(os.path.join(self.checkout_path, '.git')):
222 raise gclient_utils.Error('\n____ %s%s\n' 230 raise gclient_utils.Error('\n____ %s%s\n'
223 '\tPath is not a git repo. No .git dir.\n' 231 '\tPath is not a git repo. No .git dir.\n'
224 '\tTo resolve:\n' 232 '\tTo resolve:\n'
225 '\t\trm -rf %s\n' 233 '\t\trm -rf %s\n'
226 '\tAnd run gclient sync again\n' 234 '\tAnd run gclient sync again\n'
227 % (self.relpath, rev_str, self.relpath)) 235 % (self.relpath, rev_str, self.relpath))
228 236
229 # See if the url has changed (the unittests use git://foo for the url, let 237 # See if the url has changed (the unittests use git://foo for the url, let
230 # that through). 238 # that through).
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 return 736 return
729 737
730 if args: 738 if args:
731 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) 739 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
732 740
733 # revision is the revision to match. It is None if no revision is specified, 741 # revision is the revision to match. It is None if no revision is specified,
734 # i.e. the 'deps ain't pinned'. 742 # i.e. the 'deps ain't pinned'.
735 url, revision = gclient_utils.SplitUrlRevision(self.url) 743 url, revision = gclient_utils.SplitUrlRevision(self.url)
736 # Keep the original unpinned url for reference in case the repo is switched. 744 # Keep the original unpinned url for reference in case the repo is switched.
737 base_url = url 745 base_url = url
746 managed = True
738 if options.revision: 747 if options.revision:
739 # Override the revision number. 748 # Override the revision number.
740 revision = str(options.revision) 749 revision = str(options.revision)
741 if revision: 750 if revision:
742 forced_revision = True 751 if revision != 'unmanaged':
743 # Reconstruct the url. 752 forced_revision = True
744 url = '%s@%s' % (url, revision) 753 # Reconstruct the url.
745 rev_str = ' at %s' % revision 754 url = '%s@%s' % (url, revision)
755 rev_str = ' at %s' % revision
756 else:
757 managed = False
758 revision = None
746 else: 759 else:
747 forced_revision = False 760 forced_revision = False
748 rev_str = '' 761 rev_str = ''
749 762
750 if not os.path.exists(self.checkout_path): 763 if not os.path.exists(self.checkout_path):
751 # We need to checkout. 764 # We need to checkout.
752 command = ['checkout', url, self.checkout_path] 765 command = ['checkout', url, self.checkout_path]
753 command = self._AddAdditionalUpdateFlags(command, options, revision) 766 command = self._AddAdditionalUpdateFlags(command, options, revision)
754 self._RunAndGetFileList(command, options, file_list, self._root_dir) 767 self._RunAndGetFileList(command, options, file_list, self._root_dir)
755 return 768 return
756 769
770 if not managed:
771 print ('________ unmanaged solution; skipping %s' % self.relpath)
772 return
773
757 # Get the existing scm url and the revision number of the current checkout. 774 # Get the existing scm url and the revision number of the current checkout.
758 try: 775 try:
759 from_info = scm.SVN.CaptureInfo(os.path.join(self.checkout_path, '.')) 776 from_info = scm.SVN.CaptureInfo(os.path.join(self.checkout_path, '.'))
760 except (gclient_utils.Error, subprocess2.CalledProcessError): 777 except (gclient_utils.Error, subprocess2.CalledProcessError):
761 raise gclient_utils.Error( 778 raise gclient_utils.Error(
762 ('Can\'t update/checkout %s if an unversioned directory is present. ' 779 ('Can\'t update/checkout %s if an unversioned directory is present. '
763 'Delete the directory and try again.') % self.checkout_path) 780 'Delete the directory and try again.') % self.checkout_path)
764 781
765 # Look for locked directories. 782 # Look for locked directories.
766 dir_info = scm.SVN.CaptureStatus(os.path.join(self.checkout_path, '.')) 783 dir_info = scm.SVN.CaptureStatus(os.path.join(self.checkout_path, '.'))
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 956
940 This method returns a new list to be used as a command.""" 957 This method returns a new list to be used as a command."""
941 new_command = command[:] 958 new_command = command[:]
942 if revision: 959 if revision:
943 new_command.extend(['--revision', str(revision).strip()]) 960 new_command.extend(['--revision', str(revision).strip()])
944 # --force was added to 'svn update' in svn 1.5. 961 # --force was added to 'svn update' in svn 1.5.
945 if ((options.force or options.manually_grab_svn_rev) and 962 if ((options.force or options.manually_grab_svn_rev) and
946 scm.SVN.AssertVersion("1.5")[0]): 963 scm.SVN.AssertVersion("1.5")[0]):
947 new_command.append('--force') 964 new_command.append('--force')
948 return new_command 965 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698