CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Taking care of custom code during upgrades
Pages: [1]

Author Topic: Taking care of custom code during upgrades  (Read 1756 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Taking care of custom code during upgrades
January 22, 2009, 05:38:49 pm
Hi there,

I started development with 2.1.2.  We're now at 2.1.4 and 2.2 around the corner.  I've inevitably had to 'hack the core' a few times and kept all my customisations in a separate directory.  I encountered an issue in my 2.1.2 installation (http://issues.civicrm.org/jira/browse/CRM-3866) and it has made me think about the implications of customising the code on upgrading.

I once did a diff between 2.1.1 and 2.1.2 and it makes me think that going from 2.1.2 to 2.1.4 isn't going to be completely trivial.  I imagine that most of the files I modified in 2.2 will have changed a lot by the 2.4.  I'm not massively experienced with projects that have quick release cycles or with doing clever stuff with diff, patch and svn so wanted to ask if the following a sensible approach to upgrade from 2.1.2 to 2.1.4, and request a bit more detail / help.

1) Do a diff between my 2.1.2 customisations and the original 2.1.2.
2) Follow the upgrade to a new revision instructions at http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrade+to+a+New+Revision+-+Drupal
3) Make a new custom code directory and then use patch with some cool options to create a load of files in the new custom code directory that are based on 2.1.4 but contain my changes?

Also, what about when I upgrade this site to 2.2?  Is it the same thing but a bit more involved?  Any insights and tips on best practice for development environments etc. from experienced types very appreciated.

Cheers,
Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Taking care of custom code during upgrades
January 22, 2009, 11:11:15 pm
Hi,

What I do to make it a bit less painful:

1) Use svn, and hack on the svn version first
You have nice things like svn status or svn diff to see what you have changed

For increments within the 2.1 series, svn update does the trick most of the time, and makes it easier to fix manually

For new branches, it needs more time to be sure the patches are still valid, have been fixed better, or are incompatible

I tend to do smaller svn diff on subdirectories or files, and patch -p0 them on the new branch

2) Use rsync -avzC to put in prod or move between servers
So you are sure not to miss anything

3) I haven't played too much on the custom directories for templates and php, mostly because I want them in the svn and find it easier to see what has been changed

4) I'm considering going git (mostly because that's the source code manager we use within my company) and using git-svn, any experience with that ?

Makes it easier, or at least less painful ;)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Taking care of custom code during upgrades
January 27, 2009, 01:52:38 am
Hi there,

Looks like proper use of SVN eases the pain a lot.  At the moment I use diff on Eclipse on Windows - it's ok but requires a fair amount of intervention.

I think I'll start a related post / wiki page on setting up a development environment for civicrm incorperating best practice, etc. and put some of this info in there.





Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Taking care of custom code during upgrades
January 27, 2009, 07:08:19 am
Hi,

How my! yes, svn will make it easier for you.

There is a plugin (or is that the core now?) in eclipse to interface with svn directly.

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Taking care of custom code during upgrades
January 28, 2009, 07:33:26 am
The way we do things at DharmaTech has been working well.  Our Subversion repository has a directory per major release, and each major release directory has vendor, trunk and branches subdirectories.  When a new major release comes out we put it in rrr/vendor/ then copy that into rrr/branches/devl/ and hack on the devl branch only.  That way it is always easy to see exactly what has been hacked by diffing vendor/ with branches/devl/ .  When the hacks seem stable we copy branches/devl/ to trunk/ and we roll that out to our clients.  You can see how this is done at our repository.

When a new bugfix release comes out we merge it into rrr/vendor/ then merge from there into rrr/branches/devl/ and repeat the verification cycle.  Thus vendor/ always contains only code from the download, never local changes.

Some of our hacks merge automatically into new releases, while other hacks require some rework.  Rework is a lot easier if you can diff the original and hacked code and the changes made in the new release.

-- Walt

http://dharmatech.org
oss@dharmatech.org
801.541.8671

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Taking care of custom code during upgrades
January 29, 2009, 12:05:07 am

That's the way I did it. My experience:

1) The svn external is great for that (the vendor branch is automatically sync with the civicrm svn
2) The merging between the vendor and your local branch is a pain enough so you don't do it as often as you'd do svn update
3) the merging between your branch and the vendor branch is a pain enough so you don't give back patches as often as you could/should

I think git-svn is a nice option (you manage your local branches on git, with the nice merge/branch that does work) , and you sync it with svn easily. Haven't tried, any experience return more than welcome.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Taking care of custom code during upgrades
January 29, 2009, 03:36:28 pm
Quote from: michaelmcandrew on January 27, 2009, 01:52:38 am
Looks like proper use of SVN eases the pain a lot.  At the moment I use diff on Eclipse on Windows - it's ok but requires a fair amount of intervention.

SVN is highly recommended. Tortoise SVN is a fine Windows GUI and works well. The easiest way to setup an SVN repository, IMO, is to hire one out. I use a service for $4 a month (can't ask for better than that) and the SVN works perfectly. They also provide Trac, which I use.

I don't want to advertise for them here, but if you are interested, contact me offline and I will send you a link to them--I have no affiliation whatsoever, just a satisfied customer. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Taking care of custom code during upgrades

This forum was archived on 2017-11-26.