title: Mercurial pre commit hook to modify settings
body: <p>I'm trying to setup my web-app (browser extension) so that I can seamlessly move between development, test and production.  For the most part I've avoided hardcoding any URLs into the app, but there are few places where this isn't possible:</p>
  
  <ul>
  <li>As a browser extension that injects js, I can't use relative paths (or location.host) when inserting an iframe on a page since it'll default to the domain it's being inserted on.  (but I infact need this to be localhost for testing and then www.mydomain.com once I push live)</li>
  <li>I also sometimes like to test against both the test and live database, but don't want to have to always toggle that flag and risk committing the test db settings.</li>
  </ul>
  
  <p>What's I'd really like to do is a search/replace before I commit (on a couple of files  x.php, y.js) to swap out localhost with www.mydomain.com.</p>
  
  <p>Can anyone tell me how to do that with a precommit hook (or any other technique)?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>While I have this posted under mercurial hooks -- I'm 100% open to any other method of automating the changes...</p>
  
  <ul>
  <li>I'm be OK with doing the change on the live server after pulling changes as well .. </li>
  <li>I guess for the DB changes, I could just remove the config file from my repo and keep a preconfig version on my live server -- but I don't love this because pulling from my repo to a new server / path would pull the entire app without any db settings... (just dumping my ideas here in case it helps someone with a solution)</li>
  </ul>
  
  <p>Thanks!</p>