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.
Related
I have a folder for Octave M-files in C:\\Users\Dropbox\Octave, under which are various subfolders by function categories (normal distribution, chisq...). I just started making those subfolders and they will keep changing (adding, removing, reshuffling) as time goes on.
I would just like to set that folder as root and have Octave search for functions recursively there, just like you set a classpath in Java and JVM searches all folders there.
I used addpath(genpath('C:\\Users\Dropbox\Octave')), but the paths generated are then fixed, not reflecting subsequent subfolder changes.
Shall I add addpath(genpath('C:\\Users\Dropbox\Octave')) to the .octaverc file?
I think there is some confusion here. There are several ways to interact with the path, but for the most part these do not result in permanent changes, unless you save this somehow.
Simply adding a path for an existing octave session will not result in any permanent changes to the usual path that octave initialises at startup. Therefore when you say:
I used addpath(genpath('C:\Users\Dropbox\Octave')), but the paths generated are then fixed, not reflecting subsequent subfolder changes.
this makes no sense, because as soon as you exit your octave session, those added paths should have been gone altogether, and not appear in later octave sessions.
It is more likely that at some point you added these paths, and then used the savepath command, which resulted in your custom paths being added to your .octaverc file.
If that is the case, then yes, you can expect that octave will not "update" what was written in your .octaverc file, unless you call savepath again with an updated path definition.
If you would like the addpath(genpath('C:\Users\Dropbox\Octave')) command you mentioned to be called every time octave starts, so that the current/updated directory structure is loaded, then yes, the best way to do it would be to add that command to your .octaverc file. Make sure you remove the lines in your .octaverc that refer to the previous changes made by savepath. Note that there may be several levels of octaverc files that you need to check (see the relevant page in the manual)
Alternatively, you could simply make sure that this line appears in every script you want to call which intends to make use of those files.
While you may consider this last approach tedious, programmatically it is the most recommended one, since it makes dependencies clear in your code. This is especially important if you ever plan to share your code (and doubly so if you'd like it to be matlab compatible).
PS. All the above mostly applies to matlab too, with the exception that a) matlab's savepath saves path information in a file called pathdef.m, rather than directly in your startup files, and b) matlab uses startup.m instead of .octaverc as startup files. Also, if you don't care about doing this programmatically, matlab provides pathtool, which is a graphical interface for adding / saving directories to the matlab path.
How to gitignore extension-less files without breaking a global gitignore?
This is not a duplicate of How do I add files without dots in them (all extension-less files) to the gitignore file? or gitignore without binary files or similar questions, since none of them addressed the constraint that I want to honor my global gitignore.
Example:
# in $XDG_CONFIG_HOME/git/gitignore
foo.bar
# in /pathto/somegitrepo/.gitignore
*
!/**/
!*.*
With this pattern (that gitignores extension less files such as posix binaries), the global gitignore is effectively rendered useless, so this is not an acceptable solution.
I'm also not interested in workarounds (eg listing all extension-less paths explicitly or using a script to generate the gitignore file or requiring all your binaries to be in some folder).
Note: see also https://public-inbox.org/git/CANri+Ey2o-P+3S9iu1xj5YQooqBxo5Lvom0HdiQDAkSVTRv86A#mail.gmail.com/T/#u for what I'd like gitignore syntax to allow.
we are working on a project, where the angularjs web project is compiled and binaries are stored in hg repo. The problem is angularjs js files are usually compiled with hashing for all binary files. Ex: binary files are suffixed with unique extensions for each file
main.1cc794c25c00388d81bb.js,
polyfills.eda7b2736c9951cdce19.js,
runtime.a2aefc53e5f0bce023ee.js,
common.7d1522841bf85b01f2e6.js,
1.620807da7415abaeeb47.js,
2.93e8bd3b179a0199a6a3.....etc.
The problem is every time a new binary in checkin in hg repo, it is being detected as new file and retained along with old file of same name. So, i need a way to fool the hg repo, to retain the file name but still consider them as old file replacing the previous one.
main.1cc794c25c00388d81bb.js ==> overwrite old main.js
polyfills.eda7b2736c9951cdce19.js ==> overwrite old polyfill.js
runtime.a2aefc53e5f0bce023ee.js ==> overwrite old polyfill.js
common.7d1522841bf85b01f2e6.js ==> overwrite old commom.js
1.620807da7415abaeeb47.js ==> overwrite old 1.js
2.93e8bd3b179a0199a6a3 ==> overwrite old 2.js
Could any one point out a way, to fool the hg to consider these files are just modification of previous files and not as new files ?
Can hgignore or some other extension be used...
A VCS shall track the state of files. And those are indeed new files. One can argue that those are the old files renamed - which can be recorded by the VCS.
So there are two solutions I see:
Record moving the old filenames to the new filenames. hg addremove --similarity XX might be of big help here. It will result in all the files having the new names each time - but if the similarity is good enough it will work nicely. You might need to adjust the XX to get a similarity measure (0 ... 100) which works for you best. Adding --dry-run for testing purposes might make testing easy. You WILL need to delete the old files before you run hg addremove though.
Have a pre-commit hook which iterates over *.js files and moves via an appropriate regex ..js to *.js omitting the hashing code, effectively overwriting the generic filenames with the newly generated hashed filenames.
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.
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.