mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support to patch_util.py for patches containing new files.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@971 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -9,6 +9,9 @@
|
|||||||
CEF Changes
|
CEF Changes
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
2013/01/03
|
||||||
|
- Add support for patches containing new files
|
||||||
|
|
||||||
2009/07/22
|
2009/07/22
|
||||||
- Add a 'root_directory' argument to PatchInfo::apply
|
- Add a 'root_directory' argument to PatchInfo::apply
|
||||||
- Fix a Python 2.4 compile error in PatchInfo::parse_stream
|
- Fix a Python 2.4 compile error in PatchInfo::parse_stream
|
||||||
@ -312,6 +315,17 @@ class PatchInfo(object):
|
|||||||
if not root_directory is None:
|
if not root_directory is None:
|
||||||
f2patch = root_directory + f2patch
|
f2patch = root_directory + f2patch
|
||||||
if not exists(f2patch):
|
if not exists(f2patch):
|
||||||
|
# if the patch contains a single hunk at position 0 consider it a new file
|
||||||
|
if len(self.hunks[fileno]) == 1 and self.hunks[fileno][0].startsrc == 0:
|
||||||
|
hunklines = [x[1:].rstrip("\r\n") for x in self.hunks[fileno][0].text if x[0] in " +"]
|
||||||
|
if len(hunklines) > 0:
|
||||||
|
warning("creating file %s" % (f2patch))
|
||||||
|
f = open(f2patch, "wb")
|
||||||
|
for line in hunklines:
|
||||||
|
f.write(line + "\n")
|
||||||
|
f.close()
|
||||||
|
continue
|
||||||
|
|
||||||
f2patch = self.target[fileno]
|
f2patch = self.target[fileno]
|
||||||
if not exists(f2patch):
|
if not exists(f2patch):
|
||||||
warning("source/target file does not exist\n--- %s\n+++ %s" % (filename, f2patch))
|
warning("source/target file does not exist\n--- %s\n+++ %s" % (filename, f2patch))
|
||||||
@ -369,7 +383,8 @@ class PatchInfo(object):
|
|||||||
canpatch = True
|
canpatch = True
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if hunkno < len(self.hunks[fileno]):
|
if hunkno < len(self.hunks[fileno]) and \
|
||||||
|
(len(self.hunks[fileno]) != 1 or self.hunks[fileno][0].startsrc != 0):
|
||||||
warning("premature end of source file %s at hunk %d" % (filename, hunkno+1))
|
warning("premature end of source file %s at hunk %d" % (filename, hunkno+1))
|
||||||
|
|
||||||
f2fp.close()
|
f2fp.close()
|
||||||
@ -407,6 +422,24 @@ def check_patched(filename, hunks):
|
|||||||
class NoMatch(Exception):
|
class NoMatch(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# special case for new files
|
||||||
|
try:
|
||||||
|
if len(hunks) == 1 and hunks[0].startsrc == 0:
|
||||||
|
hunklines = [x[1:].rstrip("\r\n") for x in hunks[0].text if x[0] in " +"]
|
||||||
|
if len(hunklines) > 0:
|
||||||
|
for line in hunklines:
|
||||||
|
srcline = fp.readline()
|
||||||
|
if not len(srcline) or srcline.rstrip("\r\n") != line:
|
||||||
|
raise NoMatch
|
||||||
|
srcline = fp.readline()
|
||||||
|
if len(srcline):
|
||||||
|
raise NoMatch
|
||||||
|
fp.close()
|
||||||
|
return True
|
||||||
|
except NoMatch:
|
||||||
|
fp.close()
|
||||||
|
fp = open(filename)
|
||||||
|
|
||||||
lineno = 1
|
lineno = 1
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
hno = None
|
hno = None
|
||||||
|
Reference in New Issue
Block a user