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

Side by Side Diff: gclient_scm.py

Issue 1739021: Modify scm.GIT.GetUpstreamBranch to behave like git-cl. (Closed)
Patch Set: Created 10 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 | 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) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2009 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 # 1) current branch based on a hash (could be git-svn) 230 # 1) current branch based on a hash (could be git-svn)
231 # - try to rebase onto the new upstream (hash or branch) 231 # - try to rebase onto the new upstream (hash or branch)
232 # 2) current branch based on a remote branch with local committed changes, 232 # 2) current branch based on a remote branch with local committed changes,
233 # but the DEPS file switched to point to a hash 233 # but the DEPS file switched to point to a hash
234 # - rebase those changes on top of the hash 234 # - rebase those changes on top of the hash
235 # 3) current branch based on a remote with or without changes, no switch 235 # 3) current branch based on a remote with or without changes, no switch
236 # - see if we can FF, if not, prompt the user for rebase, merge, or stop 236 # - see if we can FF, if not, prompt the user for rebase, merge, or stop
237 # 4) current branch based on a remote, switches to a new remote 237 # 4) current branch based on a remote, switches to a new remote
238 # - exit 238 # - exit
239 239
240 # GetUpstream returns something like 'refs/remotes/origin/master' for a 240 # GetUpstreamBranch returns something like 'refs/remotes/origin/master' for
241 # tracking branch 241 # a tracking branch
242 # or 'master' if not a tracking branch (it's based on a specific rev/hash) 242 # or 'master' if not a tracking branch (it's based on a specific rev/hash)
243 # or it returns None if it couldn't find an upstream 243 # or it returns None if it couldn't find an upstream
244 upstream_branch = scm.GIT.GetUpstream(self.checkout_path) 244 upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path)
245 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): 245 if not upstream_branch or not upstream_branch.startswith('refs/remotes'):
246 current_type = "hash" 246 current_type = "hash"
247 logging.debug("Current branch is based off a specific rev and is not " 247 logging.debug("Current branch is based off a specific rev and is not "
248 "tracking an upstream.") 248 "tracking an upstream.")
249 elif upstream_branch.startswith('refs/remotes'): 249 elif upstream_branch.startswith('refs/remotes'):
250 current_type = "branch" 250 current_type = "branch"
251 else: 251 else:
252 raise gclient_utils.Error('Invalid Upstream') 252 raise gclient_utils.Error('Invalid Upstream')
253 253
254 # Update the remotes first so we have all the refs. 254 # Update the remotes first so we have all the refs.
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " 850 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory "
851 "does not exist." 851 "does not exist."
852 % (' '.join(command), path)) 852 % (' '.join(command), path))
853 # There's no file list to retrieve. 853 # There's no file list to retrieve.
854 else: 854 else:
855 scm.SVN.RunAndGetFileList(options, command, path, file_list) 855 scm.SVN.RunAndGetFileList(options, command, path, file_list)
856 856
857 def FullUrlForRelativeUrl(self, url): 857 def FullUrlForRelativeUrl(self, url):
858 # Find the forth '/' and strip from there. A bit hackish. 858 # Find the forth '/' and strip from there. A bit hackish.
859 return '/'.join(self.url.split('/')[:4]) + url 859 return '/'.join(self.url.split('/')[:4]) + url
OLDNEW
« no previous file with comments | « no previous file | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698