| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from __future__ import print_function | 7 from __future__ import print_function |
| 8 | 8 |
| 9 import errno | 9 import errno |
| 10 import logging | 10 import logging |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return self._Capture(['log', '-n', '1', '--format=%ai']) | 285 return self._Capture(['log', '-n', '1', '--format=%ai']) |
| 286 | 286 |
| 287 @staticmethod | 287 @staticmethod |
| 288 def cleanup(options, args, file_list): | 288 def cleanup(options, args, file_list): |
| 289 """'Cleanup' the repo. | 289 """'Cleanup' the repo. |
| 290 | 290 |
| 291 There's no real git equivalent for the svn cleanup command, do a no-op. | 291 There's no real git equivalent for the svn cleanup command, do a no-op. |
| 292 """ | 292 """ |
| 293 | 293 |
| 294 def diff(self, options, _args, _file_list): | 294 def diff(self, options, _args, _file_list): |
| 295 merge_base = self._Capture(['merge-base', 'HEAD', self.remote]) | 295 try: |
| 296 self._Run(['diff', merge_base], options) | 296 merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] |
| 297 except subprocess2.CalledProcessError: |
| 298 merge_base = [] |
| 299 self._Run(['diff'] + merge_base, options) |
| 297 | 300 |
| 298 def pack(self, _options, _args, _file_list): | 301 def pack(self, _options, _args, _file_list): |
| 299 """Generates a patch file which can be applied to the root of the | 302 """Generates a patch file which can be applied to the root of the |
| 300 repository. | 303 repository. |
| 301 | 304 |
| 302 The patch file is generated from a diff of the merge base of HEAD and | 305 The patch file is generated from a diff of the merge base of HEAD and |
| 303 its upstream branch. | 306 its upstream branch. |
| 304 """ | 307 """ |
| 305 merge_base = self._Capture(['merge-base', 'HEAD', self.remote]) | 308 try: |
| 309 merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] |
| 310 except subprocess2.CalledProcessError: |
| 311 merge_base = [] |
| 306 gclient_utils.CheckCallAndFilter( | 312 gclient_utils.CheckCallAndFilter( |
| 307 ['git', 'diff', merge_base], | 313 ['git', 'diff'] + merge_base, |
| 308 cwd=self.checkout_path, | 314 cwd=self.checkout_path, |
| 309 filter_fn=GitDiffFilterer(self.relpath, print_func=self.Print).Filter) | 315 filter_fn=GitDiffFilterer(self.relpath, print_func=self.Print).Filter) |
| 310 | 316 |
| 311 def _FetchAndReset(self, revision, file_list, options): | 317 def _FetchAndReset(self, revision, file_list, options): |
| 312 """Equivalent to git fetch; git reset.""" | 318 """Equivalent to git fetch; git reset.""" |
| 313 quiet = [] | 319 quiet = [] |
| 314 if not options.verbose: | 320 if not options.verbose: |
| 315 quiet = ['--quiet'] | 321 quiet = ['--quiet'] |
| 316 self._UpdateBranchHeads(options, fetch=False) | 322 self._UpdateBranchHeads(options, fetch=False) |
| 317 | 323 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 784 |
| 779 def runhooks(self, options, args, file_list): | 785 def runhooks(self, options, args, file_list): |
| 780 self.status(options, args, file_list) | 786 self.status(options, args, file_list) |
| 781 | 787 |
| 782 def status(self, options, _args, file_list): | 788 def status(self, options, _args, file_list): |
| 783 """Display status information.""" | 789 """Display status information.""" |
| 784 if not os.path.isdir(self.checkout_path): | 790 if not os.path.isdir(self.checkout_path): |
| 785 self.Print('________ couldn\'t run status in %s:\n' | 791 self.Print('________ couldn\'t run status in %s:\n' |
| 786 'The directory does not exist.' % self.checkout_path) | 792 'The directory does not exist.' % self.checkout_path) |
| 787 else: | 793 else: |
| 788 merge_base = self._Capture(['merge-base', 'HEAD', self.remote]) | 794 try: |
| 789 self._Run(['diff', '--name-status', merge_base], options, | 795 merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] |
| 796 except subprocess2.CalledProcessError: |
| 797 merge_base = [] |
| 798 self._Run(['diff', '--name-status'] + merge_base, options, |
| 790 stdout=self.out_fh) | 799 stdout=self.out_fh) |
| 791 if file_list is not None: | 800 if file_list is not None: |
| 792 files = self._Capture(['diff', '--name-only', merge_base]).split() | 801 files = self._Capture(['diff', '--name-only'] + merge_base).split() |
| 793 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 802 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 794 | 803 |
| 795 def GetUsableRev(self, rev, options): | 804 def GetUsableRev(self, rev, options): |
| 796 """Finds a useful revision for this repository. | 805 """Finds a useful revision for this repository. |
| 797 | 806 |
| 798 If SCM is git-svn and the head revision is less than |rev|, git svn fetch | 807 If SCM is git-svn and the head revision is less than |rev|, git svn fetch |
| 799 will be called on the source.""" | 808 will be called on the source.""" |
| 800 sha1 = None | 809 sha1 = None |
| 801 if not os.path.isdir(self.checkout_path): | 810 if not os.path.isdir(self.checkout_path): |
| 802 raise NoUsableRevError( | 811 raise NoUsableRevError( |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1718 new_command.append('--force') | 1727 new_command.append('--force') |
| 1719 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1728 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1720 new_command.extend(('--accept', 'theirs-conflict')) | 1729 new_command.extend(('--accept', 'theirs-conflict')) |
| 1721 elif options.manually_grab_svn_rev: | 1730 elif options.manually_grab_svn_rev: |
| 1722 new_command.append('--force') | 1731 new_command.append('--force') |
| 1723 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1732 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1724 new_command.extend(('--accept', 'postpone')) | 1733 new_command.extend(('--accept', 'postpone')) |
| 1725 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1734 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1726 new_command.extend(('--accept', 'postpone')) | 1735 new_command.extend(('--accept', 'postpone')) |
| 1727 return new_command | 1736 return new_command |
| OLD | NEW |