Patchfolder cleanup helper


Recommended Posts

Ever since patchfolders were created for different branches and different board families it has become more and more a nightmare to maintain these folders and keep them clean.

 

Instead of taking the approach to clear one or more of these folders by myself, last but not least due to lack of necessary skills, I was thinking maybe I can provide some tools that make such tasks a little easier for somebody else.

Last but not least was (and still is) this a perfect opportunity to pratice with my quite new Python skills.

 

https://github.com/EvilOlaf/refactorpatches

 

What this script basically does is break down all patches in a certain folder and check which files are targeted by each individual diff (if you choose to split them up) and sort the output by the target file.

This way it should be an easy thing to merge patches that affect the same file and therefore it is no longer necessary to take care about the order to apply them.

 

Requirements from apt: patchutils, python3

Requirements from Pypi: none but just make sure the prettytable.py is in the same folder as main refactor.py.

 

I have tested this with random patch folders for kernel patches and for what it is expected to do at the current state it seems to just work as it should.

There is still a ton of room for improvements.

 

Let me know what do you think or if it is useful at all. Even if it is not I had fun coding and using Python :lol:

 

grafik.thumb.png.f13be6099fb48e72926be4a32ca35f28.png

Link to post
Share on other sites
Donate and support the project!

Interesting approach.

 

I'd just like to mention that factorizing is required, if the patches apply to the same file AND the same blocks (functions, DTS, ...).

 

If you create THAT big patch that add 50 entries to a single DTS file, and the mainline DTS file gets updated with the addition of, like, 3 entries out of the 50, then you won't be able to apply your big patch AND you'll need to rework it.
Since you won't be able to apply it again, you can either pray that 3-way merging works, or you'll have to do a copy-paste of every missing entry from the patch, back to the DTS file AND regenerate a patch from there.

 

Now, if you got 5 patches affecting "that same function" or "that same DTS block", then yes, merging is required.

 

Anyway, this tool should greatly help in reducing the number of patches. Just don't do a blind factorization, it will back-fire very quickly.

Link to post
Share on other sites

Thanks for your comment.

 

In first place I was thinking about making this tool to merge patches automatically but now I think it is even better to have the patches broken down into files because when there are changes upstream it is easier to detect which one fails and you can faster deal with it. And due to the numbering of the files you know anyways which split-patch  belongs to another and even keeps the sequence of merging.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...