# Copyright (c) 2011 The Chromium OS Authors.
#
-# See file CREDITS for list of people who contributed to this
-# project.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
+# SPDX-License-Identifier: GPL-2.0+
#
import command
import sys
import terminal
+import checkpatch
import settings
Args:
fname: filename of patch file to apply
"""
+ col = terminal.Color()
cmd = ['git', 'am', fname]
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
print line
match = re_error.match(line)
if match:
- print GetWarningMsg('warning', match.group(1), int(match.group(2)),
- 'Patch failed')
+ print checkpatch.GetWarningMsg(col, 'warning', match.group(1),
+ int(match.group(2)), 'Patch failed')
return pipe.returncode == 0, stdout
def ApplyPatches(verbose, args, start_point):
print stdout
return False
old_head = stdout.splitlines()[0]
+ if old_head == 'undefined':
+ str = "Invalid HEAD '%s'" % stdout.strip()
+ print col.Color(col.RED, str)
+ return False
# Checkout the required start point
cmd = ['git', 'checkout', 'HEAD~%d' % start_point]