| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |