Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: scm.py

Issue 16057018: Pass --no-renames to git diff (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 def CaptureStatus(files, cwd, upstream_branch): 106 def CaptureStatus(files, cwd, upstream_branch):
107 """Returns git status. 107 """Returns git status.
108 108
109 @files can be a string (one file) or a list of files. 109 @files can be a string (one file) or a list of files.
110 110
111 Returns an array of (status, file) tuples.""" 111 Returns an array of (status, file) tuples."""
112 if upstream_branch is None: 112 if upstream_branch is None:
113 upstream_branch = GIT.GetUpstreamBranch(cwd) 113 upstream_branch = GIT.GetUpstreamBranch(cwd)
114 if upstream_branch is None: 114 if upstream_branch is None:
115 raise gclient_utils.Error('Cannot determine upstream branch') 115 raise gclient_utils.Error('Cannot determine upstream branch')
116 command = ['diff', '--name-status', '-r', '%s...' % upstream_branch] 116 command = ['diff', '--name-status', '--no-renames',
117 '-r', '%s...' % upstream_branch]
117 if not files: 118 if not files:
118 pass 119 pass
119 elif isinstance(files, basestring): 120 elif isinstance(files, basestring):
120 command.append(files) 121 command.append(files)
121 else: 122 else:
122 command.extend(files) 123 command.extend(files)
123 status = GIT.Capture(command, cwd).rstrip() 124 status = GIT.Capture(command, cwd).rstrip()
124 results = [] 125 results = []
125 if status: 126 if status:
126 for statusline in status.splitlines(): 127 for statusline in status.splitlines():
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False, 340 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False,
340 files=None): 341 files=None):
341 """Diffs against the upstream branch or optionally another branch. 342 """Diffs against the upstream branch or optionally another branch.
342 343
343 full_move means that move or copy operations should completely recreate the 344 full_move means that move or copy operations should completely recreate the
344 files, usually in the prospect to apply the patch for a try job.""" 345 files, usually in the prospect to apply the patch for a try job."""
345 if not branch: 346 if not branch:
346 branch = GIT.GetUpstreamBranch(cwd) 347 branch = GIT.GetUpstreamBranch(cwd)
347 command = ['diff', '-p', '--no-color', '--no-prefix', '--no-ext-diff', 348 command = ['diff', '-p', '--no-color', '--no-prefix', '--no-ext-diff',
348 branch + "..." + branch_head] 349 branch + "..." + branch_head]
349 if not full_move: 350 if full_move:
351 command.append('--no-renames')
352 else:
350 command.append('-C') 353 command.append('-C')
351 # TODO(maruel): --binary support. 354 # TODO(maruel): --binary support.
352 if files: 355 if files:
353 command.append('--') 356 command.append('--')
354 command.extend(files) 357 command.extend(files)
355 diff = GIT.Capture(command, cwd=cwd).splitlines(True) 358 diff = GIT.Capture(command, cwd=cwd).splitlines(True)
356 for i in range(len(diff)): 359 for i in range(len(diff)):
357 # In the case of added files, replace /dev/null with the path to the 360 # In the case of added files, replace /dev/null with the path to the
358 # file being added. 361 # file being added.
359 if diff[i].startswith('--- /dev/null'): 362 if diff[i].startswith('--- /dev/null'):
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 # revert, like for properties. 1090 # revert, like for properties.
1088 if not os.path.isdir(cwd): 1091 if not os.path.isdir(cwd):
1089 # '.' was deleted. It's not worth continuing. 1092 # '.' was deleted. It's not worth continuing.
1090 return 1093 return
1091 try: 1094 try:
1092 SVN.Capture(['revert', file_status[1]], cwd=cwd) 1095 SVN.Capture(['revert', file_status[1]], cwd=cwd)
1093 except subprocess2.CalledProcessError: 1096 except subprocess2.CalledProcessError:
1094 if not os.path.exists(file_path): 1097 if not os.path.exists(file_path):
1095 continue 1098 continue
1096 raise 1099 raise
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698