Skip to contentSkip to conversation

using devtool for rebasing patches

DISCUSSION Alexander Kanavin 5 participants 11 messages Nov 3, 2016 – Nov 4, 2016

lore
Share & tools
lore
#0 lore raw

Hello Paul,

it would be very useful if devtool offered support for rebasing source patches when they fail to apply, but currently there does not seem to be any such feature:

ak@kanavin-desktop:~/development/poky/build$ devtool modify libksba
Parsing recipes..done.
NOTE: Fetching libksba...
NOTE: Unpacking...
NOTE: Patching...
ERROR: Applying 'ksba-add-pkgconfig-support.patch' failed:
checking file Makefile.am
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED
checking file configure.ac
Hunk #1 succeeded at 414 (offset 14 lines).
checking file ksba.pc.in
checking file src/ksba.m4
ERROR: Function failed: patch_do_patch
ak@kanavin-desktop:~/development/poky/build$

What devtool could do here is apply the patches that can be applied and then partially apply the patches that fail. Then give the developer some kind of UI for dealing with the rejected hunks (which typically means finding the place in the target file where the changes should go and then manually editing them in, while looking at the original patch).

Without this feature devtool is half as useful as it could be particularly for recipe version updates.

Thanks,
Alex

#1 lore raw
Quoted 20 lines · Alexander Kanavin

it would be very useful if devtool offered support for rebasing source patches when they fail to apply, but currently there does not seem to be any such feature:

ak@kanavin-desktop:~/development/poky/build$ devtool modify libksba
Parsing recipes..done.
NOTE: Fetching libksba...
NOTE: Unpacking...
NOTE: Patching...
ERROR: Applying 'ksba-add-pkgconfig-support.patch' failed:
checking file Makefile.am
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED
checking file configure.ac
Hunk #1 succeeded at 414 (offset 14 lines).
checking file ksba.pc.in
checking file src/ksba.m4
ERROR: Function failed: patch_do_patch
ak@kanavin-desktop:~/development/poky/build$
Quoted 9 lines

What devtool could do here is apply the patches that can be applied and then partially apply the patches that fail. Then give the developer some kind of UI for dealing with the rejected hunks (which typically means finding the place in the target file where the changes should go and then manually editing them in, while looking at the original patch).

Without this feature devtool is half as useful as it could be particularly for recipe version updates.

That would be useful, indeed.

git already provides such a UI, afaik devtool just needs to use git-am to apply the patches, ideally passing -3 to it, and let the user use git am to resolve and continue applying patches.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#2 lore raw
Quoted 3 lines · Christopher Larson

git already provides such a UI, afaik devtool just needs to use git-am to apply the patches, ideally passing -3 to it, and let the user use git am to resolve and continue applying patches.

I don't think git am has any UI that helps with rebasing the rejects, and -3 is often not useful here, as we don't have the commit history, if the source is coming from tarball.

What you need to do here is to use git am --reject, which would partially apply the patch, then find all the *.rej files and let the user manually edit them in, then complete the patch application with git am --continue.

Alex

#3 lore raw
Quoted 11 lines · Alexander Kanavin
Quoted 4 lines · Christopher Larson

git already provides such a UI, afaik devtool just needs to use git-am to apply the patches, ideally passing -3 to it, and let the user use git am to resolve and continue applying patches.

I don't think git am has any UI that helps with rebasing the rejects, and -3 is often not useful here, as we don't have the commit history, if the source is coming from tarball.

Fairly sure that’s not actually correct. See below.

Quoted 3 lines

What you need to do here is to use git am --reject, which would partially apply the patch, then find all the *.rej files and let the user manually edit them in, then complete the patch application with git am --continue.

With -3, it’ll merge it into the file with conflict markers, which is a lot more pleasant to deal with than .rej files, even without the merge-base being available.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#4 lore raw
Quoted 10 lines · Christopher Larson

On Thu, Nov 3, 2016 at 9:35 AM, Alexander Kanavin
<[email protected]> wrote:

What you need to do here is to use git am --reject, which would partially apply the patch, then find all the *.rej files and let the user manually edit them in, then complete the patch application with git am --continue.

