Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion...
Transcript of Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion...
![Page 1: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/1.jpg)
Simplifying Drupal Development with
Subversion
Andrew Berry: [email protected]://www.abdevelopment.ca/
![Page 2: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/2.jpg)
How do Drupal sites get managed and
deployed?
![Page 3: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/3.jpg)
![Page 4: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/4.jpg)
![Page 5: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/5.jpg)
![Page 6: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/6.jpg)
And modules...
![Page 7: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/7.jpg)
And themes...
![Page 8: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/8.jpg)
And libraries...
![Page 9: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/9.jpg)
And custom themes or code...
![Page 10: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/10.jpg)
![Page 11: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/11.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
What is Version Control?
• The management of changes to code and project resources over time
• Project history
• Takes the processes you do manually for creating copies of old files, cleans it up, and makes it automatic
9
![Page 12: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/12.jpg)
![Page 13: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/13.jpg)
1
![Page 14: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/14.jpg)
1
![Page 15: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/15.jpg)
1 2
![Page 16: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/16.jpg)
1 2
![Page 17: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/17.jpg)
1 2 3
![Page 18: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/18.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Immediate benefits
• Revert local changes
• Revert to a previous version
• Compare previous versions of a file
• “annotate” or “blame”
• Multiple developers / computers
• Conflict resolution
11
![Page 19: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/19.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
SVN Hosting
• Your own system (VPS, desktop, web server, etc)
• Just make sure that your server is accessible over the ‘net
• Code hosting services
• Unfuddle, Beanstalk, Springloops, etc
• Google Code, Sourceforge
12
![Page 20: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/20.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Setting Up the command-line SVN Client
• It’s really simple on Linux - just search for and install “subversion” from your package manager
• OS X 10.5 includes an older version of Subversion (1.4.4 currently)
• I recommend downloading the latest version and installing that
• For Windows, or the latest version for other OS’s, see http://subversion.tigris.org/
13
![Page 21: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/21.jpg)
Demonstration!http://www.flickr.com/photos/dans180/243974098/
cd drupal-6.13svn import https://kibble.serveftp.net/svn/wdug-demo/cd ~/Projectssvn co https://kibble.serveftp.net/svn/wdug-demo/svn logsvn mkdir sites/all/modulesmv ~/Drupal\ Modules/webform sites/all/modules/svn statsvn add sites/all/modules/webformsvn statsvn cisvn infosvn upsvn log
![Page 22: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/22.jpg)
About .svn folders...
Copy in the new webform files.svn statsvn revert -R .diff -rup webform-2.6 webform-2.7 | grep "Only in"svn ci -m "Updating to webform 6.x-2.7 for critical security upgrades."svn up
![Page 23: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/23.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
I broke it!
• svn stat
• svn diff
• svn revert
• svn merge -r HEAD:PREV .
• If it’s committed, your local checkout is expendable
16
![Page 24: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/24.jpg)
Repository Layout
![Page 25: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/25.jpg)
http://www.flickr.com/photos/copleys/3725348370/
![Page 26: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/26.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Three Directories
• trunk
• branches
• tags
• ...
19
![Page 27: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/27.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Branches Merging to Trunk
• Have each developer working on a feature work in their own branch
• When complete, merge back to trunk
• Deploy site from trunk, or from a tag made from trunk
20
![Page 28: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/28.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Trunk Splitting into Branches
• Trunk is the latest, bleeding-edge code
• Branch from trunk to stabilize code for release
• Tag from branch once ready to be deployed
21
![Page 29: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/29.jpg)
Whatever your repository layout, keep
it consistent and documented
Subversion is flexible, so use it that way!
![Page 30: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/30.jpg)
Demo!http://www.flickr.com/photos/40002687@N02/3676625419/
Billy Mays firing dead bugs at a windshield to demonstrate wipers.
svn upsvn rm * .htaccesssvn cisvn mkdir trunk tags branchescp -Rv ~/Drupal\ Modules/drupal-6.13/ .svn add * .htaccess && svn cisvn cp trunk/ branches/new-theme && svn ci
![Page 31: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/31.jpg)
svn switch(having the entire repository checked out isn’t the best
use of your disk space)
svn switch https://kibble.serveftp.net/svn/wdug-demo/trunksvn switch https://kibble.serveftp.net/svn/wdug-demo/branches/new-themeadd acquia_slatemerge to trunksvn switch trunksvn merge https://kibble.serveftp.net/svn/wdug-demo/branches/new-theme .
![Page 32: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/32.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Deployment Advantages
• No more FTP!
• No more manual tracking of file and folder changes
• Much faster transfer (compression, differences only, less overhead)
• Use ‘svn stat’ on the server to detect changes
25
![Page 33: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/33.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Drupal-specific Notes
• settings.php may be an issue due to SQL passwords
• /files directories
• svn:ignore
• Database / code coupling
26
![Page 34: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/34.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
hook_update_N
• You can use a custom module with a .install file to automatically configure site updates
• For example, you can easily set variables, install modules, or update the database
27
![Page 35: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/35.jpg)
Merging external sources
![Page 36: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/36.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
External Code
• Every Drupal developer will need to merge in changes from external sources
• Subversion, plus additional utilities, can make updating modules a much simpler process
• Faster, less errors, automatic patch integration (!)
• Many thanks to IMAGEX MEDIA (http://imagexmedia.com/)
29
![Page 37: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/37.jpg)
http://www.flickr.com/photos/31847994@N04/3676331838/
![Page 38: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/38.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
In a Nutshell• Import the first version of the module into /vendor/
modules/<module_name>/current
• I use current-47, current-5, current-6
• Tag current with version number
• “svn cp current 6.x-1.0”
• Use svn_load_dirs.pl to import later versions of the module
• svn_load_dirs.pl -t 6.x-1.1 https://example.com/svn/vendor/modules/cck current cck
31
![Page 39: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/39.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Handy Utilities
• svnmerge.py: http://www.orcaware.com/svn/wiki/Svnmerge.py
• svn_load_dirs.pl (or the Python equivalent)
• grep
• diff / patch
• pbcopy, pbpaste, open, gnome-open
32
![Page 40: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/40.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
GUI Clients
• IDE Plugins (Eclipse, NetBeans, DreamWeaver, etc)
• TortoiseSVN (watch the download links for ads)
• KSVN
• Web interface (WebSVN, ViewVC, mod_svn)
• Many, many others
33
![Page 41: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/41.jpg)
Andrew Berry Development, http://www.abdevelopment.ca/
Other VCS’
• Drupal uses CVS
• The Linux Kernel developers use Git
• Ubuntu uses Bazaar
• Many more Free and proprietary VCS systems
• http://en.wikipedia.org/wiki/Revision_control
34
![Page 42: Simplifying Drupal Development with Subversion · Simplifying Drupal Development with Subversion Andrew Berry: andrew@abdevelopment.ca ... • Project history ... mv ~/Drupal\ Modules/webform](https://reader033.fdocuments.in/reader033/viewer/2022042320/5f09ff7a7e708231d429843b/html5/thumbnails/42.jpg)
Questions / Comments?