Patchwork [Proof,of,concept] patch.bbclass: add incredibly naive 'git am' mode

login
register
mail settings
Submitter Koen Kooi
Date Nov. 30, 2011, 3:43 p.m.
Message ID <1322667784-23451-1-git-send-email-koen@dominion.thruhere.net>
Download mbox | patch
Permalink /patch/15863/
State New
Headers show

Comments

Mario Domenech Goulart - Nov. 30, 2011, 3:40 p.m.
Hi,

On Wed, 30 Nov 2011 16:43:04 +0100 Koen Kooi <koen@dominion.thruhere.net> wrote:

> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
> ---
>  meta/classes/patch.bbclass |    1 +
>  meta/lib/oe/patch.py       |   14 ++++++++++++++
>  2 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
> index ac6c1ce..9f99e38 100644
> --- a/meta/classes/patch.bbclass
> +++ b/meta/classes/patch.bbclass
> @@ -18,6 +18,7 @@ python patch_do_patch() {
>  		"patch": oe.patch.PatchTree,
>  		"quilt": oe.patch.QuiltTree,
>  		"git": oe.patch.GitApplyTree,
> +		"gitam": oe.patch.GitAmTree,
>  	}
>  
>  	cls = patchsetmap[d.getVar('PATCHTOOL', 1) or 'quilt']
> diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
> index f4ccb3e..06965ba 100644
> --- a/meta/lib/oe/patch.py
> +++ b/meta/lib/oe/patch.py
> @@ -176,6 +176,20 @@ class GitApplyTree(PatchTree):
>  
>          return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
>  
> +class GitAmTree(PatchTree):
> +    def __init__(self, dir, d):
> +        PatchTree.__init__(self, dir, d)
> +
> +    def _applypatch(self, patch, force = False, reverse = False, run = True):
> +        shellcmd = ["git", "am"]
> +
> +        shellcmd.append(patch['file'])
> +
> +        if not run:
> +            return "sh" + "-c" + " ".join(shellcmd)

That'd result in

    'sh-cgit am'

Maybe you mean something like

    " ".join(["sh", "-c"] + shellcmd)

?

> +
> +        return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
> +
>  
>  class QuiltTree(PatchSet):
>      def _runcmd(self, args, run = True):

Best wishes.
Mario
Koen Kooi - Nov. 30, 2011, 3:43 p.m.
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
---
 meta/classes/patch.bbclass |    1 +
 meta/lib/oe/patch.py       |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

Patch

diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index ac6c1ce..9f99e38 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -18,6 +18,7 @@  python patch_do_patch() {
 		"patch": oe.patch.PatchTree,
 		"quilt": oe.patch.QuiltTree,
 		"git": oe.patch.GitApplyTree,
+		"gitam": oe.patch.GitAmTree,
 	}
 
 	cls = patchsetmap[d.getVar('PATCHTOOL', 1) or 'quilt']
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index f4ccb3e..06965ba 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -176,6 +176,20 @@  class GitApplyTree(PatchTree):
 
         return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
 
+class GitAmTree(PatchTree):
+    def __init__(self, dir, d):
+        PatchTree.__init__(self, dir, d)
+
+    def _applypatch(self, patch, force = False, reverse = False, run = True):
+        shellcmd = ["git", "am"]
+
+        shellcmd.append(patch['file'])
+
+        if not run:
+            return "sh" + "-c" + " ".join(shellcmd)
+
+        return runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+
 
 class QuiltTree(PatchSet):
     def _runcmd(self, args, run = True):