Quoted 3 lines

With -3, it’ll merge it into the file with conflict markers, which is a lot more pleasant to deal with than .rej files, even without the merge-base being available.

That's also what I would prefer.

To deal with recipes that have something other than git as source one could create a local git repo with a branch that contains two commits (old version and new version), apply the patches on a second branch on top of the old version, then do the normal rebase with conflictstyle = diff3. At least I find that configstyle useful and have it in my ~/.gitconfig.

Signature · 6 lines
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
#5 lore raw
Quoted 13 lines · On Thu, 03 Nov 2016 20:14:04 Patrick Ohly wrote:
Quoted 11 lines · Christopher Larson

On Thu, Nov 3, 2016 at 9:35 AM, Alexander Kanavin

<[email protected]> wrote:
What you need to do here is to use git am --reject, which would partially apply the patch, then find all the *.rej files and let the user manually edit them in, then complete the patch application with git am --continue.

With -3, it’ll merge it into the file with conflict markers, which is a lot more pleasant to deal with than .rej files, even without the merge-base being available.

Quoted 8 lines

That's also what I would prefer.

To deal with recipes that have something other than git as source one could create a local git repo with a branch that contains two commits (old version and new version), apply the patches on a second branch on top of the old version, then do the normal rebase with conflictstyle = diff3. At least I find that configstyle useful and have it in my ~/.gitconfig.

FYI this is what "devtool upgrade" already does. It's just that it's geared towards upgrading so it expects the version to be changing at the same time.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#6 lore raw
In reply to Christopher Larson
Quoted 23 lines · Christopher Larson

On Thu, Nov 3, 2016 at 9:01 AM, Alexander Kanavin <[email protected] <mailto:[email protected]>> wrote:
it would be very useful if devtool offered support for rebasing source patches when they fail to apply, but currently there does not seem to be any such feature:

ak@kanavin-desktop:~/development/poky/build$ devtool modify libksba
Parsing recipes..done.
NOTE: Fetching libksba...
NOTE: Unpacking...
NOTE: Patching...
ERROR: Applying 'ksba-add-pkgconfig-support.pa <http://ksba-add-pkgconfig-support.pa/>tch' failed:
checking file Makefile.am
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED
checking file configure.ac <http://configure.ac/>
Hunk #1 succeeded at 414 (offset 14 lines).
checking file ksba.pc.in <http://ksba.pc.in/>
checking file src/ksba.m4
ERROR: Function failed: patch_do_patch
ak@kanavin-desktop:~/development/poky/build$
Quoted 7 lines

What devtool could do here is apply the patches that can be applied and then partially apply the patches that fail. Then give the developer some kind of UI for dealing with the rejected hunks (which typically means finding the place in the target file where the changes should go and then manually editing them in, while looking at the original patch).

Without this feature devtool is half as useful as it could be particularly for recipe version updates.

That would be useful, indeed.

git already provides such a UI, afaik devtool just needs to use git-am to apply the patches, ideally passing -3 to it, and let the user use git am to resolve and continue applying patches.

this seems good. Although, I have seen that all patches are not git am applicable, then I use git apply, something even that does not work, then third option is to use patch < patch and this works if it does not work then patch needs manual work.

Quoted 11 lines

--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#7 lore raw
In reply to Alexander Kanavin
Quoted 4 lines · Alexander Kanavin

Hello Paul,

it would be very useful if devtool offered support for rebasing source patches when they fail to apply

+1 for that.

I tried it the other way around: first "devtool modify", then rebasing using git (which only works when the recipe fetches from a git repo), and finally changing the recipe such that it refers to the version I rebased onto. But that version change in the recipe confused "devtool update-recipe" considerably (as in "added all patches between the version", if I remember correctly).

Signature · 6 lines
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
#8 lore raw
In reply to Alexander Kanavin

Hi Alex,

Quoted 20 lines · On Thu, 03 Nov 2016 18:01:27 Alexander Kanavin wrote:

it would be very useful if devtool offered support for rebasing source patches when they fail to apply, but currently there does not seem to be any such feature:

