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

Side by Side Diff: scm.py

Issue 523094: Fix checkout root detection for git (Closed)
Patch Set: Created 10 years, 11 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 | « gclient_utils.py ('k') | tests/trychange_unittest.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) 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 os 7 import os
8 import re 8 import re
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 diff[i] = '--- %s' % diff[i+1][4:] 227 diff[i] = '--- %s' % diff[i+1][4:]
228 return ''.join(diff) 228 return ''.join(diff)
229 229
230 @staticmethod 230 @staticmethod
231 def GetPatchName(cwd): 231 def GetPatchName(cwd):
232 """Constructs a name for this patch.""" 232 """Constructs a name for this patch."""
233 short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd).strip() 233 short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd).strip()
234 return "%s-%s" % (GIT.GetBranch(cwd), short_sha) 234 return "%s-%s" % (GIT.GetBranch(cwd), short_sha)
235 235
236 @staticmethod 236 @staticmethod
237 def GetCheckoutRoot(cwd): 237 def GetCheckoutRoot(path):
238 """Returns the top level directory of the current repository. 238 """Returns the top level directory of a git checkout as an absolute path.
239
240 The directory is returned as an absolute path.
241 """ 239 """
242 return os.path.abspath(GIT.Capture(['rev-parse', '--show-cdup'], 240 root = GIT.Capture(['rev-parse', '--show-cdup'], path).strip()
243 cwd).strip()) 241 return os.path.abspath(os.path.join(path, root))
244 242
245 243
246 class SVN(object): 244 class SVN(object):
247 COMMAND = "svn" 245 COMMAND = "svn"
248 246
249 @staticmethod 247 @staticmethod
250 def Run(args, in_directory): 248 def Run(args, in_directory):
251 """Runs svn, sending output to stdout. 249 """Runs svn, sending output to stdout.
252 250
253 Args: 251 Args:
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 if not cur_dir_repo_root: 693 if not cur_dir_repo_root:
696 return None 694 return None
697 695
698 while True: 696 while True:
699 parent = os.path.dirname(directory) 697 parent = os.path.dirname(directory)
700 if (SVN.CaptureInfo(parent, print_error=False).get( 698 if (SVN.CaptureInfo(parent, print_error=False).get(
701 "Repository Root") != cur_dir_repo_root): 699 "Repository Root") != cur_dir_repo_root):
702 break 700 break
703 directory = parent 701 directory = parent
704 return directory 702 return directory
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | tests/trychange_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698