From dffc73cb44da22c636a20d74148e1e02b4f8186b Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Fri, 21 Sep 2012 19:09:16 +0000 Subject: [PATCH] Fix applying git diff with new file mode 644 on a svn checkout. svn propdel svn:executable shouldn't be called on it. R=petermayo@chromium.org BUG=150960 Review URL: https://chromiumcodereview.appspot.com/10962038 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@158038 0039d316-1c4b-4281-b951-d872f2087c98 --- patch.py | 4 +++- testing_support/patches_data.py | 10 ++++++++++ tests/patch_test.py | 11 ++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/patch.py b/patch.py index 44282ddaf..54f5d175a 100644 --- a/patch.py +++ b/patch.py @@ -406,7 +406,9 @@ class FilePatchDiff(FilePatchBase): # Only look at owner ACL for executable. if bool(int(mode[4]) & 1): self.svn_properties.append(('svn:executable', '*')) - else: + elif not self.source_filename and self.is_new: + # It's a new file, not from a rename/copy, then there's no property to + # delete. self.svn_properties.append(('svn:executable', None)) return diff --git a/testing_support/patches_data.py b/testing_support/patches_data.py index 3134a98a2..1acd83265 100644 --- a/testing_support/patches_data.py +++ b/testing_support/patches_data.py @@ -292,6 +292,16 @@ class GIT(object): 'old mode 100644\n' 'new mode 100755\n') + NEW_NOT_EXECUTABLE = ( + 'diff --git a/build/android/ant/create.js b/build/android/ant/create.js\n' + 'new file mode 100644\n' + 'index 0000000000000000000..542a89e978feada38dd\n' + '--- /dev/null\n' + '+++ b/build/android/ant/create.js\n' + '@@ -0,0 +1,1 @@\n' + '+// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n' + ) + FOUR_HUNKS = ( 'Index: presubmit_support.py\n' 'diff --git a/presubmit_support.py b/presubmit_support.py\n' diff --git a/tests/patch_test.py b/tests/patch_test.py index 6aa7cd17b..5a442d07f 100755 --- a/tests/patch_test.py +++ b/tests/patch_test.py @@ -32,7 +32,6 @@ class PatchTest(unittest.TestCase): patchlevel=0, svn_properties=None, nb_hunks=None): - svn_properties = svn_properties or [] self.assertEquals(p.filename, filename) self.assertEquals(p.source_filename, source_filename) self.assertEquals(p.is_binary, is_binary) @@ -51,6 +50,8 @@ class PatchTest(unittest.TestCase): self.assertEquals(len(p.hunks), nb_hunks) else: self.assertEquals(None, nb_hunks) + if hasattr(p, 'svn_properties'): + self.assertEquals(p.svn_properties, svn_properties or []) def testFilePatchDelete(self): p = patch.FilePatchDelete('foo', False) @@ -89,6 +90,14 @@ class PatchTest(unittest.TestCase): p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, svn_properties=[('svn:executable', '*')], nb_hunks=0) + def testFilePatchDiffHeaderNotExecutable(self): + p = patch.FilePatchDiff( + 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, []) + self._check_patch( + p, 'build/android/ant/create.js', GIT.NEW_NOT_EXECUTABLE, + is_git_diff=True, patchlevel=1, is_new=True, + nb_hunks=1) + def testFilePatchDiffSvnNew(self): # The code path is different for git and svn. p = patch.FilePatchDiff('foo', RAW.NEW, [])