In my project's .hgignore, I want to exclude /static/ (i.e., the static folder at the root of the directory), but not /templates/static/. How would I configure .hgignore to allow this?
You can include syntax: regexp at the beginning of .hgignore and then use perl regex syntax to root a directory by using ^. So just ^static should do the work.
As of Mercurial 4.9, you can use syntax: rootglob to insert rooted glob patterns.
New rootglob: filename pattern for a glob that is rooted at the root of the repository. See hg help patterns and hg help hgignore for details
Related
I have a project with following structure
project_dir/
WebContent/
es5/
...
src/
...
.hgignore
I'm tring to ignore everithing under WebContent/es5 directory using following patterns:
syntax: glob
WebContent/es5/**
or
syntax: regexp
^WebContent/es5
or
syntax: regexp
^WebContent/es5$
but modified files in the folder are still being tracked. Could anybody please help me with it?
The clue is in the documentation for ignore files:
The Mercurial system uses a file called .hgignore in the root
directory of a repository to control its behavior when it searches for
files that it is not currently tracking.
If you've added a file in a subdirectory to the repo (either explicitly or before you added the pattern to the .hgignore file) mercurial will remember it until you hg forget it.
% hg init foo
% cd foo
% ls
% mkdir sub
% cat <<EOF > .hgignore
^sub/
EOF
% touch a
% touch sub/b sub/c
% hg st
? .hgignore
? a
% hg add sub/b
% hg st
A sub/b
? .hgignore
? a
% hg forget sub
removing sub/b
% hg st
? .hgignore
? a
There's an example given in the documentation on how to forget all files which are excluded by .hgignore:
- forget files that would be excluded by .hgignore:
hg forget "set:hgignore()"
I have a pretty large folder (with many sub folders) on a mercurial repository. I was a bit too fast with my first commit so I added a lot of files that i now realize shouldn't be on version control. I've updated my .hgignore file accordingly but all the old files are still version controlled. Is there a command that I can write in the root directory that forgets all files that are in a folder of a specific name. These folder names exist in a lot of places and i want them all forgotten with one command since it would take a long time to go through them all manually and forget the folders/files
I guess it would maybe look something like this:
hg ignore ../folderName/
Yes... use a pattern to match them like
hg forget FOLDERNAME**
hg commit -m "Forget FOLDERNAME"
hg help forget
hg forget [OPTION]... FILE...
(...)
options ([+] can be repeated):
-I --include PATTERN [+] include names matching the given patterns
or use a one-line script:
for i in $(hg ma | grep FOLDERNAME); do hg forget $i; done
You can read hg help filesets and use one of it's samples
Forget files that are in .hgignore but are already tracked:
hg forget "set:hgignore() and not ignored()"
How can I list all files in a repository that were committed (explicitly), although they were ignored because of the .hgignore file
.hgignore uses glob syntax
running on Windows
it's not necessary to take any global .hgignore file into account
My idea:
hg manifest > filter using the content of .hgignore > result
You have to learn and use filesets in this case
List files that are in .hgignore but are already tracked:
hg locate "set:hgignore() and not ignored()"
i am using Mercurial for version controlling. I am trying to ignore zip files in the repository, my hgignore file is in the root directory of project
i got the codes below from http://www.selenic.com/mercurial/hg.1.html#patterns.
syntax: glob
**.zip
syntax: regexp
re:.*\.zip$
But these doesnt work for me.
i also tried
hg addremove
and
hg forget -I '*'
but it didnt help. Can you tell me how can properly ignore zip files from the repository?
Thanks for help.
EDIT
My problem was the zip files were already added to repository. I first forgot them and committed. Now it ignores
Simply writing *.zip inside .hgignore will do this. The patterns inside .hgignore are not rooted, so *.zip would match a zip archive no matter where it appears.
Maybe a a silly question, but my googles don't work. Doing the following on my repository root:
$ hg archive my_archive.tar.gz
Gives me a tar.gz file with an inner directory named my_archive, then inside my repo contents.
I understand this is meant by hg arhives's help:
Each member added to an archive file has a directory prefix prepended.
Use -p/--prefix to specify a format string for the prefix. The
default is the basename of the archive, with suffixes removed.
But it boggles my deployment workflow. I need it without the inner dir.
Is that possible?
Specify the prefix as the current directory:
hg archive -p . my_archive.tar.gz