How to ignore certain folders in HG? - mercurial

I have my project folder - Project. In Project I have other sub projects - SUBPROJECT1, SUBPROJECT2, SUBPROJECT3.
In each sub project I have folders, among which I have BIN and OBJ. However, I want the latter to be ignored such that when I commit I don`t have the changes made to BIN and OBJ. How can I do that?

You'll need to edit your .hgignore file, and include the following lines:
glob:bin\
glob:obj\
You probably want at least these other things as well:
glob:*.user
glob:*.suo
glob:_ReSharper.*\
There's other examples out there of more complete .hgignore files.

With .hgignore.

Related

Mercurial .hgignore

I need to ignore all files in whole project tree, versioned by Mercurial, that starts with specific character. Let's say underscore (or it may be some other).
I searched on google a lot, but I cannot find right glob syntax. I found glob expression test environment, where I could try patterns, but nothing works for me.
Consider following project structure:
/function/_backup/file1.php
/function/_backup/file2.php
/function/Class/A.php
/function/Class/_B.php
/_graph/1.jpg
/.hgignore
/.htaccess
/_index.php
/index.php
The only files that I need to propagate to repository are A.php, .htaccess and index.php.
The question is: how should my .hgignore look like?
You should add the following line to .hgignore:
glob:_*

.hgignore - ignore some folders except one specific folder

__
Hello everybody,
My hgignore file contains following lines:
syntax:regexp
^data/dyn/.*
^data/config/.*
^data/temp/.*
^data/mediapool
^\.project
^\.buildpath
^\.settings/.*
^nbproject/.*
/\.git/
\.hg_archival.txt
syntax:glob
*.sublime-project
*.sublime-workspace
sftp-config.json
BUT, i want to "unignore" the folder data/dyn/xxx/yyy with it's files inside.
How can i solve my problem?
Many thanks!
Mercurial .hgignore files are a blacklist only. The only way to whitelist something is to blacklist the "outer" group and then hg add what you want not-ignore. Adding something with hg add always trumps ignoring it in .hgignore.
That works great for files, but not so great for directories since you can't add directories. You can add all the files in them, but any new files that land there will be ignored until you add them.
You can try using the "zero-length negative look-ahead" feature of regular expressions, but honestly it's easier to just add the files in that directory.

PhpStorm - How can I avoid creating the .idea folder?

I don't want PhpStorm to create an .idea folder. Is this possible?
I'm working in a new environment where I pretty much MUST figure out a way to remove them or I have to change IDE, which I really don't want to do.
Can't PhpStorm store the project files and settings in its own directory?
I don't want PhpStorm to create an .idea folder. Is this possible?
No, but workaround is very simple and described in the actual ticket body: http://youtrack.jetbrains.com/issue/WI-343 :
WORKAROUND: Actually you can do it for a long time - but only manually. Just create a new project anywhere where you want to store your project data, then go to "Settings | Directories" and detach its dir and attach your project root folder.
Just remember to open this folder instead of actual one next time.
Maybe, as an alternative, if you use a VCS, you can add .idea to your VCS ignore list? For example, for Mercurial it is called .hgignore and for Git - .gitignore.

how to ignore files in kiln/mercurial using tortoise hg "that are part of the repository"

We use tortoise hg with Kiln. In my vs 2010 c# project there are some files that are part of the repository but I would like tortoise hg to ignore them when I make a commit.
For eg., say in a login screen I may hard code the userid, password for testing. I dont really want this file considered during a commit. I understand .hgignore file but this really works for files that are not part of the repo. Any trick in tortoise hg to ignore files that are part of the repo ? (so they do not show up as modified (M) during a commit.) thanks
I always use a combination of .hgignore and BeforeBuild (in the .csproj file) for things like this.
In one of my pet projects, I have the following setup:
App.config contains my real hardcoded user id and password for testing.
App.config.example is identical, but with fake data like "dummy_user" and "dummy_pw".
App.config is not part of the repository, and it's ignored (in .hgignore).
App.config.example is part of the repository.
Then, I have the following in the BeforeBuild target in the .csproj file of my solution:
<Target Name="BeforeBuild">
<Copy
Condition="!Exists('App.config')"
SourceFiles="App.config.example"
DestinationFiles="App.config"/>
</Target>
All this together has the following effect:
the config file with the real data can never be accidentally committed to the repository, because it's ignored
the repository only contains the config file with the example data
if someone else clones the repository to his machine, he won't have the "real" config file...but if it's missing, it will be automatically created before the first build by Visual Studio / MSBuild by simply copying the .example file (and then he can just put his real login data into the newly created App.config file).
if an App.config with real hardcoded user data already exists, it won't be overwritten when building because the BeforeBuild event will only happen if App.config does not already exist
The answer by Christian is the right one, but I want to mention that TortoiseHg supports what you want with their Auto Exclude List.
One problem with an exclude list is that it cannot work with merges: you must commit all files when you merge and so you'll have to do a little dance with shelve, merge, commit, and unshelve.
When you do a TortoiseHG commit, there is a list of files with checkboxes by them. Deselect the files you do not want comitted.
Or, on the command line, do a commit of the form hg commit --exclude "pattern", where pattern is defined in the hg man page.
You could always use hg forget.

How do I change the template .hgignore used for new repositories?

When I create a new repository, I can ask TortoiseHG to give me a .hgignore file. Is there a way that I can customise what that file will look like, rather than having to go and get one manually from somewhere every time?
It's an old question, put still popped up as the first result on google, so here is an update:
In the TortoiseHg settings under the tab TortoiseHg users can specify the path of a Repo Skeleton. You can put your predefined .hgignore there, and it will be automatically copied during hg init.
See also:
#3569 Allow user-defined default .hgignore file when creating a new repository
TortoiseHG Docs
Like Tim already said in his comment, apparently it's not possible to do this.
Take a look at the following issue from TortoiseHG's bug tracker:
#966 Include some reasonable defaults in .hgignore on repo creation
Quotes from this link, both by Steve Borho (THG project lead):
This topic comes up on the Mercurial mailing list once a year or so and Matt always shoots it down. There is already support for user level ignore files; one could add these globs to a global file and be done with it.
and:
If a user has files or directories that they always want to ignore, they can add those to a global ignore file without having to introduce any new behaviors in THG.
So putting the things you always want ignored in a user-global ignore file seems to be the only option (even though it's not exactly what you're asking for):
Would like to create some defaults for my .hgignore files in TortoiseHG/Mercurial
(the question that I posted in my comment above)
Global hgignore usage