is it possible to use .hgignore in mercurial to ignore header files generated from idl files?
I have a very large project in VS2008 and, by default, the midl tool generates .h files from .idl files in the same folder and with the same name. Naturally, I do not want the generated files controlled. Is it possible to configure mercurial to ignore a xxx.h file if there is xxx.idl file in the same folder?
Is there any other solution to my problem? Renaming the files for those ~100 projects would take ages and is not really an option I want to consider...
As stevevls pointed out you can just ignore all .h files and then manually add the .h files you do want tracked (hg add overrides ignores).
Another option would be to put something like this in your .hg/hgrc
[ui]
ignore.generated = .hgignore-generated
and then create that file either manually or with a hook so that it lists all the generated .h files. The file could be tracked or untracked at your option. On unix this would auto create that file:
find . -name '*.idl' | sed 's/\.idl$/.h/ >| .hgignore-generated
I've no idea how to script that on windows, but one imagines powershell can do it.
Yes, this is possible. .hgignore is very flexible and accepts globs and regexes. You could probably get away with :
syntax:glob
*.h
See here for more details: http://www.selenic.com/mercurial/hgignore.5.html.
Related
In my mercurial repository I have a lot of different files. For example .org and .tex files. Exporting the .org file generates a .tex file. Normally I do not want to ignore .tex files since these are usually source files. But I am looking for something like:
foo.org present => ignore foo.tex
foo.org absent => do not ignore foo.tex
There is no such option available in Mercurial.
What you could do is create an extension of your own to make some kind of 'hg customstatus' command available. This could be a wrapper around the 'hg status' command that executes the filtering you want.
Dumb thing, we are changing our code standard that all C++ header files need to be ".hpp" instead of ".h" (leaving .h to be C compatible headers). So my library only has *.h files in it. Is there a quick way built in to mercurial to do this rename or do I need to write my own script?
Mercurial has a way to do it if you want to rename them in all revisions back to the start of time (and thus change history and invalidate any clones), but since you probably don't want do do that you can just do:
for thefile in $(find $(hg root) -name '*.h') ; do hg rename $thefile ${thefile}pp ; done
We are using Mercurial for keeping track of a number of linguistic papers. We want to keep our source files in Mercurial. The source files are mostly in XML, but the output file is in PDF. Therefore, we have added glob:*.pdf to our .hgignore file. Among our source files, we also have graphic files with extensions like .jpg, .png, and .svg. Recently, we've also added .pdf files as graphic files. Naturally, these PDF graphic files are not showing up when we do a hg status command.
So my question is this: is there a way to create a .hgignore pattern that will ignore *.pdf files in most directories but still show *.pdf in specified directories (directories where we store our graphic files)?
There's a good example which does nearly what you want in the Mercurial wiki.
Quote from the link:
/target/.*\.o$
This would match all files ending with .o below (within and in subdirectories at any depth of) the target directory.
If the number of directories where you want to ignore PDF files is somewhat limited (and not: "ignore *.pdf in all directories but this one"), you can use this solution.
In my mercurial.ini file, I call a global hgignore file like this:
[ui]
ignore = ~/hgignore.ini
This refers to a hgignore.ini file which is in the same directory as the mercurial.ini file.
Does the local hgignore override the global hgignore?
If so, is it recommended to have a single global hgignore with relevant sections marked or have a global hgignore file for general patterns and individual local hgignore files for special patterns pertaining to the particular repo?
By global hgignore with relevant sections marked, I mean:
syntax: glob
# VISUAL STUDIO
*.obj
*.pdb
*.suo
[Bb]in
[Dd]ebug*/
[Rr]elease*/
# TEMPORARY FILES
*.log
*.bak
*.cache
The global .hgignore is "added" to the local one. This means that everything in the global one will be considered for each repository, but the content of the local one will also be considered.
For the second question, I think the best answer is : it depends on what you want ;)
If you want a really fine grained control on what is ignored for each repository, go for the local version.
If you want to don't be bothered each time you create a repo, add everything to the global file.
Anything in between to suits your needs...
In my case, I use both of them. The global .hgignore contains project files (Visual Studio, Netbeans), backup files (.bak, vim), libraries (dll, so, etc). And for each project, I put whatever is specific in the local file.
I want Mercurial to ignore any file with a certain extension.
For example, I wanted to ignore files with a .SUO extension. (There's no need to version-control Visual Studio user settings.)
So I changed my .hgignore file to this:
syntax: glob
*.suo
However, this has no effect, and Mercurial still sees my .suo file.
What am I doing wrong here?
If, when running hg status before altering your .hgignore file, the .suo file had a ? in front of it, then it should be ignored now. If anything else (M or A for example) it is already tracked by the repository and will not magically stop being tracked. In such a case you'll need to do hg remove on the file to delete it and have hg stop tracking it, or just do hg forget on it to have hg stop tracking it but keep the file. Either should be followed by a commit.
The only files that will be omitted from the status listing if their path matches a pattern in the .hgignore file are files that are not tracked. It would make no sense to omit a file that is tracked, because you would never see whether it had been modified, added, or removed.
Edit: Mercurial does only track files (you can't make it track empty directories), but the patterns in .hgignore are simply run against strings of the file paths relative to the root of the repository. The very same relative paths that it shows you when you run hg status. So it does work how you say you want it to work because the following lines are a standard part of my own .hgignore files:
syntax: glob
*\obj\*
*\bin\*
*.csproj.user
*.suo
Again, when you run hg status and it shows a .suo file, what single character is at the beginning of that line? Is it a M, A, R, ! or ? character? What is the path after it?
Mercurial uses entries in a file called .hgignore to determine what files it completely ignores. It is normally located in the root file for your repository (and not in the .hg directory, which you might think).
You can find out more here:
http://www.selenic.com/mercurial/hgignore.5.html
Normally, we use regular expression syntax to ensure that case is not a factor in extensions:
# use regexp syntax.
syntax: regexp
(?i)\.dcu
(?i)\.identcache
(?i)\.dof
(?i)\.dsk
(?i)\.bak
(?i)\.old
That way, it ensures that even if for some reason the case of the extension changes, it is still ignored.
Example for ignoring/excluding files with .o extension:
.*\.o$
should translate to .*\.suo$ for .suo extensions.
I have used this method successfully
Check where .hgignore file is located and ensure it is either in $HOME or project root folder. Check the CASE (vs case) of the extension. I doubt if pattern matching is case insensitive.
edit: tested, the pattern matching is NOT case sensitive. Hence, add "*.SUO" if you want to ignore files with ".SUO" extension.