To ignore ./node_modules/ folder and .idea folder into .hgignore file so that I don't want to track them.
Currently I have the following rules on my .hgignore file.
*.orig
*./node_module/
*.idea/
*.rej
*~
*.o
tests/*.err
But abort error on hg status.
Well, hg help hgignore points to have a look at hg help patterns. I can't quite explain it better:
Mercurial accepts several notations for identifying one or more files at a
time.
By default, Mercurial treats filenames as shell-style extended glob
patterns.
Alternate pattern notations must be specified explicitly.
Note:
Patterns specified in ".hgignore" are not rooted. Please see 'hg help
hgignore' for details.
To use a plain path name without any pattern matching, start it with
"path:". These path names must completely match starting at the current
repository root.
To use an extended glob, start a name with "glob:". Globs are rooted at
the current directory; a glob such as "*.c" will only match files in the
current directory ending with ".c".
The supported glob syntax extensions are "**" to match any string across
path separators and "{a,b}" to mean "a or b".
(...)
Plain examples:
path:foo/bar a name bar in a directory named foo in the root
of the repository
path:path:name a file or directory named "path:name"
There are alternate ways to specify paths using regex as well as also explained in the available command line help.
So, use something like
node_module/**
.idea/**
or
path:node_module
path:.idea
provided you quoted your entire .hgignore and thus use the default glob pattern matching.
finally i found tip . here is how to .
Foradding node_modules/ and .idea/ folder you need to specify the following.N.B > is refers terminal.
touch .hgignore
nano .hgignore
add the following
^node_modules/
^.idea/
Done !
Related
I'm trying to convert a gitignore.io file to mercurial using syntax: glob at the top of the file and renamed it as .hgignore. The problem is that patterns starting with / like /vendor/ don't work.
Does Mercurial ignore file doesn't work with patterns starting with /?
I have searched in the documentation of mercurial but I can't find something specific about starting a glob with /, only about how to make rooted patterns with rootglob.
For now, I have removed manually all starting patterns with / as a workaround.
I have a repository with one file (subdir/a.txt), and the one revision, adding it.
If I run hg convert with a filemap consisting of include subdir/a.txt, it works just fine.
But if the filemap is include subdir/*.txt, include */a.txt, or include **/*.txt, the resultant repository has no revisions in it.
Is it possible do use wildcards in the filemap of hg convert?
--
The reason I want to do this is so that I can create a new repository with history, but without any binary files. I want to be able to do something like exclude **/*.dll. Is there any way to do that?
Wildcards do not seem to be supported, but you can use hg manifest --all to get a list of all files present in all changesets, and do some filtering and editing of the output to generate what to exclude. Something like the following to list all the DLL file paths on Windows:
hg manifest --all | findstr \.dll
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.
I have a working directory structure like the below one :
mercurial_working_dir:
project1
project2
project3
Under each project folder there are common folders that i want to untrack from mercurial.e.g:
i dont want any file to be tracked under /metadata folder which is common at the 3 projects.
As far as i know i should use hg remove -Af command with the specifing files.Is there any way to define regular exps at the command in order to recursively "remove" the current version of any file under the metadata folder which is placed at all my projects?
Take a look at the chapter about file names and pattern matching in the mercurial book. You can use a pattern like this:
hg rm "glob:**/metadata/**"
If you prefer regular expressions, you can also use the re: prefix instead of glob:.
There's a particular file in my repository, libraries/database.php, that I need ignored. However, I can't get the syntax to recognize the file - I've tried **/libraries/**/database.php and libraries/database.php in glob, and ^.libraries/database.php in regex, but neither of them work. What should I do?
After hours of following all the suggestions here and others found on the web, I found out that I was always doing it right in .hgignore, but .hgignore will not ignore files that are currently being tracked by mercurial.
You must do
hg forget mydir/myfile.ext
Or adding the file to .hgignore doesn't take affect.
syntax: glob
mydir/myfile.ext
Then the above will work.
syntax: re
^libraries/database\.php$
That will work.
But, frankly, I've always found the .hgignore syntax to be a little obscure myself. I don't really understand what glob will and won't match.
From the mercurial QuickStart guide:
"Mercurial will look for a file named .hgignore in the root of your repository which contains a set of glob patterns and regular expressions to ignore in file paths"
is your .hgignore at the right place ?
So
syntax: glob
libraries/database.php
should work.