ak@kanavin-desktop:~/development/poky/build$ devtool modify libksba
Parsing recipes..done.
NOTE: Fetching libksba...
NOTE: Unpacking...
NOTE: Patching...
ERROR: Applying 'ksba-add-pkgconfig-support.patch' failed:
checking file Makefile.am
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED
checking file configure.ac
Hunk #1 succeeded at 414 (offset 14 lines).
checking file ksba.pc.in
checking file src/ksba.m4
ERROR: Function failed: patch_do_patch
ak@kanavin-desktop:~/development/poky/build$
Quoted 8 lines

What devtool could do here is apply the patches that can be applied and then partially apply the patches that fail. Then give the developer some kind of UI for dealing with the rejected hunks (which typically means finding the place in the target file where the changes should go and then manually editing them in, while looking at the original patch).

Without this feature devtool is half as useful as it could be particularly for recipe version updates.

"devtool upgrade" is designed specifically to handle the upgrade case and tries to rebase the old patches onto the new version, putting you into resolution mode with "git am" if it fails to apply a patch. I appreciate that you may now be working through sorting out all of the patches to reduce the fuzziness when applying, and that won't help in that scenario, but it would definitely be worth considering for upgrades.

I'm open to implementing better support for handling patch application failure for devtool modify - in fact there is a bug open for just that:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=8325

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#9 lore raw
Quoted 39 lines · On Fri, 04 Nov 2016 08:29:26 Paul Eggleton wrote:

Hi Alex,

Quoted 20 lines · On Thu, 03 Nov 2016 18:01:27 Alexander Kanavin wrote:

it would be very useful if devtool offered support for rebasing source patches when they fail to apply, but currently there does not seem to be any such feature:

ak@kanavin-desktop:~/development/poky/build$ devtool modify libksba
Parsing recipes..done.
NOTE: Fetching libksba...
NOTE: Unpacking...
NOTE: Patching...
ERROR: Applying 'ksba-add-pkgconfig-support.patch' failed:
checking file Makefile.am
Hunk #1 FAILED at 21.
1 out of 1 hunk FAILED
checking file configure.ac
Hunk #1 succeeded at 414 (offset 14 lines).
checking file ksba.pc.in
checking file src/ksba.m4
ERROR: Function failed: patch_do_patch
ak@kanavin-desktop:~/development/poky/build$
Quoted 8 lines

What devtool could do here is apply the patches that can be applied and then partially apply the patches that fail. Then give the developer some kind of UI for dealing with the rejected hunks (which typically means finding the place in the target file where the changes should go and then manually editing them in, while looking at the original patch).

Without this feature devtool is half as useful as it could be particularly for recipe version updates.

"devtool upgrade" is designed specifically to handle the upgrade case and tries to rebase the old patches onto the new version, putting you into resolution mode with "git am" if it fails to apply a patch. I appreciate that you may now be working through sorting out all of the patches to reduce the fuzziness when applying, and that won't help in that scenario, but it would definitely be worth considering for upgrades.

Quoted 4 lines

I'm open to implementing better support for handling patch application failure for devtool modify - in fact there is a bug open for just that:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=8325

(Although admittedly that was mostly for an earlier issue - we ought to add a bit of description of where to go from here.)

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#10 lore raw
In reply to Paul Eggleton
Quoted 6 lines · Paul Eggleton

"devtool upgrade" is designed specifically to handle the upgrade case and tries to rebase the old patches onto the new version, putting you into resolution mode with "git am" if it fails to apply a patch. I appreciate that you may now be working through sorting out all of the patches to reduce the fuzziness when applying, and that won't help in that scenario, but it would definitely be worth considering for upgrades.

Fair enough, although I was not aware of this feature of devtool until now, despite being a major contributor of package upgrades to oe-core :) We have had a miscommunication issue, it seems.

Quoted 4 lines

I'm open to implementing better support for handling patch application failure for devtool modify - in fact there is a bug open for just that:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=8325

THanks, I just wrote a comment there, and made the patch fuzz bug depend on this one :)

Alex