Commit dffc73cb authored by maruel@chromium.org's avatar maruel@chromium.org

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
parent 072d94b6
...@@ -406,7 +406,9 @@ class FilePatchDiff(FilePatchBase): ...@@ -406,7 +406,9 @@ class FilePatchDiff(FilePatchBase):
# Only look at owner ACL for executable. # Only look at owner ACL for executable.
if bool(int(mode[4]) & 1): if bool(int(mode[4]) & 1):
self.svn_properties.append(('svn:executable', '*')) 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)) self.svn_properties.append(('svn:executable', None))
return return
......
...@@ -292,6 +292,16 @@ class GIT(object): ...@@ -292,6 +292,16 @@ class GIT(object):
'old mode 100644\n' 'old mode 100644\n'
'new mode 100755\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 = ( FOUR_HUNKS = (
'Index: presubmit_support.py\n' 'Index: presubmit_support.py\n'
'diff --git a/presubmit_support.py b/presubmit_support.py\n' 'diff --git a/presubmit_support.py b/presubmit_support.py\n'
......
...@@ -32,7 +32,6 @@ class PatchTest(unittest.TestCase): ...@@ -32,7 +32,6 @@ class PatchTest(unittest.TestCase):
patchlevel=0, patchlevel=0,
svn_properties=None, svn_properties=None,
nb_hunks=None): nb_hunks=None):
svn_properties = svn_properties or []
self.assertEquals(p.filename, filename) self.assertEquals(p.filename, filename)
self.assertEquals(p.source_filename, source_filename) self.assertEquals(p.source_filename, source_filename)
self.assertEquals(p.is_binary, is_binary) self.assertEquals(p.is_binary, is_binary)
...@@ -51,6 +50,8 @@ class PatchTest(unittest.TestCase): ...@@ -51,6 +50,8 @@ class PatchTest(unittest.TestCase):
self.assertEquals(len(p.hunks), nb_hunks) self.assertEquals(len(p.hunks), nb_hunks)
else: else:
self.assertEquals(None, nb_hunks) self.assertEquals(None, nb_hunks)
if hasattr(p, 'svn_properties'):
self.assertEquals(p.svn_properties, svn_properties or [])
def testFilePatchDelete(self): def testFilePatchDelete(self):
p = patch.FilePatchDelete('foo', False) p = patch.FilePatchDelete('foo', False)
...@@ -89,6 +90,14 @@ class PatchTest(unittest.TestCase): ...@@ -89,6 +90,14 @@ class PatchTest(unittest.TestCase):
p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1, p, 'git_cl/git-cl', GIT.MODE_EXE_JUNK, is_git_diff=True, patchlevel=1,
svn_properties=[('svn:executable', '*')], nb_hunks=0) 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): def testFilePatchDiffSvnNew(self):
# The code path is different for git and svn. # The code path is different for git and svn.
p = patch.FilePatchDiff('foo', RAW.NEW, []) p = patch.FilePatchDiff('foo', RAW.NEW, [])
......
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