##// END OF EJS Templates
patch: make internal code a bit friendlier to use
Bryan O'Sullivan -
r5035:a675f6d5 default
parent child Browse files
Show More
@@ -142,7 +142,7 b' GP_PATCH = 1 << 0 # we have to run pat'
142 GP_FILTER = 1 << 1 # there's some copy/rename operation
142 GP_FILTER = 1 << 1 # there's some copy/rename operation
143 GP_BINARY = 1 << 2 # there's a binary patch
143 GP_BINARY = 1 << 2 # there's a binary patch
144
144
145 def readgitpatch(fp, firstline):
145 def readgitpatch(fp, firstline=None):
146 """extract git-style metadata about patches from <patchname>"""
146 """extract git-style metadata about patches from <patchname>"""
147 class gitpatch:
147 class gitpatch:
148 "op is one of ADD, DELETE, RENAME, MODIFY or COPY"
148 "op is one of ADD, DELETE, RENAME, MODIFY or COPY"
@@ -156,7 +156,8 b' def readgitpatch(fp, firstline):'
156 self.binary = False
156 self.binary = False
157
157
158 def reader(fp, firstline):
158 def reader(fp, firstline):
159 yield firstline
159 if firstline is not None:
160 yield firstline
160 for line in fp:
161 for line in fp:
161 yield line
162 yield line
162
163
@@ -278,10 +279,13 b' def externalpatch(patcher, args, patchna'
278 util.explain_exit(code)[0])
279 util.explain_exit(code)[0])
279 return fuzz
280 return fuzz
280
281
281 def internalpatch(patchname, ui, strip, cwd, files):
282 def internalpatch(patchobj, ui, strip, cwd, files={}):
282 """use builtin patch to apply <patchname> to the working directory.
283 """use builtin patch to apply <patchobj> to the working directory.
283 returns whether patch was applied with fuzz factor."""
284 returns whether patch was applied with fuzz factor."""
284 fp = file(patchname, 'rb')
285 try:
286 fp = file(patchobj, 'rb')
287 except TypeError:
288 fp = patchobj
285 if cwd:
289 if cwd:
286 curdir = os.getcwd()
290 curdir = os.getcwd()
287 os.chdir(cwd)
291 os.chdir(cwd)
General Comments 0
You need to be logged in to leave comments. Login now