On all the projects I work on we use CVS checkouts, rather than drupal.org tarballs for our contrib modules. This makes it much easier to contribute changes back to the modules, because we can use cvs diff to derive a standard patchfile. That said, as drupal.org moves towards official release branches for projects it is becoming much harder to simply run all modules off the development branch. We can check out a specific tag, but it is a pain to go and look what the latest official tag is for each project, and to track upgrades. Here is where drush comes in handy :)

Here is a patch to allow separate 'module handlers' for drush pm, and to add CVS and wget as separate handlers. I imagine that folks could add other handlers for SVN or other 'internal' repositories if they want (for mass rollout situations).

This module now allows you to install modules with either CVS or wget/curl. You can specify a --handler option to select which, or it will fall back onto whatever is available. I have added documentation to explain this option.

If folks could take a look at this and let me know if this approach looks good that would be great :)

At some point it would be great if we could add some installation hooks so that we check that wget or curl is available for drush_pm_wget and that cvs is available for drush_pm_cvs, and also that either of the above modules is installed for drush_pm to be enabled (this would need some code - we can't do this part in a .info).

Another addition would be to allow users to specify a tag/branch for a release, since at some points you still want to be using the dev version of some modules (modules you maintain, for example!) - I think I will likely try and work on this next. Any ideas on syntax (in a new issue please!).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Owen Barton’s picture

Anyone?

moshe weitzman’s picture

Sorry, I didn't see this ... patch looks good to me. any interest in similarly handling updates? that function is kinda gnarly and maybe you can think if ways to simplify/clean. note that you should probably skip the copying to a backup like a I do for .svn managed projects.

Owen Barton’s picture

Well, updates basically work with the current patch, as far as I can tell at least, because it simply backs up and removes the directory and does a fresh install - or, in this case cvs checkout - using the standard install function.

We could try and be clever of course, and update the tag to the latest release using CVS. The advantage of this I can see is that it preserves the .svn directories, which is an improvement (since using 'rm' rather than 'svn rm' on the module directory, as we do now will confuse svn). The potential disadvantage is that it will try and merge things, which will likely break stuff for the newbie in ways they don't know how to fix.

What do you think?

moshe weitzman’s picture

Note that recent versions of drush don't move your module dir if we notice a .svn directory. That is helpful since the module may have some small modifrications which would be tossed if we moved the directory. svn gets very unhappy if its .svn dir is missing.

So, for updates I thin the right behavior is to leave the diectory and update in place like we do for subversion. we add a reminder for the user in this case to svn commit at his convenience.

Also see http://drupal.org/node/197666 for related issue.

Owen Barton’s picture

FileSize
13.55 KB

Here is an updated patch, which adds support for updates, either with:
A) a cvs checkout (the default if you don't use SVN)
B) a cvs update -dP -r TAG. This will try to merge, and so is best avoided unless you know how to resolve conflicts, which I assume SVN users do - so it is the default for them. However it will remove dead files so keeps things a little cleaner if we are not moving the whole directory to backups and making a fresh checkout (which is the case for SVN users).

I also added a couple of options to force the CVS co/up method, and add parameters to the CVS command.

moshe weitzman’s picture

Status: Needs review » Needs work

missing the new file(s). looks good so far.

moshe weitzman’s picture

oops - they are there. my scripts are too smart.

* I think drush is hurling towards module overload. how about these install handlers live as .inc files instead?
* the wget handler actually supports curl as a fallback. maybe put that in the handler description somewhere. i can imagine people compiling wget when they already have curl.
* "--cvsmethod - force cvs updates or checkouts". it isn't clear what the possible values are. also i would think this only applies to udpates and can be omitted from the help in pm install.
* does it make sense to let cvs credentials get passed as options? we hard code to anon here.
* I can't get cvsparams to work. i am passing: --cvsparams -r DRUPAL-5. The error is: "E: Could not locate the Drupal installation directory. Aborting.". This does not happen without that param. Note that I am indeed not running from drupal root, and my drush.php comes from elsewhere (the rest of drush though is from sites/all/modules). If you don't spot the problem quickly, I will find it.

I can't seem to get pm update to show me pending updates but I'm sure thats a local problem. I will fix and test the next version of this patch.

Owen Barton’s picture

* I think drush is hurling towards module overload. how about these install handlers live as .inc files instead?

That was my initial thought, but then I could imagine that some development shops would want to really stick to a single handler, and so would want to turn the other one off completely. Also they may want to write their own handler (e.g. using svn externals), so modules seemed to simplify things there.
Either way is fine though really, just let me know what you think :)

