473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Version control philosophy and style

JDS
I am trying to figure out how to use Subversion, but this question isn't
really Subversion-specific. Any version control system will suffer from
the same problem, IMO.

I've crossposted to those groups I've deemed most relevant WRT web
development. (Well, relevant to *me*). I don't think this question will
be completely relevant in a C/C++ or other local devlopment environment.
Maybe it is...
So, in using Subversion, I have imported a webapp directory tree "into"
Subversion.

I have then "checked out" a copy of the webapp into a development
directory. (This is a PHP+Apache+MySQL app, btw).

Now, to test, I have a LAMP environment installed *locally* and I access
the webapp locally (the cheked out copy) using
http://localhost/path/to/webapp/
Now, the question comes down to configuration details and "pushing" the
thing to the live web server. The local LAMP config and the "live" SAMP
config (the live server is on Solaris) are quite different from each other
as far as naming of paths and whatnot on the server.

There *is* a config file in the webapp hiearchy! Changing that file
easily makes the webapp point all of its various pieces to the correct
paths and files on the server.

But the config file has to be different on the working copy than on the
server!

How can a version control system deal with this problem without me having
to tweak the "live" config file every time I migrate the app from the
Subversion repository to the live server?

Any general insight at all would be appreciated. I have worked as a web
developer for quite a while now, but never have used a VCS before. I'm
sure it is not a new question! But how does one Google on so esoteric a
concept?

Allright, thanks. later...

--
JDS

Jul 14 '06 #1
5 1653
JDS wrote:
I am trying to figure out how to use Subversion, but this question isn't
really Subversion-specific. Any version control system will suffer from
the same problem, IMO.

I've crossposted to those groups I've deemed most relevant WRT web
development. (Well, relevant to *me*). I don't think this question will
be completely relevant in a C/C++ or other local devlopment environment.
Maybe it is...
So, in using Subversion, I have imported a webapp directory tree "into"
Subversion.

I have then "checked out" a copy of the webapp into a development
directory. (This is a PHP+Apache+MySQL app, btw).

Now, to test, I have a LAMP environment installed *locally* and I access
the webapp locally (the cheked out copy) using
http://localhost/path/to/webapp/
Now, the question comes down to configuration details and "pushing" the
thing to the live web server. The local LAMP config and the "live" SAMP
config (the live server is on Solaris) are quite different from each other
as far as naming of paths and whatnot on the server.

There *is* a config file in the webapp hiearchy! Changing that file
easily makes the webapp point all of its various pieces to the correct
paths and files on the server.

But the config file has to be different on the working copy than on the
server!

How can a version control system deal with this problem without me having
to tweak the "live" config file every time I migrate the app from the
Subversion repository to the live server?

Any general insight at all would be appreciated. I have worked as a web
developer for quite a while now, but never have used a VCS before. I'm
sure it is not a new question! But how does one Google on so esoteric a
concept?

Allright, thanks. later...

--
JDS
I posted how I deal with this a little while back:

http://groups.google.com/group/comp....ffc0861b30517c

Right now i simply delete the whole live site and export a clean copy
of it from subversion (phpmyadmin, bugzilla, wiki, etc are stored in a
directory aboved and aliased to prevent deletion). In addition to the
export, i delete certain files: *.dev.php, and *.config-dev.php (in
case i forget to). This allows me to automatically update the
development server on each commit (using a hook) then roll it out to
the live one without worrying about having to change configuration
settings.

In retrospect, I probably should have made the live version a working
copy, too, so i could just do an update and use svn:ignore to filter
out the development files.

