mercurial ignore .zip files in whole repository - mercurial

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.

Related

Why is Mercurial ignoring some of my files?

Having run 'hg init' and 'hg add' to create a new Mercurial repository and add the files, I find that quite a few of the files are not being tracked (they show up with 'hg status -i'), yet do not seem to match any pattern in my .hgignore file, so I don't see what the issue is. Here's the .hgignore file:
# Eclipse project files
.classpath
.project
.settings/
# IntelliJ project files
\.iml
\.ipr
\.iws
.idea/
out
# Grails files and dirs that should not be versioned
target
web-app/WEB-INF/classes
web-app/WEB-INF/tld/c.tld
web-app/WEB-INF/tld/fmt.tld
stacktrace.log
plugin.xml
devDb.*
prodDb.*
# Mac OS/X finder files
.DS_Store
oldhg/
All files in e.g., '/grails-app/views/layouts' are ignored, and yet I can see nothing in the .hgignore file which would cause this. What am I missing? How can I force these files not to be ignored?
The string out matches anything containing that, including layouts/. If you want it to only match at the beginning or end of a name, you need to anchor it with ^ or $.

Find committed files that should have been 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()"

Why is .hgignore being ignored?

I am very new to Hg so please excuse my ignorance here...
I am using Mercurial and TortoiseHg in Windows 7. I have a repository created that has the following folder structure:
-- My repo dir
|
|--- .hg
|--- .hgignore
|--- File 1
|--- File 2
|--- ...
My database data files live in the repo directory but I do not want them to be included as part of the repository. I've tried all kinds of things in the .hgignore file, but regardless when I right-click on the repo folder in the Windows Shell and go to Hg Commit..., it includes the two database data files in the list of files to be committed. Yes, I can uncheck them manually, but my thought was that by being in .hgignore they wouldn't be included in the list of files to commit.
Here's my current incarnation of .hgignore, although I've tried a handful of others with no luck:
MyDatabase\.mdf
MyDatabase\_log\.ldf
Am I being daft here, or is it that TortoiseHg does not respect/inspect the .hgignore file when committing?
UPDATE:
Finally got this to work. I had to instruct Mercurial to forget the files, as #Diego suggested. Interestingly, though, when I followed #Diego's suggestions and tried to forget them via the command-line it did not work. I had to go to Windows Explorer, right-click on the files, and from the context menu I chose TortoiseHg --> Forget Files...
Thanks for the suggestions, everyone.
Maybe mercurial is already tracking those files. If files are already tracked then .hgignore does not have any effect. Try:
hg forget MyDatabase\.mdf MyDatabase\_log\.ldf
Then edit .hgignore to exclude those files and commit.
That should solve it.
You need to add this line at the beginning of your .hgignore file:
syntax: glob
MyDatabase\.mdf
MyDatabase\_log\.ldf
Scott,
Do you have any other mdf/ldf files that you want to add to the repository? If not, could you just try the following in your .hgignore file?
syntax: glob
*.mdf
*.ldf

Would like to do a mercurial clone with filter of patterns in hgignore

Over time a number of the developers have committed files that were then added to the .hgignore. From what I hear there is no way to remove items from the history of mercurial, which is ok. But I also heard that there is a way to do a clone, I think using the convert plugin, to clone/export a repo while specifying which files to not include in the conversion.
I can't help but think that someone out there has a script that does this export/filter/convert using the patterns from the .hgignore file.
Has anyone created such a beast?
You could create a filemap from .hgignore doing something like this:
hg clone -U yourrepo temprepo # create a temp repo with no files in working dir
cd tmprepo
hg revert --all # put files in working dir
hg forget ** # un-add the files
hg status --ignored --no-status | sed 's/^/exclude /' > ../filemap
that will get you a filemap you can pass into hg convert that removes all the added files that would be ignored given your .hgignore.
Do understand though, that running convert creates a whole new repo that is unrelated to your previous repo. All existing clones will be unusable with the new one. It's not normally worth it.
hg convert is indeed the thing you want to use.
You will want to create a file map (just a text file) which will list all of the things you either want to include, exclude, or rename:
include subfolder
exclude subfolder/supersub
etc...
Read the following for a more concrete example:
https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap
Once you have created this file you will just use the following command:
$ hg convert --filemap my_file_map /path/to/source/repo /path/to/dest/repo
The source repo will not be modified and a dest repo will be created. I don't want to just copy verbatim what the documentation already says so here is the link:
How to keep just a subdirectory (or run on the mercurial repo):
https://www.mercurial-scm.org/wiki/ConvertExtension#Converting_from_Mercurial

For Mercurial (Hg), why the file .hgignore cannot be ignored?

I have these in the proj/.hgignore:
syntax: glob
log/*
*~
*.orig
dump/*
*.hgignore
.hgignore
tmp/*
but for some reason, when I do an hg st or hg com, the file .hgignore still shows up to be modified or to be committed. So the .hgignore cannot be ignored? There might be particulars in my folder that my team didn't want to ignore but I do. So I don't want to commit this file.
Chris has it in the comment: you've probably already added your .hgignore file, and an add overrides the .hgignore. You need to hg forget .hgignore and hg commit and then you'll find your file is ignored.
Thats said, most people put the .hgignore file into the repo for a reason -- so that the next person to clone doesn't accidentally commit all of their log/temporary files.
I think you're looking for this:
https://www.mercurial-scm.org/wiki/TipsAndTricks#Ignore_files_in_local_working_copy_only
The overall .hgignore file is necessary to ignore anything, and so you can't exclude it.