Here's Agaric's workflow (ignore the lack of a link to Drush's path, we have too many Drupal installations to make that practical at the moment):
cd /var/www/drupal-5_3-live/sites/all/modules/
sudo php drush/drush.php -l http://example.com pm install fasttoggle
sudo svn add fasttoggle
sudo svn commit -m "Installed fasttoggle via Drush"
Drush has me expecting to be able to wave my hand in the general direction of the keyboard and get what I want.
So the above is just too much typing!
So the immediate support question is: should I go about scripting it inside Drush, or outside Drush?
Could/should post pm install actions be added to Drush, or is the best approach a Bash script that wraps around Drush (and has a delay before svn add? Hmm.)
Thanks!
benjamin, Agaric Design Collective
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | drush_head_pm_svn_0.patch | 10.01 KB | owen barton |
| #17 | drush_5_pm_svn_1.patch | 10.03 KB | owen barton |
| #16 | drush_5_pm_svn_1.patch | 10.03 KB | owen barton |
| #14 | drush_5_pm_svn_0.patch | 9.16 KB | owen barton |
| #12 | drush_pm_svn_0.patch | 5.77 KB | owen barton |
Comments
Comment #1
moshe weitzman commentedthats my workflow too. i'd like to see this in drush. i'm not sure how best to implement it. maybe a post hook a you suggest. i guess that hook could run for all drush commands, not just pm install.
Comment #2
mlncn commentedIt gets more complicated when you update...
As far as I can tell, the only way get your updated module into subversion is to delete the original and
svn addthe updated version.Please correct me if I'm wrong, but if this is the case, for people keeping their local checkouts of Drupal modules under SVN:
pm update will need to be followed by a script that sees what has changed, and then runs a script like this (called as
drush_update_svn module1 module2 moduel3etc.).Comment #3
moshe weitzman commentedat a high level, thats what is needed. but i don't think that we need to svn remove files that are staying in the repository. we only need to remove those that are no longer in the directory. similarly, we need to discover newly added files and svn add them. there are some scripts out there for this from which we might learn. for example, see http://piston.rubyforge.org/.
Comment #4
moshe weitzman commentedif it gets too complicated, i guess we could only hook into pm install for now and leave pm update for later.
Comment #5
moshe weitzman commentedhere is a great blog post which details usage of svn_load_dirs.pl. That script ships with svn and really helps handle changes like this. see http://www.burtonini.com/blog/computers/svn-vendor-2005-05-04-13-55
Comment #6
ukdg_phil commentedHi, I've just discovered the wonders of drush & the pm install feature!
Just wondered on the svn setup you guys are using, as I currently use svn:externals to add drupal modules to sites, so theres only one copy of the module code in the svn repos.
I take it doing things the way you show benjamin, each site in your repository has its own copy of the contrib module? Don't see much of an issue with that, seeing how easy drush makes adding & instaling modules now! Just wanted to see how others do things before I start using drush in my daily workflow : )
Thanks,
Phil
Comment #7
moshe weitzman commentedI keep each project in separate svn repository and same for Contrib. No svn:externals for me and my clients. Folks who like svn:externals might be interested in the repos at http://svn.advantagelabs.com
Comment #8
ukdg_phil commentedCheers Moche, will try & take a look at that link when I get a spare mo.
Although I'm starting to think I might ditch svn:externals, as it can complicate things alittle, and instead go for a similar setup to you guys.
Back to the original post, when doing an update on a module already in your svn repos, would the workflow go like this?
Comment #9
moshe weitzman commentedyes, thats the idea. perhaps someone could try this out and see how well it works. then we'll talk about how smart drush should get about this workflow.
Comment #10
moshe weitzman commentedA drupal specific tutorial including svn-load-dirs: http://www.davidgrant.ca/maintaining_vendor_sources_with_subversion
Comment #11
owen barton commentedAnother option, that seems quite a bit simpler (especially if we want to implement in PHP!) is http://gael-varoquaux.info/computers/svnautocommit/#the-autocommit-script - this does what is described above - reading the output of svn stat, and adding/deleting the files as appropriate.
Comment #12
owen barton commented..and a patch...
I have moved all subversion integration out of the main drush_pm module, and into a drush_pm_svn module (yay!). There is now a hook to suppress backups, and another more general one after the install/update of each project, which should be useful for lots of things. I have added a simple static get/set function to store the output of the last exec (this is somewhat the same style as used by perl, IIRC) - which seemed neater and easier than returning a whole array of the return value plus the output. We need this to parse svn stat output, but it is also handy for presenting more helpful error messages (we should apply this approach to the handler modules too, I think).
Everything else is pretty much self explanatory. I have added lots of error checking and messages. I didn't go for drush_die, since none of these really seem 'fatal' to me, however I am open to suggestions otherwise! This needs testing with the wget handler (I tested quite a lot with cvs though), and perhaps a good read through the documentation and error messages.
Comment #13
moshe weitzman commentedNice work!
* Need some Doxygen for drush_shell_exec_output_set()
* Personally I find it easier to work with XML output than regexing out info. See `svn stat --xml` for an example. Not a big deal I suppose.
* Does it make sense to implement the backup step as a 'pre' operation of pm update?
* Instead of implementing pre/post hooks that are specific to install and update, why not add these for all commands. Maybe in drush_dispatch(). That function seems to support multiple commands in one drush call but I have never tried that.
* I suspect some implementations will want to pass in subversion credentials in this call. We should document how to do that in the help for the commands and/or in example.drushrc.php
* Some support for DRUSH_SIMULATE mode would be very handy here.
-moshe
Comment #14
owen barton commentedAdded.
I agree here - I think it might be best to add this to the D6 version though, since we have PHP5 and hence SimpleXML, and keep the D5 version PHP4 compatible.
I thought about that, but we still need some way for other modules to overrule the backups. The only other things I can think of seem more complex or fragile.
This is a great idea, and should be easy to implement. However I think this is a different patch because neither of these would really help us here - skip_backup needs to know the source of the module to check for .svn directories and drush_pm_post_update should only be run after a successful install (not just after the completion of the command). Also each of them should be run for each project, not once per command.
I have added these, which I think could be useful (although only occasionally), we need a separate parameter for each command because different svn commands accept different parameters (and throw errors if they get one they don't expect).
It already works in simulation mode by not actually running the shell command. Not sure what else we would do in simulation mode - svn has a --dry-run option, but only for merge (which we aren't using).
Comment #15
owen barton commentedand a HEAD patch (could use a test)
Comment #16
owen barton commentedand a tweaked D5 patch
Comment #17
owen barton commentedand a tweaked D5 patch
Comment #18
owen barton commentedForgot the HEAD patch (end of day...)
Comment #19
moshe weitzman commentedCommitted! This was nicely done. Thanks Grugnog2.
I think that svncommit should imply svnsync. This saves typing.
Comment #20
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.