Commit 4005225a authored by maruel@chromium.org's avatar maruel@chromium.org

Fix deleted empty files.

Add relevant new tests.

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@109692 0039d316-1c4b-4281-b951-d872f2087c98
parent 0927b7ee
...@@ -289,7 +289,13 @@ class FilePatchDiff(FilePatchBase): ...@@ -289,7 +289,13 @@ class FilePatchDiff(FilePatchBase):
(match.group(1), line)) (match.group(1), line))
return return
# Ignore "deleted file mode 100644" since it's not needed. match = re.match(r'^deleted file mode (\d{6})$', line)
if match:
# It is necessary to parse it because there may be no hunk, like when the
# file was empty.
self.is_delete = True
return
match = re.match(r'^new(| file) mode (\d{6})$', line) match = re.match(r'^new(| file) mode (\d{6})$', line)
if match: if match:
mode = match.group(2) mode = match.group(2)
...@@ -297,6 +303,7 @@ class FilePatchDiff(FilePatchBase): ...@@ -297,6 +303,7 @@ class FilePatchDiff(FilePatchBase):
# TODO(maruel): Add support to remove a property. # TODO(maruel): Add support to remove a property.
if bool(int(mode[4]) & 1): if bool(int(mode[4]) & 1):
self.svn_properties.append(('svn:executable', '*')) self.svn_properties.append(('svn:executable', '*'))
return
match = re.match(r'^--- (.*)$', line) match = re.match(r'^--- (.*)$', line)
if match: if match:
......
...@@ -98,6 +98,14 @@ class GIT(object): ...@@ -98,6 +98,14 @@ class GIT(object):
'-Also see\n' '-Also see\n'
'\n') '\n')
# http://codereview.chromium.org/download/issue8508015_6001_7001.diff
DELETE_EMPTY = (
'Index: tests/__init__.py\n'
'diff --git a/tests/__init__.py b/tests/__init__.py\n'
'deleted file mode 100644\n'
'index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..'
'0000000000000000000000000000000000000000\n')
# http://codereview.chromium.org/download/issue6250123_3013_6010.diff # http://codereview.chromium.org/download/issue6250123_3013_6010.diff
RENAME_PARTIAL = ( RENAME_PARTIAL = (
'Index: chromeos/views/webui_menu_widget.h\n' 'Index: chromeos/views/webui_menu_widget.h\n'
......
...@@ -188,7 +188,23 @@ class RietveldTest(unittest.TestCase): ...@@ -188,7 +188,23 @@ class RietveldTest(unittest.TestCase):
] ]
patches = self.rietveld.get_patch(123, 456) patches = self.rietveld.get_patch(123, 456)
self.assertEquals(1, len(patches.patches)) self.assertEquals(1, len(patches.patches))
self._check_patch(patches.patches[0], name, None, is_delete=True) self._check_patch(patches.patches[0], name, RAW.DELETE, is_delete=True)
def test_delete_empty(self):
name = 'tests/__init__.py'
self.requests = [
('/api/123/456', _api({name: _file('D')})),
('/download/issue123_456_789.diff', GIT.DELETE_EMPTY),
]
patches = self.rietveld.get_patch(123, 456)
self.assertEquals(1, len(patches.patches))
self._check_patch(
patches.patches[0],
name,
GIT.DELETE_EMPTY,
is_delete=True,
is_git_diff=True,
patchlevel=1)
def test_m_plus(self): def test_m_plus(self):
properties = '\nAdded: svn:eol-style\n + LF\n' properties = '\nAdded: svn:eol-style\n + LF\n'
...@@ -348,5 +364,6 @@ class RietveldTest(unittest.TestCase): ...@@ -348,5 +364,6 @@ class RietveldTest(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig(level=logging.ERROR) logging.basicConfig(level=[
logging.ERROR, logging.INFO, logging.DEBUG][min(2, sys.argv.count('-v'))])
unittest.main() unittest.main()
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