Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Uses own post-update hook instead of the one offerred by drush_invoke().
Perhaps we can break it up a bit and use rollback feature? I guess thats only interesting if this becomes multiple commands.
Comment | File | Size | Author |
---|---|---|---|
#8 | 433950.patch | 40.84 KB | Owen Barton |
Comments
Comment #1
adrian CreditAttribution: adrian commentedI saw that myself.
it's a biiit different because it is calling hooks in it's handlers, but it could definitely benefit from having rollback support
Comment #2
Owen Barton CreditAttribution: Owen Barton commentedYeah - I don't think we need the generic hook (pm_post_update) here any more - we do need to keep the version control engine function in though - that really needs to be applied after each update, not after the whole batch.
One big thing I want to do here, that should clean it up a lot is to move all the backup stuff to be a version_control engine (albeit a kinda clunky one).
There are various other things we could do - I want to push all the "big" operation functions into their own files, as I did with updatecode (and also move some of the updatecode only functions into the right file).
Comment #3
Owen Barton CreditAttribution: Owen Barton commentedOh - yes, the rollback stuff would be very cool too and should be interesting to write (what with the different version control engines in play). This is dependent on moving the backup stuff into an engine first, I think.
Comment #4
Owen Barton CreditAttribution: Owen Barton commentedMade a start on this, but not enough to review yet.
I am adding a ['signature'] element to the engine array for hook_engine_version_control, so we could do a directory existence check to detect if that version control is active in a particular place - so for svn we have 'signature' => '.svn'. The idea is that you could provide a comma separated list of engines - e.g. --version-control=svn,backup (which would be the default) and it would use the first one that "matches". We can't include the tests in the engines themselves, since you can only load one engine at a time.
Questions:
- Is this a useful approach - anyone have any better ideas?
- Are directory checks sufficient, or should we be doing something more precise (like an exec "svn info !dir" for example) - or should we sommort both types of signatures?
- Is this worth abstracting out (into drush_include_engine() for instance) - it seems like there might be other uses for this kind of "smart fallback" behavior - the package handlers would seem to be another case.
Comment #5
Owen Barton CreditAttribution: Owen Barton commentedI'll try and remember which computer I left this (proto) patch on...
Comment #6
ChrisRut CreditAttribution: ChrisRut commentedSubscribe
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedMarking as critical for 3.0. The approach in #4 sounds good to me.
Comment #8
Owen Barton CreditAttribution: Owen Barton commentedOK, here is a patch. I have tested it pretty thoroughly with the various combinations of update handler and version control, as well as the various error conditions. It could use some testing across different platforms (e.g. OS X and Fedora). The exception is for bzr, which I just did a theoretical update on - if a bzr user could sanity check this that would be great.
I had to hold back from going crazy and rewriting everything, but hopefully this is a good first step, and I think puts us in a good place to be able to record "unhacked versions", check for patches, and support themes etc. There are still a few TODOs (such as making the package managers use a single array param as version control now does).
The only major architectural change is that version control engines are now namespaced (via a simple class interface) so we can load more than one at a time without function naming conflicts. This avoids a potential edge (or not so edge) case we have now where you have some modules (e.g. in sites/all) versioned and some (e.g. sites/default) unversioned, or versioned with a separate system. If folks like the idea I think it is worth considering moving the factory function up into drush.inc so as the standard way you use engines (we would need to coordinate this change with provision, of course).
Comment #9
Owen Barton CreditAttribution: Owen Barton commentedHere is a test script I used for svn sites:
and "backup" sites:
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedCode looks great. I do think the class interface should move up to drush.inc. No rush though.
typo: concevably
typo: As simple factory
I tested with the backup version control engine on OSX and it worked swell. My one suggestion is to use one REQUEST_TIME for all the backups in a given request. This groups them all in one dir. Mine got spread out across 2 dirs that differred by a second.
IMO, this is RTBC. I'll leave it in this state for a day or so, just in case Owen wants to tweak some more, or further feedback trickles in.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commentedI removed my write perms to backup dior and the rollback happenned as expected.
I did notice that updatecode appears to be refreshing my update_status info every time. not sure if thats by design or not.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentedCommitted after making improvements in #10.
Comment #13
Owen Barton CreditAttribution: Owen Barton commentedCommitted a bunch more re-factoring over the last couple of weeks - mostly moving things around to simplify the structure, standardize the naming and pass more information down to the various engines (this is needed for future improvements). I have fixed quite a few bugs also due to a nice test script - I will go through and close off any issues that are resolved.
I think that is the most disruptive part over - the next round of changes will be more substantive, so will get their own issues.