OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 def pack(self, options, args, file_list): | 146 def pack(self, options, args, file_list): |
147 """Generates a patch file which can be applied to the root of the | 147 """Generates a patch file which can be applied to the root of the |
148 repository. | 148 repository. |
149 | 149 |
150 The patch file is generated from a diff of the merge base of HEAD and | 150 The patch file is generated from a diff of the merge base of HEAD and |
151 its upstream branch. | 151 its upstream branch. |
152 """ | 152 """ |
153 path = os.path.join(self._root_dir, self.relpath) | 153 path = os.path.join(self._root_dir, self.relpath) |
154 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 154 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) |
155 command = ['diff', merge_base] | 155 command = ['git', 'diff', merge_base] |
156 filterer = DiffFilterer(self.relpath) | 156 filterer = DiffFilterer(self.relpath) |
157 scm.GIT.RunAndFilterOutput(command, cwd=path, filter_fn=filterer.Filter, | 157 gclient_utils.CheckCallAndFilter( |
158 stdout=options.stdout) | 158 command, cwd=path, filter_fn=filterer.Filter, stdout=options.stdout) |
159 | 159 |
160 def update(self, options, args, file_list): | 160 def update(self, options, args, file_list): |
161 """Runs git to update or transparently checkout the working copy. | 161 """Runs git to update or transparently checkout the working copy. |
162 | 162 |
163 All updated files will be appended to file_list. | 163 All updated files will be appended to file_list. |
164 | 164 |
165 Raises: | 165 Raises: |
166 Error: if can't get URL for relative path. | 166 Error: if can't get URL for relative path. |
167 """ | 167 """ |
168 | 168 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 643 |
644 def _Run(self, args, cwd=None, redirect_stdout=True): | 644 def _Run(self, args, cwd=None, redirect_stdout=True): |
645 # TODO(maruel): Merge with Capture or better gclient_utils.CheckCall(). | 645 # TODO(maruel): Merge with Capture or better gclient_utils.CheckCall(). |
646 if cwd is None: | 646 if cwd is None: |
647 cwd = self.checkout_path | 647 cwd = self.checkout_path |
648 stdout = None | 648 stdout = None |
649 if redirect_stdout: | 649 if redirect_stdout: |
650 stdout = subprocess.PIPE | 650 stdout = subprocess.PIPE |
651 if cwd == None: | 651 if cwd == None: |
652 cwd = self.checkout_path | 652 cwd = self.checkout_path |
653 cmd = [scm.GIT.COMMAND] | 653 cmd = ['git'] + args |
654 cmd.extend(args) | |
655 logging.debug(cmd) | 654 logging.debug(cmd) |
656 try: | 655 try: |
657 sp = gclient_utils.Popen(cmd, cwd=cwd, stdout=stdout) | 656 sp = gclient_utils.Popen(cmd, cwd=cwd, stdout=stdout) |
658 output = sp.communicate()[0] | 657 output = sp.communicate()[0] |
659 except OSError: | 658 except OSError: |
660 raise gclient_utils.Error("git command '%s' failed to run." % | 659 raise gclient_utils.Error("git command '%s' failed to run." % |
661 ' '.join(cmd) + "\nCheck that you have git installed.") | 660 ' '.join(cmd) + "\nCheck that you have git installed.") |
662 if sp.returncode: | 661 if sp.returncode: |
663 raise gclient_utils.Error('git command %s returned %d' % | 662 raise gclient_utils.Error('git command %s returned %d' % |
664 (args[0], sp.returncode)) | 663 (args[0], sp.returncode)) |
(...skipping 27 matching lines...) Expand all Loading... |
692 assert os.path.exists(export_path) | 691 assert os.path.exists(export_path) |
693 scm.SVN.Run(['export', '--force', '.', export_path], | 692 scm.SVN.Run(['export', '--force', '.', export_path], |
694 cwd=os.path.join(self._root_dir, self.relpath)) | 693 cwd=os.path.join(self._root_dir, self.relpath)) |
695 | 694 |
696 def pack(self, options, args, file_list): | 695 def pack(self, options, args, file_list): |
697 """Generates a patch file which can be applied to the root of the | 696 """Generates a patch file which can be applied to the root of the |
698 repository.""" | 697 repository.""" |
699 path = os.path.join(self._root_dir, self.relpath) | 698 path = os.path.join(self._root_dir, self.relpath) |
700 if not os.path.isdir(path): | 699 if not os.path.isdir(path): |
701 raise gclient_utils.Error('Directory %s is not present.' % path) | 700 raise gclient_utils.Error('Directory %s is not present.' % path) |
702 command = ['diff', '-x', '--ignore-eol-style'] | 701 command = ['svn', 'diff', '-x', '--ignore-eol-style'] |
703 command.extend(args) | 702 command.extend(args) |
704 | 703 |
705 filterer = DiffFilterer(self.relpath) | 704 filterer = DiffFilterer(self.relpath) |
706 scm.SVN.RunAndFilterOutput(command, cwd=path, print_messages=False, | 705 gclient_utils.CheckCallAndFilter(command, cwd=path, always=False, |
707 print_stdout=False, filter_fn=filterer.Filter, | 706 print_stdout=False, filter_fn=filterer.Filter, |
708 stdout=options.stdout) | 707 stdout=options.stdout) |
709 | 708 |
710 def update(self, options, args, file_list): | 709 def update(self, options, args, file_list): |
711 """Runs svn to update or transparently checkout the working copy. | 710 """Runs svn to update or transparently checkout the working copy. |
712 | 711 |
713 All updated files will be appended to file_list. | 712 All updated files will be appended to file_list. |
714 | 713 |
715 Raises: | 714 Raises: |
716 Error: if can't get URL for relative path. | 715 Error: if can't get URL for relative path. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 959 |
961 This method returns a new list to be used as a command.""" | 960 This method returns a new list to be used as a command.""" |
962 new_command = command[:] | 961 new_command = command[:] |
963 if revision: | 962 if revision: |
964 new_command.extend(['--revision', str(revision).strip()]) | 963 new_command.extend(['--revision', str(revision).strip()]) |
965 # --force was added to 'svn update' in svn 1.5. | 964 # --force was added to 'svn update' in svn 1.5. |
966 if ((options.force or options.manually_grab_svn_rev) and | 965 if ((options.force or options.manually_grab_svn_rev) and |
967 scm.SVN.AssertVersion("1.5")[0]): | 966 scm.SVN.AssertVersion("1.5")[0]): |
968 new_command.append('--force') | 967 new_command.append('--force') |
969 return new_command | 968 return new_command |
OLD | NEW |