* the wget handler actually supports curl as a fallback. maybe put that in the handler description somewhere. i can imagine people compiling wget when they already have curl.

It already does this in the module description - do you mean the drush help description?
+description = Allows drush to install and update modules using wget or curl.

* "--cvsmethod - force cvs updates or checkouts". it isn't clear what the possible values are. also i would think this only applies to udpates and can be omitted from the help in pm install.

Yeah - this could use some cleanup, I was trying to not get too wordy. Basically 'up'-anything will do an update, anything other value will do a checkout. Help is fairly clumsy to work with (what with hard coding 80 character breaks etc) - it might be nice to have a 'theme function' to 80-char flow and style the help. Perhaps we could reuse/adapt the html2email code? We might also want to have a more structured way of passing names & descriptions for commands and arguments.

* does it make sense to let cvs credentials get passed as options? we hard code to anon here.

I can't think of a reason. I guess perhaps if it was your own module (so you could commit directly) you might want to do that - but I think making/applying a patch is pretty good practice even then :)

* I can't get cvsparams to work. i am passing: --cvsparams -r DRUPAL-5. The error is: "E: Could not locate the Drupal installation directory. Aborting.". This does not happen without that param. Note that I am indeed not running from drupal root, and my drush.php comes from elsewhere (the rest of drush though is from sites/all/modules). If you don't spot the problem quickly, I will find it.

I think many parameters need to be quoted (or drush picks them up as separate entities) - i.e. --cvsparams="-C".

Also, this module already passes the -r TAG parameter each time already (using the stable tag from the update system) - I am pretty sure it wouldn't work to specify it twice. Adding support for selecting specific tags, dev branches or HEAD is coming (once we commit this) but I think can happen at the drush_pm level, rather than in a specific handler.

moshe weitzman’s picture

module files make sense. you convinced me.

yes, add curl to the drush help, and cleanup --cvsmethod help text. then we are good to commit. i will try to test upgrade before i commit but if not, we'll just wait for bug reports.

moshe weitzman’s picture

Grugnog2 - any chance you can reroll?

Owen Barton’s picture

Yup - I'll try and get to this when I have a moment

Owen Barton’s picture

Status: Needs work » Needs review
FileSize
14.19 KB

I have added examples to both the CVS options, and added a note for wget to mention that curl is also supported. I think we are all set here :)

moshe weitzman’s picture

Status: Needs review » Fixed

I committed this - many thanks.

However, the syntax for specifying handler is a bit unlike the others. Here is my line:

drush -l http://mm/dr5 --handler=wget pm install og_vocab

notice that the -l option has no equals sign but --handler does. I could not get handler to work without the = sign. can we standardize this?

Owen Barton’s picture

Good stuff :)

Next up, I want to work on some options for selecting a specific version (tag/branch), since there are many cases where you want to do that.

It would also be interesting if we could copy the code the d.o. packaging script uses to insert the package version into the .info files (for packages handled by CVS), so you can easily check what is running (cvs_deploy does this, but is not super convenient from the command line).

Regarding the parameters, I am not sure what could be causing this - here are the 2 calls:

$handler = drush_get_option('handler');

drush_get_option(array('l', 'uri')

Both are within the syntax drush_get_option() accepts, so I am pretty sure this is a bug in drush_parse_args() - looking at it it seems to handle short and long options slightly differently, so perhaps this is it. I'll open a new issue for this.

dww’s picture

I wish someone had referenced http://drupal.org/node/124661 in here earlier... I recently found out in IRC someone implemented this in drush and I came searching. No time to read or review what's here. I just hope your design followed the path I spelled out months ago about how to best get this working. ;)

Owen Barton’s picture

dww - I had read that thread also (albeit many moons ago), but I think the important features are now present - the update system is used to determine stable versions. CVS tags are used for stable checkouts (rather than branches, which are obviously not really stable), and there are several choices for updates (from a straight cvs up, which will merge, to an overwriting cvs up, to a fresh checkout).

There are other drush issues around for adding options for doing checkouts of a specific branch or (older) tag, but the stable tag will remain the default.

dww’s picture

Sweet, sounds lovely. Makes me feel more at ease knowing you read my original proposal about how it should all work, even if it was a while ago. ;) I'll have to try it out someday when I have the chance. Thanks for implementing it! Once this functionality is in an official release, I'll update the cvs_deploy project node to point to it. Yay. ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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