Mercurial ignore all files except specific file names
سؤال
I have a large file system in which almost every folder has a file called content.txt
I want to track every file named content.txt and automatically ignore everything else. I want the repo to automatically track new files named content.txt so I don't want to ignore everything in the .hgignore and then manually add.
Anyone know how to do this?
المحلول
- It has to be regexp mode, not glob
- You must debug
path-part of regexp, but "all except content.txt" draft isre:.*\.(?!content.txt)
as hope
Alternative solution can be
* ignore all
* add content.txt files pattern to commit command (-I option), see hg help commit
and hg help patterns
hg commit -I '**content.txt'
Edit
re:.*/(?!content.txt)
نصائح أخرى
Try this:
syntax: regexp
\.(?!txt$)[^.]+$ # "*." is followed by "txt" and we're at the end
(?<!\.)txt$ # "txt" follows a "."
(?<!/)content\. # "content." follows path separator
(?<!content)\. # "." follows "content"
I left in the comments I made while experimenting, to make sense of it all. (That's glob syntax in the first one.)
لا تنتمي إلى StackOverflow