55 lines
1.4 KiB
Diff
55 lines
1.4 KiB
Diff
--- patch.py.orig 2018-11-09 11:48:08.507323235 -0800
|
|
+++ patch.py 2018-11-09 11:48:26.759761184 -0800
|
|
@@ -263,6 +263,7 @@
|
|
|
|
self.errors = 0 # fatal parsing errors
|
|
self.warnings = 0 # non-critical warnings
|
|
+ self.already_patched = False
|
|
# --- /API ---
|
|
|
|
if stream:
|
|
@@ -803,10 +804,10 @@
|
|
|
|
def findfile(self, old, new):
|
|
""" return name of file to be patched or None """
|
|
- if exists(old):
|
|
- return old
|
|
- elif exists(new):
|
|
+ if exists(new):
|
|
return new
|
|
+ elif exists(old):
|
|
+ return old
|
|
else:
|
|
# [w] Google Code generates broken patches with its online editor
|
|
debug("broken patch from Google Code, stripping prefixes..")
|
|
@@ -826,10 +827,6 @@
|
|
from file paths. `root` parameter specifies working dir.
|
|
return True on success
|
|
"""
|
|
- if root:
|
|
- prevdir = os.getcwd()
|
|
- os.chdir(root)
|
|
-
|
|
total = len(self.items)
|
|
errors = 0
|
|
if strip:
|
|
@@ -853,6 +850,8 @@
|
|
new = pathstrip(p.target, strip)
|
|
else:
|
|
old, new = p.source, p.target
|
|
+ old = os.path.join(root, old)
|
|
+ new = os.path.join(root, new)
|
|
|
|
filename = self.findfile(old, new)
|
|
|
|
@@ -954,9 +953,6 @@
|
|
# todo: proper rejects
|
|
shutil.move(backupname, filename)
|
|
|
|
- if root:
|
|
- os.chdir(prevdir)
|
|
-
|
|
# todo: check for premature eof
|
|
return (errors == 0)
|
|
|