Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial selectively hgignore htaccess files

I am using Mercurial for version control, and have an .htaccess file in my web root with rewrite rules that differ depending on whether it's my localhost or my development server, etc. Therefore, I have put ".htaccess" into my .hgignore file, so that it's not part of version control.

However, I also have another .htaccess file, at .hg/.htaccess, with "deny from all", so that my .hg folder is not web accessible. I DO want THIS htaccess file checked in to version control, so that there's no chance of me forgetting to set it up on a new server, etc.

Is there a way to do this? It seems as if just putting ".htaccess" into my hgignore makes it ignore all .htaccess files, located anywhere. I tried "./.htaccess", hoping that'd ignore the root level one, but not .hg/.htaccess--didn't work though. I've tried doing research and have not had much luck.

Thanks, and sorry if I missed something obvious somewhere!

like image 654
Simon Avatar asked Oct 07 '22 05:10

Simon


2 Answers

It is not possible. Not because of ignore, but because of files from .hg cannot be tracked by mercurial.

So you better create and check-in .htaccess.dist with template that fits most of your requirements and after you check out it on a particular machine - copy .htaceccess.dist to .htaccess and make required changes in it.

like image 157
zerkms Avatar answered Oct 08 '22 18:10

zerkms


There is a (simple and elegant) solution. It appears you're using the glob sytax. With a simple regex you can ignore only the files that are in the 'root' of your repository. Say you wanted to ignore just the main .htaccess, you'd have to append the following to the .hgignore:

syntax: regexp
^\.htaccess

Also, comment out or remove the .htaccess from your .hgignore. Note that all patterns below the line syntax: regexp will have to be in Perl/Python-style regex, as stated in man hgignore.

Hope this helps!

like image 38
Luk van den Borne Avatar answered Oct 08 '22 20:10

Luk van den Borne