Show More
@@ -280,10 +280,6 b' def extract(ui, fileobj):' | |||||
280 | p2 = parents and parents.pop(0) or None |
|
280 | p2 = parents and parents.pop(0) or None | |
281 | return tmpname, message, user, date, branch, nodeid, p1, p2 |
|
281 | return tmpname, message, user, date, branch, nodeid, p1, p2 | |
282 |
|
282 | |||
283 | GP_PATCH = 1 << 0 # we have to run patch |
|
|||
284 | GP_FILTER = 1 << 1 # there's some copy/rename operation |
|
|||
285 | GP_BINARY = 1 << 2 # there's a binary patch |
|
|||
286 |
|
||||
287 | class patchmeta(object): |
|
283 | class patchmeta(object): | |
288 | """Patched file metadata |
|
284 | """Patched file metadata | |
289 |
|
285 | |||
@@ -316,9 +312,6 b' def readgitpatch(lr):' | |||||
316 | # Filter patch for git information |
|
312 | # Filter patch for git information | |
317 | gp = None |
|
313 | gp = None | |
318 | gitpatches = [] |
|
314 | gitpatches = [] | |
319 | # Can have a git patch with only metadata, causing patch to complain |
|
|||
320 | dopatch = 0 |
|
|||
321 |
|
||||
322 | lineno = 0 |
|
315 | lineno = 0 | |
323 | for line in lr: |
|
316 | for line in lr: | |
324 | lineno += 1 |
|
317 | lineno += 1 | |
@@ -333,11 +326,8 b' def readgitpatch(lr):' | |||||
333 | gp.lineno = lineno |
|
326 | gp.lineno = lineno | |
334 | elif gp: |
|
327 | elif gp: | |
335 | if line.startswith('--- '): |
|
328 | if line.startswith('--- '): | |
336 | if gp.op in ('COPY', 'RENAME'): |
|
|||
337 | dopatch |= GP_FILTER |
|
|||
338 | gitpatches.append(gp) |
|
329 | gitpatches.append(gp) | |
339 | gp = None |
|
330 | gp = None | |
340 | dopatch |= GP_PATCH |
|
|||
341 | continue |
|
331 | continue | |
342 | if line.startswith('rename from '): |
|
332 | if line.startswith('rename from '): | |
343 | gp.op = 'RENAME' |
|
333 | gp.op = 'RENAME' | |
@@ -357,15 +347,11 b' def readgitpatch(lr):' | |||||
357 | elif line.startswith('new mode '): |
|
347 | elif line.startswith('new mode '): | |
358 | gp.setmode(int(line[-6:], 8)) |
|
348 | gp.setmode(int(line[-6:], 8)) | |
359 | elif line.startswith('GIT binary patch'): |
|
349 | elif line.startswith('GIT binary patch'): | |
360 | dopatch |= GP_BINARY |
|
|||
361 | gp.binary = True |
|
350 | gp.binary = True | |
362 | if gp: |
|
351 | if gp: | |
363 | gitpatches.append(gp) |
|
352 | gitpatches.append(gp) | |
364 |
|
353 | |||
365 |
|
|
354 | return gitpatches | |
366 | dopatch = GP_PATCH |
|
|||
367 |
|
||||
368 | return (dopatch, gitpatches) |
|
|||
369 |
|
355 | |||
370 | class linereader(object): |
|
356 | class linereader(object): | |
371 | # simple class to allow pushing lines back into the input stream |
|
357 | # simple class to allow pushing lines back into the input stream | |
@@ -986,9 +972,9 b' def scangitpatch(lr, firstline):' | |||||
986 | fp = cStringIO.StringIO(lr.fp.read()) |
|
972 | fp = cStringIO.StringIO(lr.fp.read()) | |
987 | gitlr = linereader(fp, lr.textmode) |
|
973 | gitlr = linereader(fp, lr.textmode) | |
988 | gitlr.push(firstline) |
|
974 | gitlr.push(firstline) | |
989 |
|
|
975 | gitpatches = readgitpatch(gitlr) | |
990 | fp.seek(pos) |
|
976 | fp.seek(pos) | |
991 |
return |
|
977 | return gitpatches | |
992 |
|
978 | |||
993 | def iterhunks(ui, fp, sourcefile=None): |
|
979 | def iterhunks(ui, fp, sourcefile=None): | |
994 | """Read a patch and yield the following events: |
|
980 | """Read a patch and yield the following events: | |
@@ -1062,7 +1048,7 b' def iterhunks(ui, fp, sourcefile=None):' | |||||
1062 | afile, bfile = m.group(1, 2) |
|
1048 | afile, bfile = m.group(1, 2) | |
1063 | if not git: |
|
1049 | if not git: | |
1064 | git = True |
|
1050 | git = True | |
1065 |
gitpatches = scangitpatch(lr, x) |
|
1051 | gitpatches = scangitpatch(lr, x) | |
1066 | yield 'git', gitpatches |
|
1052 | yield 'git', gitpatches | |
1067 | for gp in gitpatches: |
|
1053 | for gp in gitpatches: | |
1068 | changed[gp.path] = gp |
|
1054 | changed[gp.path] = gp |
General Comments 0
You need to be logged in to leave comments.
Login now