diff options
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r-- | meta/lib/oe/patch.py | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 9b480b2b28..e4bb5a7839 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
@@ -461,41 +461,43 @@ class GitApplyTree(PatchTree): | |||
461 | return (tmpfile, cmd) | 461 | return (tmpfile, cmd) |
462 | 462 | ||
463 | @staticmethod | 463 | @staticmethod |
464 | def extractPatches(tree, startcommit, outdir, paths=None): | 464 | def extractPatches(tree, startcommits, outdir, paths=None): |
465 | import tempfile | 465 | import tempfile |
466 | import shutil | 466 | import shutil |
467 | tempdir = tempfile.mkdtemp(prefix='oepatch') | 467 | tempdir = tempfile.mkdtemp(prefix='oepatch') |
468 | try: | 468 | try: |
469 | shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", startcommit, "-o", tempdir] | 469 | for name, rev in startcommits.items(): |
470 | if paths: | 470 | shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", rev, "-o", tempdir] |
471 | shellcmd.append('--') | 471 | if paths: |
472 | shellcmd.extend(paths) | 472 | shellcmd.append('--') |
473 | out = runcmd(["sh", "-c", " ".join(shellcmd)], tree) | 473 | shellcmd.extend(paths) |
474 | if out: | 474 | out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name)) |
475 | for srcfile in out.split(): | 475 | if out: |
476 | for encoding in ['utf-8', 'latin-1']: | 476 | for srcfile in out.split(): |
477 | patchlines = [] | 477 | for encoding in ['utf-8', 'latin-1']: |
478 | outfile = None | 478 | patchlines = [] |
479 | try: | 479 | outfile = None |
480 | with open(srcfile, 'r', encoding=encoding) as f: | 480 | try: |
481 | for line in f: | 481 | with open(srcfile, 'r', encoding=encoding) as f: |
482 | if line.startswith(GitApplyTree.patch_line_prefix): | 482 | for line in f: |
483 | outfile = line.split()[-1].strip() | 483 | if line.startswith(GitApplyTree.patch_line_prefix): |
484 | continue | 484 | outfile = line.split()[-1].strip() |
485 | if line.startswith(GitApplyTree.ignore_commit_prefix): | 485 | continue |
486 | continue | 486 | if line.startswith(GitApplyTree.ignore_commit_prefix): |
487 | patchlines.append(line) | 487 | continue |
488 | except UnicodeDecodeError: | 488 | patchlines.append(line) |
489 | continue | 489 | except UnicodeDecodeError: |
490 | break | 490 | continue |
491 | else: | 491 | break |
492 | raise PatchError('Unable to find a character encoding to decode %s' % srcfile) | 492 | else: |
493 | 493 | raise PatchError('Unable to find a character encoding to decode %s' % srcfile) | |
494 | if not outfile: | 494 | |
495 | outfile = os.path.basename(srcfile) | 495 | if not outfile: |
496 | with open(os.path.join(outdir, outfile), 'w') as of: | 496 | outfile = os.path.basename(srcfile) |
497 | for line in patchlines: | 497 | bb.utils.mkdirhier(os.path.join(outdir, name)) |
498 | of.write(line) | 498 | with open(os.path.join(outdir, name, outfile), 'w') as of: |
499 | for line in patchlines: | ||
500 | of.write(line) | ||
499 | finally: | 501 | finally: |
500 | shutil.rmtree(tempdir) | 502 | shutil.rmtree(tempdir) |
501 | 503 | ||