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

Side by Side Diff: scm.py

Issue 554142: Fix a FetchUpstreamTuple cwd bug (Closed)
Patch Set: Created 10 years, 10 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 | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2006-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 """SCM-specific utility classes.""" 5 """SCM-specific utility classes."""
6 6
7 import glob 7 import glob
8 import os 8 import os
9 import re 9 import re
10 import shutil 10 import shutil
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 @staticmethod 199 @staticmethod
200 def FetchUpstreamTuple(cwd): 200 def FetchUpstreamTuple(cwd):
201 """Returns a tuple containg remote and remote ref, 201 """Returns a tuple containg remote and remote ref,
202 e.g. 'origin', 'refs/heads/master' 202 e.g. 'origin', 'refs/heads/master'
203 """ 203 """
204 remote = '.' 204 remote = '.'
205 branch = GIT.GetBranch(cwd) 205 branch = GIT.GetBranch(cwd)
206 upstream_branch = None 206 upstream_branch = None
207 upstream_branch = GIT.Capture( 207 upstream_branch = GIT.Capture(
208 ['config', 'branch.%s.merge' % branch], error_ok=True).strip() 208 ['config', 'branch.%s.merge' % branch], in_directory=cwd,
209 error_ok=True).strip()
209 if upstream_branch: 210 if upstream_branch:
210 remote = GIT.Capture( 211 remote = GIT.Capture(
211 ['config', 'branch.%s.remote' % branch], 212 ['config', 'branch.%s.remote' % branch],
212 error_ok=True).strip() 213 in_directory=cwd, error_ok=True).strip()
213 else: 214 else:
214 # Fall back on trying a git-svn upstream branch. 215 # Fall back on trying a git-svn upstream branch.
215 if GIT.IsGitSvn(cwd): 216 if GIT.IsGitSvn(cwd):
216 upstream_branch = GIT.GetSVNBranch(cwd) 217 upstream_branch = GIT.GetSVNBranch(cwd)
217 # Fall back on origin/master if it exits.
218 if not upstream_branch:
219 GIT.Capture(['branch', '-r']).split().count('origin/master')
220 remote = 'origin'
221 upstream_branch = 'refs/heads/master'
222 return remote, upstream_branch 218 return remote, upstream_branch
223 219
224 @staticmethod 220 @staticmethod
225 def GetUpstream(cwd): 221 def GetUpstream(cwd):
226 """Gets the current branch's upstream branch.""" 222 """Gets the current branch's upstream branch."""
227 remote, upstream_branch = GIT.FetchUpstreamTuple(cwd) 223 remote, upstream_branch = GIT.FetchUpstreamTuple(cwd)
228 if remote is not '.': 224 if remote is not '.':
229 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote) 225 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote)
230 return upstream_branch 226 return upstream_branch
231 227
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 if not cur_dir_repo_root: 729 if not cur_dir_repo_root:
734 return None 730 return None
735 731
736 while True: 732 while True:
737 parent = os.path.dirname(directory) 733 parent = os.path.dirname(directory)
738 if (SVN.CaptureInfo(parent, print_error=False).get( 734 if (SVN.CaptureInfo(parent, print_error=False).get(
739 "Repository Root") != cur_dir_repo_root): 735 "Repository Root") != cur_dir_repo_root):
740 break 736 break
741 directory = parent 737 directory = parent
742 return GetCasedPath(directory) 738 return GetCasedPath(directory)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698