Why is Mercurial ignoring some of my files? - mercurial

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 $.

Related

Why don't mercurial file sets work when adding files?

I'm trying to use mercurial file sets to add all the files in a directory tree, excluding very large files and any binary files. Cribbing from the mercurial documentation, this command should do it:
hg init
hg add 'set: size("<1M") and not binary()'
However this returns a status code of 0, and hasn't added anything to my new, empty repo. I've tried just 'set: not binary()' and that didn't work either.
The frustrating thing is that although I can google for mercurial file sets, and find lots of examples, I can't find anything to help troubleshoot when it doesn't work!
I don't have a .hgignore file, and it's a fresh empty repo. Mercurial 4.2.2.
The directory where I'm testing this has a couple of artificially created files for the purpose of testing. In my real use case, I inherit a multi-gigbyte tarball of assorted sources and binaries from a client, and I want to get all the sources into mercurial before I start hacking to fix their problems, hence the need to exclude the binaries and large files that otherwise choke mercurial.
Here's my little test script:
#!/bin/sh -ex
dd if=/dev/urandom of=binary_1k bs=1 count=1024
dd if=/dev/urandom of=binary_2M bs=1 count=2097152
echo "This. Is, a SMALL text file." > text_small
hexdump binary_1k > text_1k
hexdump binary_2M > text_2M
ls -lh
file binary_1k
file binary_2M
file text_1k
file text_2M
hg init
hg add 'set: size("<1M") and not binary()'
hg status -a
hg add 'set: not binary()'
hg status -a
hg add 'set: size("<1M")'
hg status -a
At the end of this, each status command reports no files in the repo, and the add commands report no errors.
The problem is that file sets do a query of Mercurial's repository data base, which knows only about files that are part of the repository or have been added.
One solution is to add all, and then to get rid of the files that you don't like, e.g.:
hg forget 'set:size(">1M") or binary()'
This works, because the query also requires recently added files, even if they haven't been committed yet.

How to edit Mercurial .hgignore to permanently ignore all bin and obj folders?

I am using BitBucket with SourceTree on my home computer and on my laptop.
When I commit on one computer, the bin and obj folders are ignored.
When I commit on the other computer, changes to files in the bin and obj folders display.
The .hgignore file is under source control so I don't understand why it does not behave the same on both computers.
Both computers run VS2015 Update 1 and SourceTree 1.7.32059
The repositories do have different folder names.
The .hgignore file on my home computer is (trimmed down)
syntax: glob
MyAppDocuments
SBD.MyApp.Web\MyAppdocs
*.nupkg
Why does this not work the same way on my laptop?
Apparently Sourcetree supports both the usual .hgignore file in the Mercurial repository and a global .hgignore which is stored in C:\users\<username>\.hgignore_global.
It sounds like you've got the bin and obj folders added to the global ignore on one computer, but not on the other.
Really the bin and obj entries should be in the .hgignore in your repository. If you can locate the global ignore file you might be able to copy the required entries from there into your repository .hgignore file.
Information taken from this question on Atlassian support.

hg convert with filemap giving empty repository

I have got a new repository converted from SVN. I want to minimize this repository further by removing unintended files.
For that I am again converting the mercurial repository to a new one by using hg convert and the filemap parameter.
So my filemap looks like this:
include a
rename a .
The command I am using is:
hg convert --filemap fm.txt . ../new_repo
This ends after full conversion as I can see in the console output.
But if I now check the content of the directory new repo, I can see only .hg files in there.
I ran hg update -C within the directory whic gives me one more file .hgtags
Can anyone please suggest what has gone wrong?
This answer was spot on: you don't actually create an empty directory, but a directory with a hidden .hg directory. If you run
hg update
in your target directory, you will have your target directory with all its contents as expected.
In common, you done all correct (if directory a exist in source repo)
In my test for repository with directory lang, which I want to move into the root of new repo, I used filemap
include lang
rename lang .
identical to your filemap and got bare repository after converting (no files in Working Dir, only repository on .hg). Testing repository
hg log
changeset: 19:41e96453fa67
tag: tip
...
changeset: 0:ba52ea5c5c1f
showed me all related hisory
hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(without -C) brings all files into the Working Directory
SR>dir /B
.hg
UTF-8

mercurial ignore .zip files in whole repository

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.

How do I hide file extensions from showing up by default in TortoiseHg commit?

I'm using TortoiseHg to commit files to my repository; however, it shows all the .pyc files by default. Is it possible to exclude these files from being shown?
You can have Mercurial ignore those files by writing something like the following in your .hgignore file (which should be placed at the same level as your .hg directory):
# use glob syntax.
syntax: glob
*.pyc
After doing that you'll want to remove the existing .pyc files (using the hg rem command).