Show More
@@ -71,10 +71,23 b' def filter(s, cmd):' | |||||
71 | return fn(s, cmd[len(name):].lstrip()) |
|
71 | return fn(s, cmd[len(name):].lstrip()) | |
72 | return pipefilter(s, cmd) |
|
72 | return pipefilter(s, cmd) | |
73 |
|
73 | |||
|
74 | def find_in_path(name, path, default=None): | |||
|
75 | '''find name in search path. path can be string (will be split | |||
|
76 | with os.pathsep), or iterable thing that returns strings. if name | |||
|
77 | found, return path to name. else return default.''' | |||
|
78 | if isinstance(path, str): | |||
|
79 | path = path.split(os.pathsep) | |||
|
80 | for p in path: | |||
|
81 | p_name = os.path.join(p, name) | |||
|
82 | if os.path.exists(p_name): | |||
|
83 | return p_name | |||
|
84 | return default | |||
|
85 | ||||
74 | def patch(strip, patchname, ui): |
|
86 | def patch(strip, patchname, ui): | |
75 | """apply the patch <patchname> to the working directory. |
|
87 | """apply the patch <patchname> to the working directory. | |
76 | a list of patched files is returned""" |
|
88 | a list of patched files is returned""" | |
77 | fp = os.popen('patch -p%d < "%s"' % (strip, patchname)) |
|
89 | patcher = find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') | |
|
90 | fp = os.popen('"%s" -p%d < "%s"' % (patcher, strip, patchname)) | |||
78 | files = {} |
|
91 | files = {} | |
79 | for line in fp: |
|
92 | for line in fp: | |
80 | line = line.rstrip() |
|
93 | line = line.rstrip() |
General Comments 0
You need to be logged in to leave comments.
Login now