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

Side by Side Diff: gclient_scm.py

Issue 289863012: Handle branch or commit refs in the url for unmanaged git solutions (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: split long line, reuse deps_revision 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
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | tests/gclient_scm_test.py » ('J')
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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 # If a dependency is not pinned, track the default remote branch. 324 # If a dependency is not pinned, track the default remote branch.
325 default_rev = 'refs/remotes/%s/master' % self.remote 325 default_rev = 'refs/remotes/%s/master' % self.remote
326 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) 326 url, deps_revision = gclient_utils.SplitUrlRevision(self.url)
327 rev_str = "" 327 rev_str = ""
328 revision = deps_revision 328 revision = deps_revision
329 managed = True 329 managed = True
330 if options.revision: 330 if options.revision:
331 # Override the revision number. 331 # Override the revision number.
332 revision = str(options.revision) 332 revision = str(options.revision)
333 if revision == 'unmanaged': 333 if revision == 'unmanaged':
334 revision = None 334 # Check again for a revision in case an initial ref was specified
335 # in the url, for example bla.git@refs/heads/custombranch
336 revision = deps_revision
335 managed = False 337 managed = False
336 if not revision: 338 if not revision:
337 revision = default_rev 339 revision = default_rev
338 340
339 if gclient_utils.IsDateRevision(revision): 341 if gclient_utils.IsDateRevision(revision):
340 # Date-revisions only work on git-repositories if the reflog hasn't 342 # Date-revisions only work on git-repositories if the reflog hasn't
341 # expired yet. Use rev-list to get the corresponding revision. 343 # expired yet. Use rev-list to get the corresponding revision.
342 # git rev-list -n 1 --before='time-stamp' branchname 344 # git rev-list -n 1 --before='time-stamp' branchname
343 if options.transitive: 345 if options.transitive:
344 self.Print('Warning: --transitive only works for SVN repositories.') 346 self.Print('Warning: --transitive only works for SVN repositories.')
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 gclient_utils.safe_makedirs(self.checkout_path) 814 gclient_utils.safe_makedirs(self.checkout_path)
813 gclient_utils.safe_rename(os.path.join(tmp_dir, '.git'), 815 gclient_utils.safe_rename(os.path.join(tmp_dir, '.git'),
814 os.path.join(self.checkout_path, '.git')) 816 os.path.join(self.checkout_path, '.git'))
815 except: 817 except:
816 traceback.print_exc(file=self.out_fh) 818 traceback.print_exc(file=self.out_fh)
817 raise 819 raise
818 finally: 820 finally:
819 if os.listdir(tmp_dir): 821 if os.listdir(tmp_dir):
820 self.Print('_____ removing non-empty tmp dir %s' % tmp_dir) 822 self.Print('_____ removing non-empty tmp dir %s' % tmp_dir)
821 gclient_utils.rmtree(tmp_dir) 823 gclient_utils.rmtree(tmp_dir)
822 if revision.startswith('refs/heads/'): 824 self._Run(['checkout', '--quiet', revision.replace('refs/heads/', '')],
823 self._Run( 825 options)
824 ['checkout', '--quiet', revision.replace('refs/heads/', '')], options) 826 if self._GetCurrentBranch() is None:
825 else:
826 # Squelch git's very verbose detached HEAD warning and use our own 827 # Squelch git's very verbose detached HEAD warning and use our own
827 self._Run(['checkout', '--quiet', revision], options)
828 self.Print( 828 self.Print(
829 ('Checked out %s to a detached HEAD. Before making any commits\n' 829 ('Checked out %s to a detached HEAD. Before making any commits\n'
830 'in this repo, you should use \'git checkout <branch>\' to switch to\n' 830 'in this repo, you should use \'git checkout <branch>\' to switch to\n'
831 'an existing branch or use \'git checkout %s -b <branch>\' to\n' 831 'an existing branch or use \'git checkout %s -b <branch>\' to\n'
832 'create a new branch for your work.') % (revision, self.remote)) 832 'create a new branch for your work.') % (revision, self.remote))
833 833
834 def _AskForData(self, prompt, options): 834 def _AskForData(self, prompt, options):
835 if options.jobs > 1: 835 if options.jobs > 1:
836 self.Print(prompt) 836 self.Print(prompt)
837 raise gclient_utils.Error("Background task requires input. Rerun " 837 raise gclient_utils.Error("Background task requires input. Rerun "
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 new_command.append('--force') 1483 new_command.append('--force')
1484 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1484 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1485 new_command.extend(('--accept', 'theirs-conflict')) 1485 new_command.extend(('--accept', 'theirs-conflict'))
1486 elif options.manually_grab_svn_rev: 1486 elif options.manually_grab_svn_rev:
1487 new_command.append('--force') 1487 new_command.append('--force')
1488 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1488 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1489 new_command.extend(('--accept', 'postpone')) 1489 new_command.extend(('--accept', 'postpone'))
1490 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1490 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1491 new_command.extend(('--accept', 'postpone')) 1491 new_command.extend(('--accept', 'postpone'))
1492 return new_command 1492 return new_command
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | tests/gclient_scm_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698