Reputation: 13323
I am using Mercurial under Linux. I would like to exclude all files containing the pattern *.pro.user*
from the version control system.
I tried to list all the files with:
find . -name "*.pro.user*"
This turned out also some results which are in the .hg
folder:
...
./.hg/store/data/_test_run_multiple/_test_run_multiple.pro.user.i
./.hg/store/data/_test_non_dominated_sorting/_test_sorting.pro.user.i
./Analyzer/AlgorithmAnalyzer.pro.user
./Analyzer/AlgorithmAnalyzer.pro.user.a6874dd
...
I then tried to pipe this result to the hg forget command like:
find . -name "*.pro.user*" | hg forget
but I get:
abort: no files specified
My guess is that the list needs to be processed in some way in order to be passed to hg forget
.
I would like to ask:
How can I pass the result of my find query into the hg forget
command?
Since the query result contains files in the "private" folder .hg
, is it a good idea? I hope that Mercurial will ignore that request, but shoud I remove those results somehow?
Upvotes: 1
Views: 118
Reputation: 59320
First of all, you can use find * -name "*.pro.user*"
to avoid looking in .hg
.
Mercurial's forget
command requires its arguments on the command line. So you need to use xargs
:
find * -name "*.pro.user*" | xargs hg forget
Alternatively you can ask find
to do the job:
find * -name "*.pro.user*" -exec hg forget {} \;
Finally, you should add *.pro.user*
to your .hgignore
file.
Upvotes: 2
Reputation: 7084
Try the following:
hg forget "set:**.pro.user*"
This tells Mercurial to forget any files that match the fileset **.pro.user*
. As the fileset is defined in Mercurial, it won't go into the .hg
directory. You can do even more with filesets by looking at: hg -v help filesets
The **
at the start means to work in subdirectories, rather than just the current directory.
Upvotes: 3