##// END OF EJS Templates
patch: extract and rename gitpatch into patchmeta, document
Patrick Mezard -
r7148:7d84e5b0 default
parent child Browse files
Show More
@@ -143,17 +143,24 b' GP_PATCH = 1 << 0 # we have to run pat'
143 143 GP_FILTER = 1 << 1 # there's some copy/rename operation
144 144 GP_BINARY = 1 << 2 # there's a binary patch
145 145
146 class patchmeta:
147 """Patched file metadata
148
149 'op' is the performed operation within ADD, DELETE, RENAME, MODIFY
150 or COPY. 'path' is patched file path. 'oldpath' is set to the
151 origin file when 'op' is either COPY or RENAME, None
152 otherwise. 'mode' is set to the new mode of patched file or None.
153 """
154 def __init__(self, path):
155 self.path = path
156 self.oldpath = None
157 self.mode = None
158 self.op = 'MODIFY'
159 self.lineno = 0
160 self.binary = False
161
146 162 def readgitpatch(fp, firstline=None):
147 163 """extract git-style metadata about patches from <patchname>"""
148 class gitpatch:
149 "op is one of ADD, DELETE, RENAME, MODIFY or COPY"
150 def __init__(self, path):
151 self.path = path
152 self.oldpath = None
153 self.mode = None
154 self.op = 'MODIFY'
155 self.lineno = 0
156 self.binary = False
157 164
158 165 def reader(fp, firstline):
159 166 if firstline is not None:
@@ -177,7 +184,7 b' def readgitpatch(fp, firstline=None):'
177 184 if gp:
178 185 gitpatches.append(gp)
179 186 src, dst = m.group(1, 2)
180 gp = gitpatch(dst)
187 gp = patchmeta(dst)
181 188 gp.lineno = lineno
182 189 elif gp:
183 190 if line.startswith('--- '):
General Comments 0
You need to be logged in to leave comments. Login now