The downside is that the working config file is versioned, when it
should just be the vanilla configuration file that is versioned. It
would be better to take an approach like phpmyadmin: have a versioned
vanilla default.config.php, then an overridding, non-versioned file
server.config.php that is included if it exists. Then you can update
the defaults and keep them in sync with the latest version while not
losing your custom settings.
Another approach i just thought of would be to use svn's merging
abilities, but have it always use your copy instead of their copy.
That way, when it merges and there's a conflict, your custom settings
will take precedence. The downside of this is that if you make a small
patch to the live site then you'll have to manually update that file
(so that your HEAD version's fixes go in over the temporary patch)

Jul 14 '06 #2
JDS wrote:
But the config file has to be different on the working copy than on the
server!

How can a version control system deal with this problem without me having
to tweak the "live" config file every time I migrate the app from the
Subversion repository to the live server?
The easy answer is to simply not version control the config file. But
that's not a satisfactory answer, as there are clear benefits in
keeping the file in the repository. It remembers the date when you
change the config and give you a place to enter a reason explaining the
change. That could be very useful information when odd things start to
happen. The ability to roll back to a previous configuration is
obviously a big plus. Having the file under SVN also simplifies the
push process.

One possible strategy is to have separate config files under different
names. Depending on which environment the application is running in,
it'd load in the correct one. For example:

$conf = parse_ini_file("{$_SERVER['SERVER_NAME']}.ini", true);

I would keep both the production and the development version in SVN.
That way you wouldn't forget that a config change is necessary for some
newly developed code, since SVN will spot the change when you commit.

Jul 15 '06 #3
JDS (je*****@invalid.address) wrote:

: There *is* a config file in the webapp hiearchy! Changing that file
: easily makes the webapp point all of its various pieces to the correct
: paths and files on the server.

: But the config file has to be different on the working copy than on the
: server!

: How can a version control system deal with this problem without me having
: to tweak the "live" config file every time I migrate the app from the
: Subversion repository to the live server?

I just keep separate config files for the different servers. Install the
app, and then install the appropriate config. I don't see how to avoid
"tweaking" the different config files at some point.

The development copy becomes your defacto "master" version. Note that the
versioning of this copy will track _two_ kinds of changes. "Maintence"
changes required for the (developmenet) server, and "upgrade" changes
required for the application updates.

Make sure that only one type of change is checked in at a time. E.g. if
you add a config variable (an upgrade change) and also change a path (a
maintenance change) then do two checkins, once to add the config variable
and once to change the path.

That way, later on it is easier to replicate the "upgrade" changes, simply
do a diff between the before and afters of the "upgrade" checkins.

Then apply those same changes to the various server configs.

If you get ambitious then use those changes as patches to automate the
upgrades of the server-specific configs. Apply the patches (in my example
to add the config variable), and then tweak the new values for each server
config (which you have to do at some point anyway).
Or - replace this whole thing with an install utility. That may itself
need a config file, but it will likely be simpler to maintain as you can
allow all sorts of defaults that the install will detect itself.

Or - a variation - use paths and variables in your development version
that are carefully chosen to be unambiguous in your code, and then a
script can easily _edit_ the master config file during the install to have
server specific values.

Or - include a config upgrade script with your application that will read
the old config variables and then spit out a new config file using those
values, perhaps prompting for any values that are new and cannot be
calculated.

$0.10
Jul 15 '06 #4
On Fri, 14 Jul 2006 15:55:40 -0400, JDS <je*****@invalid.addresswrote:
>I am trying to figure out how to use Subversion, but this question isn't
really Subversion-specific. Any version control system will suffer from
the same problem, IMO.

I've crossposted to those groups I've deemed most relevant WRT web
development. (Well, relevant to *me*). I don't think this question will
be completely relevant in a C/C++ or other local devlopment environment.
Maybe it is...
So, in using Subversion, I have imported a webapp directory tree "into"
Subversion.

I have then "checked out" a copy of the webapp into a development
directory. (This is a PHP+Apache+MySQL app, btw).

Now, to test, I have a LAMP environment installed *locally* and I access
the webapp locally (the cheked out copy) using
http://localhost/path/to/webapp/
Now, the question comes down to configuration details and "pushing" the
thing to the live web server. The local LAMP config and the "live" SAMP
config (the live server is on Solaris) are quite different from each other
as far as naming of paths and whatnot on the server.

There *is* a config file in the webapp hiearchy! Changing that file
easily makes the webapp point all of its various pieces to the correct
paths and files on the server.

But the config file has to be different on the working copy than on the
server!

How can a version control system deal with this problem without me having
to tweak the "live" config file every time I migrate the app from the
Subversion repository to the live server?

Any general insight at all would be appreciated. I have worked as a web
developer for quite a while now, but never have used a VCS before. I'm
sure it is not a new question! But how does one Google on so esoteric a
concept?

Allright, thanks. later...
How about:

1. Check in the config file with replaceable parameters instead of
whatever values you have to change for local/testing compared with
server/production values.

2. Then use a little ed or perl script to change the replaceable
values as needed each time you test or deploy.

3. The ed or perl script should also be checked in, so everything
is tidy.

HTH.

CB
Jul 15 '06 #5
JDS
On Fri, 14 Jul 2006 17:20:49 -0700, Chung Leong wrote:
One possible strategy is to have separate config files under different
names. Depending on which environment the application is running in,
it'd load in the correct one. For example:

$conf = parse_ini_file("{$_SERVER['SERVER_NAME']}.ini", true);

I would keep both the production and the development version in SVN.
That way you wouldn't forget that a config change is necessary for some
newly developed code, since SVN will spot the change when you commit.
Thanks, all, for the insightful input.

I have opted for Chung's suggestion, as it feels best to me. The other
suggestions were all great as well!

So now, for the config, I have a static file that has non-environment
specific config details, and it includes a server-specific file based on
$_SERVER['SERVER_NAME'] for the server-specific stuff.

All configs are versioned, of course.

Allright, I think I'm starting to get the hang of using version control!
Later...

--
JDS

Jul 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
11
by: trinitypete | last post by:
Hi all, I have a user control that uses control literal to build a heading with a link, and a div containing links below. As the link heading is hit, I want to change the style of the div,...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
0
by: YellowFin Announcements | last post by:
Announcing Yellowfin Version 2.4 release. (www.yellowfin.com.au) Existing SQLserver users can take advantage of this upgrade as soon as convenient. V2.4 Exciting changes in the latest...
22
by: Xah Lee | last post by:
The Nature of the “Unix Philosophy” Xah Lee, 2006-05 In the computing industry, especially among unix community, we often hear that there's a “Unix Philosophy”. In this essay, i...
2
by: Hongbo | last post by:
Hi, I have a web site built in ASP.Net 1.1 running on production server. It's the version 1.0. Now I need to build the version 2.0 for this web site. The version 2.0 will be built based on the...
12
by: lawpoop | last post by:
I'm developing a php website that I have under subversion version control. I'm working on an image upload functionality, and in the middle of it I realized that any files that a user uploads will...
3
by: jrod11 | last post by:
Hi everyone, I'm working on creating a company intranet or my company and having trouble with IE. I have a navigation bar at the bottom of my page that is a quick links bar and is a fixed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.