| 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 glob | 7 import glob |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import shutil | 10 import shutil |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 c = [GIT.COMMAND] | 58 c = [GIT.COMMAND] |
| 59 c.extend(args) | 59 c.extend(args) |
| 60 try: | 60 try: |
| 61 return gclient_utils.CheckCall(c, in_directory, print_error) | 61 return gclient_utils.CheckCall(c, in_directory, print_error) |
| 62 except gclient_utils.CheckCallError: | 62 except gclient_utils.CheckCallError: |
| 63 if error_ok: | 63 if error_ok: |
| 64 return ('', '') | 64 return ('', '') |
| 65 raise | 65 raise |
| 66 | 66 |
| 67 @staticmethod | 67 @staticmethod |
| 68 def CaptureStatus(files, upstream_branch='origin'): | 68 def CaptureStatus(files, upstream_branch=None): |
| 69 """Returns git status. | 69 """Returns git status. |
| 70 | 70 |
| 71 @files can be a string (one file) or a list of files. | 71 @files can be a string (one file) or a list of files. |
| 72 | 72 |
| 73 Returns an array of (status, file) tuples.""" | 73 Returns an array of (status, file) tuples.""" |
| 74 if upstream_branch is None: |
| 75 upstream_branch = GIT.GetUpstreamBranch(os.getcwd()) |
| 76 if upstream_branch is None: |
| 77 raise Exception("Cannot determine upstream branch") |
| 74 command = ["diff", "--name-status", "-r", "%s..." % upstream_branch] | 78 command = ["diff", "--name-status", "-r", "%s..." % upstream_branch] |
| 75 if not files: | 79 if not files: |
| 76 pass | 80 pass |
| 77 elif isinstance(files, basestring): | 81 elif isinstance(files, basestring): |
| 78 command.append(files) | 82 command.append(files) |
| 79 else: | 83 else: |
| 80 command.extend(files) | 84 command.extend(files) |
| 81 | 85 |
| 82 status = GIT.Capture(command)[0].rstrip() | 86 status = GIT.Capture(command)[0].rstrip() |
| 83 results = [] | 87 results = [] |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if not SVN.current_version: | 803 if not SVN.current_version: |
| 800 SVN.current_version = SVN.Capture(['--version']).split()[2] | 804 SVN.current_version = SVN.Capture(['--version']).split()[2] |
| 801 current_version_list = map(only_int, SVN.current_version.split('.')) | 805 current_version_list = map(only_int, SVN.current_version.split('.')) |
| 802 for min_ver in map(int, min_version.split('.')): | 806 for min_ver in map(int, min_version.split('.')): |
| 803 ver = current_version_list.pop(0) | 807 ver = current_version_list.pop(0) |
| 804 if ver < min_ver: | 808 if ver < min_ver: |
| 805 return (False, SVN.current_version) | 809 return (False, SVN.current_version) |
| 806 elif ver > min_ver: | 810 elif ver > min_ver: |
| 807 return (True, SVN.current_version) | 811 return (True, SVN.current_version) |
| 808 return (True, SVN.current_version) | 812 return (True, SVN.current_version) |
| OLD | NEW |