Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 All updated files will be appended to file_list. | 109 All updated files will be appended to file_list. |
| 110 | 110 |
| 111 Raises: | 111 Raises: |
| 112 Error: if can't get URL for relative path. | 112 Error: if can't get URL for relative path. |
| 113 """ | 113 """ |
| 114 | 114 |
| 115 if args: | 115 if args: |
| 116 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 116 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
| 117 | 117 |
| 118 self._CheckMinVersion("1.6.1") | |
| 119 | |
| 118 url, revision = gclient_utils.SplitUrlRevision(self.url) | 120 url, revision = gclient_utils.SplitUrlRevision(self.url) |
| 119 rev_str = "" | 121 rev_str = "" |
| 120 if options.revision: | 122 if options.revision: |
| 121 # Override the revision number. | 123 # Override the revision number. |
| 122 revision = str(options.revision) | 124 revision = str(options.revision) |
| 123 if revision: | 125 if revision: |
| 124 rev_str = ' at %s' % revision | 126 rev_str = ' at %s' % revision |
| 125 | 127 |
| 126 if options.verbose: | 128 if options.verbose: |
| 127 print("\n_____ %s%s" % (self.relpath, rev_str)) | 129 print("\n_____ %s%s" % (self.relpath, rev_str)) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 __pychecker__ = 'unusednames=args,options' | 180 __pychecker__ = 'unusednames=args,options' |
| 179 if not os.path.isdir(self.checkout_path): | 181 if not os.path.isdir(self.checkout_path): |
| 180 print('\n________ couldn\'t run status in %s:\nThe directory ' | 182 print('\n________ couldn\'t run status in %s:\nThe directory ' |
| 181 'does not exist.' % self.checkout_path) | 183 'does not exist.' % self.checkout_path) |
| 182 else: | 184 else: |
| 183 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 185 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) |
| 184 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) | 186 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) |
| 185 files = self._Run(['diff', '--name-only', merge_base]).split() | 187 files = self._Run(['diff', '--name-only', merge_base]).split() |
| 186 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 188 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 187 | 189 |
| 190 def _CheckMinVersion(self, min_version): | |
| 191 version = self._Run(['--version']).split()[-1] | |
| 192 version_list = map(int, version.split('.')) | |
| 193 min_version_list = map(int, min_version.split('.')) | |
|
M-A Ruel
2009/12/11 19:51:54
Nice idea, I wouldn't have thought about that.
| |
| 194 for min_ver in min_version_list: | |
| 195 ver = version_list.pop(0) | |
| 196 if min_ver > ver: | |
| 197 raise gclient_utils.Error('git version %s < minimum required %s' % | |
| 198 (version, min_version)) | |
| 199 elif min_ver < ver: | |
| 200 return | |
| 201 | |
| 188 def _Run(self, args, cwd=None, checkrc=True, redirect_stdout=True): | 202 def _Run(self, args, cwd=None, checkrc=True, redirect_stdout=True): |
| 189 # TODO(maruel): Merge with Capture? | 203 # TODO(maruel): Merge with Capture? |
| 190 if cwd is None: | 204 if cwd is None: |
| 191 cwd = self.checkout_path | 205 cwd = self.checkout_path |
| 192 stdout=None | 206 stdout=None |
| 193 if redirect_stdout: | 207 if redirect_stdout: |
| 194 stdout=subprocess.PIPE | 208 stdout=subprocess.PIPE |
| 195 if cwd == None: | 209 if cwd == None: |
| 196 cwd = self.checkout_path | 210 cwd = self.checkout_path |
| 197 cmd = [self.COMMAND] | 211 cmd = [self.COMMAND] |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 self.ReplaceAndPrint(line) | 474 self.ReplaceAndPrint(line) |
| 461 else: | 475 else: |
| 462 if (line.startswith(self.original_prefix) or | 476 if (line.startswith(self.original_prefix) or |
| 463 line.startswith(self.working_prefix)): | 477 line.startswith(self.working_prefix)): |
| 464 self.ReplaceAndPrint(line) | 478 self.ReplaceAndPrint(line) |
| 465 else: | 479 else: |
| 466 print line | 480 print line |
| 467 | 481 |
| 468 filterer = DiffFilterer(self.relpath) | 482 filterer = DiffFilterer(self.relpath) |
| 469 self.RunAndFilterOutput(command, path, False, False, filterer.Filter) | 483 self.RunAndFilterOutput(command, path, False, False, filterer.Filter) |
| OLD | NEW |