简体   繁体   中英

what is the best way to svn 2 copies of a same project?

I am working on a project that runs on two places, one on an active server and another in a local test environment. The 2 copies differ only in some configuration files (that stores names, urls, database info, etc) at several places.

Now I work like this:

  1. do some edits to the local copy, test the new version in the local test environment, if everything is fine, svn commit;

  2. go to the server, svn update, manually resolve the conflicts -- but there are a lot edits since many config items are different between the 2 copies... and I don't want to simply accept mc since there could be some changes in the config files...

Now I am thinking to keep both copies of the config files in the repo, switch the file names back and forth in my local copy, so I don't need to deal with the conflicts when I update the server copy. Is there any smarter way to do this?

You can keep two different files and use symbolic links to one of them.

project
  |-configuration
  |  |-development.cfg
  |  \-production.cfg
  \-config.cfg < symbolic link to configuration/development.cfg

The first time you checkout, you will have to create a symbolic link to one of these files.

Create three config files:

  • common
  • test
  • production

Change the config reader so it can read more than one file (options in later files overwrite earlier ones).

That allows you to split the config (and you can prepare the production config on your development machine or even test it there).

Now you just need to add an optional command line option. If the option is there, the common+production config is read. If it's missing (during development), the common+test config is used.

You should maintain as many resources as you can as JNDI named resources. You can configure your test and prod servers with the same JNDI name in front of different values. Your app doesn't have to change that way.

I'd use an environment variable or flag to tell the app which version of the configuration to use.

  1. If you use one repository-location for both servers, you can think about splitting into two (branches) inside single repo and merge changes later between branches
  2. For config-files in branches you can think (?) about moving configs into separate directory, define this dir as externals for parent repo and use relative (not absolute) path in svn:externals or specify different PEG-revisions (prepared) for common URL of externals

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM