Mercurial Glob Syntax to Match Characters in File Name - mercurial

I'm have a time trying to figure out the syntax to ignore files that match a certain pattern, namely: Com.Example/Com.Example.DomainModel23012013101705.somefileextension. The variable seems to be the date that is munged into the file name (23012013101705)
I have tried [0-9].somefileextension and other patterns all to no avail.
Thank you,
Stephen

Ry4an, sadly, made mistake. Grep() doesn't work with filenames.
My "Proving Ground"
>dir /B
.hg
404.php
archive.php
archives.php
comments.php
footer.php
functions.php
header.php
html5.js
image.php
index.php
license.txt
links.php
page.php
readme.txt
screenshot.png
search.php
sidebar.php
single.php
style.css
Tests
>hg locate "set:grep(html5)\.php"
hg: parse error at 11: invalid token
>hg locate "set:grep(html5)"
header.php
readme.txt
Note: found files, which have text "html5" in it, but not file html5.js
>hg locate "set:s[a-z]+\.php"
abort: \.php not under root
>hg locate "set:s[a-z]+.php"
>hg locate "set:s[a-z]+"
hg: parse error at 7: not a prefix: end
>hg locate "set:s\w+"
hg: parse error at 4: not a prefix: end
All tests with set: prefix and regexps failed
Different glob-patterns with set:
>hg locate "set:s**.php"
search.php
sidebar.php
single.php
>hg locate "set:s**.*"
screenshot.png
search.php
sidebar.php
single.php
style.css
>hg locate "set:s**e.*"
single.php
style.css
Regexp-patterns in filesets
>hg locate "re:s[a-z]+.php"
search.php
sidebar.php
single.php
>hg locate "re:s[a-z]+."
screenshot.png
search.php
sidebar.php
single.php
style.css
Resume
hg forget "re:Com\.Example\.DomainModel[0-9]+\.somefileextension$"
or
hg forget "set:Com.Example.DomainModel**.somefileextension"
and the same set to hgignore

Use a regex not a glob. Mercurial support both wherever it supports either. In a .hgignore that would be:
syntax: regexp
[0-9]\.somefileextension
That regex matches your attempted glob, but you could, of course, narrow it more like:
syntax: regexp
^Com\.Example/Com\.Example\.DomainModel\d+\.somefileextension$

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

Mercurial how to ignore subfolder containing files already added to source control

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()"

Is there an hgignore.io?

I use git for school, but mercurial for work.
Is there an equivalent of gitignore.io for mercurial?
Though there does not seem to be an hgignore.io, you can use any ignore file generated by gitignore.io by simply placing syntax: glob on the first line.
.hgignore
syntax: glob
# Created by https://www.gitignore.io/api/java,eclipse,netbeans,intellij
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
...
More info about .hgignore files.

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()"

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