forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-patch-no-chdir.patch
More file actions
46 lines (41 loc) · 1.18 KB
/
fix-patch-no-chdir.patch
File metadata and controls
46 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- patch.py.original 2018-11-02 23:17:51.816936730 -0700
+++ patch.py 2018-11-02 23:21:50.794673596 -0700
@@ -803,10 +803,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 +826,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 +849,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 +952,6 @@
# todo: proper rejects
shutil.move(backupname, filename)
- if root:
- os.chdir(prevdir)
-
# todo: check for premature eof
return (errors == 0)