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 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
6 | 6 |
7 import cStringIO | 7 import cStringIO |
8 import glob | 8 import glob |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 @staticmethod | 337 @staticmethod |
338 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False, | 338 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False, |
339 files=None): | 339 files=None): |
340 """Diffs against the upstream branch or optionally another branch. | 340 """Diffs against the upstream branch or optionally another branch. |
341 | 341 |
342 full_move means that move or copy operations should completely recreate the | 342 full_move means that move or copy operations should completely recreate the |
343 files, usually in the prospect to apply the patch for a try job.""" | 343 files, usually in the prospect to apply the patch for a try job.""" |
344 if not branch: | 344 if not branch: |
345 branch = GIT.GetUpstreamBranch(cwd) | 345 branch = GIT.GetUpstreamBranch(cwd) |
346 command = ['diff', '-p', '--no-prefix', '--no-ext-diff', | 346 command = ['diff', '-p', '--no-color', '--no-prefix', '--no-ext-diff', |
347 branch + "..." + branch_head] | 347 branch + "..." + branch_head] |
348 if not full_move: | 348 if not full_move: |
349 command.append('-C') | 349 command.append('-C') |
350 # TODO(maruel): --binary support. | 350 # TODO(maruel): --binary support. |
351 if files: | 351 if files: |
352 command.append('--') | 352 command.append('--') |
353 command.extend(files) | 353 command.extend(files) |
354 diff = GIT.Capture(command, cwd=cwd).splitlines(True) | 354 diff = GIT.Capture(command, cwd=cwd).splitlines(True) |
355 for i in range(len(diff)): | 355 for i in range(len(diff)): |
356 # In the case of added files, replace /dev/null with the path to the | 356 # In the case of added files, replace /dev/null with the path to the |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 # revert, like for properties. | 1048 # revert, like for properties. |
1049 if not os.path.isdir(cwd): | 1049 if not os.path.isdir(cwd): |
1050 # '.' was deleted. It's not worth continuing. | 1050 # '.' was deleted. It's not worth continuing. |
1051 return | 1051 return |
1052 try: | 1052 try: |
1053 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1053 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
1054 except subprocess2.CalledProcessError: | 1054 except subprocess2.CalledProcessError: |
1055 if not os.path.exists(file_path): | 1055 if not os.path.exists(file_path): |
1056 continue | 1056 continue |
1057 raise | 1057 raise |
OLD | NEW |