Extract filenames from diffs better.

This is a followup to: http://codereview.chromium.org/8059009/

Only add the file once instead of twice (since the diff has --- and +++ lines for each file).
Strip whitespace at the end (git diffs don't include a \t so split('\t') isn't enough).
Remove leading 'a/' from the path, since git diffs have these.

BUG=none
TEST=manual

Review URL: http://codereview.chromium.org/8050017

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@102934 0039d316-1c4b-4281-b951-d872f2087c98
parent 1516995e
......@@ -478,7 +478,11 @@ def GetMungedDiff(path_diff, diff):
for i in range(len(diff)):
if diff[i].startswith('--- ') or diff[i].startswith('+++ '):
new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/')
changed_files.append(('M', new_file.split('\t')[0]))
if diff[i].startswith('--- '):
file_path = new_file.split('\t')[0].strip()
if file_path.startswith('a/'):
file_path = file_path[2:]
changed_files.append(('M', file_path))
diff[i] = diff[i][0:4] + new_file
return (diff, changed_files)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment