Drush_pm uses very confusing variable names, mixing up projects/releases/packages and using meaningless names such as data and info in ways that make the contents of the variable very hard to determine without tracing each one back to it's source. This patch lays down a standard terminology and naming convention across the main install and update functions.

In addition, it also does the following:
* Splits the mammoth 130 line drush_pm_update() function into 2 - one that does the listing of module status, and prepares the array of updates to be made, and another to confirm and actually do the updates.
* Adds various inline comments to explain the intention
* Reorders some logic to group related operations (e.g. user output) closer together.
* Removing unrequested updates now comes after the table display - so you always see a list of all available updates (rather than just your selected updates) - this is a change in behavior, but now actually matches the description of the table ("Update status information on all installed and enabled Drupal modules").
* The output before the summary of modules that are about to be updated has been tweaked to make it clear that these *will* be updated (the previous output didn't actually explain what would happen if you hit "y").
* Renamed drush_pm_install_package() to drush_pm_install(), to make it in line with drush_pm_update() and also remove the inconsistent singular 'package' (when it accepts multiples).

Finally, this patch adds the ability to update to a specific version of a module using the project-1.x-dev type command, without needing to remove and reinstall it as you do now. This is unrelated to the refactoring, but I decided to leave it in for now since it is now quite straightforward (literally just the "Preprocess releases" loop and the 2 new constants/case options). If anyone wants however, I am happy to split this out and we can review separately at http://drupal.org/node/238762.

Drupal 5 and 6 patches attached. I have tested them both and they seem pretty solid to me - it would be worth someone else giving them a run over before we commit however.

Comments

moshe weitzman’s picture

Status: Needs review » Needs work

Tried with D6 and I could not get pm update to do anything besides list that my version of Drupal was already at 6.5. I successfully installed an older release like simpletest-6.x-1.0-alpha1 but then could not update to simpletest-6.x-1.0-alpha2

owen barton’s picture

Could you give some more details - did this work without the patch? Were you trying with the automatic version selection, or were you specifying the alpha2 version manually?

moshe weitzman’s picture

Status: Needs work » Needs review

Seems like it doesn't work unpatched either. Ugh ... I was manually specifying the version. I hope to review this another time when i am not so tired. Wish the red sox game would end already.

owen barton’s picture

StatusFileSize
new4.18 KB
new2.63 KB

So I just had a play with this, and as far as I can tell it is working correctly - please see the attached logs, one without the patch and one with. Note that they are both the same, except that the first one is unable to update to the specified version, whereas the second is (as is expected). Both work successfully for me with automatic version updates.

Could you check that you have cvs_deploy installed and enabled (assuming you are using CVS checkouts), that you enable the module you want to update and refresh the update cache and check again (ideally with and without the patch)?

Thanks!

owen barton’s picture

Been using this without issue for the last few weeks - am tempted to just commit it ;)

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Go ahead, owen. I'll come crying if it breaks my installs :)

owen barton’s picture

Status: Reviewed & tested by the community » Fixed

Committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.