From 57dd5754e7729a6a60ed54d1399a7d72183d3107 Mon Sep 17 00:00:00 2001 From: "asvitkine@chromium.org" Date: Tue, 27 Sep 2011 15:10:59 +0000 Subject: [PATCH] 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 --- trychange.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trychange.py b/trychange.py index 26c991312..9491a0b16 100755 --- a/trychange.py +++ b/trychange.py @@ -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)