.hgignore files inside folder but not the folder - mercurial

How can I ignore the files inside the folder but keeping the folder in mercurial?
I tried in this way but also folder is ignored.
syntax: glob
photos/*.jpg
photos/*.gif
photos/thumbs/*.jpg
photos/thumbs/*.gif
Thanks

Create an empty file named .keep in the folder and add it to your repository.
touch photos/.keep
hg add photos/.keep
This way the folder will be still tracked, even if its contents and the folder itself are in .hgignore.

Related

Cannot use filter pattern for largefiles extension for hg

My hgrc config files is as follow:
[extensions] largefiles =
[largefiles] patterns = *.jpg *.png *.bmp *.gif *.mp3 *.a *.jar *.psd
*.ai *.unity *.ttf *.zip *.rar
I tested by created a file a.jpg ,hg add --large a.jpg, file has been created in .hglf correctly. I created b.jpg,hg add b.jpg, file has been created in .hglf correctly as well.
If I do not hg add --large a.jpg first, this will be failed for some
reason.
Next, I created subdirectory, created c.jpg file in there,hg add c.jpg, nothing created in .hglf. This make the filter pattern not work anymore after it's in subdirectory. What should I do to be able to "hg add *" for all file in repo and it filter correctly for which one is text file, which one is binary file as config in .hgrc config file.
I suppose, you have to re-read hg help patterns
*.c any name ending in ".c" in the current directory
**.c any name ending in ".c" in any subdirectory of the
current directory including itself.
and fix your patterns

Mercurial commit with subrepositories in subfolders

I have file/directory structure:
main/.hg
main/subrepo/.hg
main/subrepo1/.hg
I have .hgignore file with such content
.hg
Finally, I want to make a commit in 'main' repository that will include all files in it, including all files from main/subrepo and main/subrepo1 and excluding folders main/subrepo/.hg and main/subrepo1/.hg (so all files from main folder, excluding .hg folders in it will be commited). But Mercurial skips main/subrepo/* and main/subrepo1/*. It does not include this subfolders/subrepos to commit fully. How can I fix this?
I'm going to guess that you have simply created some nested repositories, but not properly linked them as subrepositories.
Make sure that the root of the main repository has a file called .hgsub. You create the file, add the following and then add + commit the file to the main repository:
subrepo = https://path-to-subrepo/
subrepo1 = https://path-to-subrepo1
If the subrepos do not point to some remote server, you would use the local path of course.

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

There is no .hgignore file after I do an initial hginit command

I've created my very first Mercurial repo on my machine. I used the hg init command on the directory.
Now I'm trying to use this ignore file, before uploading to BitBucket:
Mercurial .hgignore for Visual Studio 2008 projects
Where would I post Even Mien's configuration file? I can't find an hgignore file anywhere.
Thanks
Just make one in the top-level directory of the repository (the same place where the .hg folder is).
Just create a new text file named .hgignore at the root folder of your project and paste the content into it.

How to branch the whole repository including ignore files

I have a project, which is in the Mercurial repository. In the root folder there is a .hgignore file, which states, that the "Bin" folder should be ignored (and also some other files and folders).
Now I want to clone this repository but in a way, that ALL folders and files should be cloned, also the original ignored ones. If I just clone the repository, than I get only the files, which are included in the repository thus my bin folder is missing.
How can I get cloned repository with all files in it? I want to merge these two repositories together in a while...
PS - I am working on a legacy application which has a lot of external dll-s in the bin folder of the application. I know I should put them to a seperate folder, but that's another story.
Just copy it.
Copy the whole tree from point a to point b, and the new copy will function perfectly as a repository. The only thing that would be different from a clone is the lack of hardlinks and that the default pull/push path will be set-up to be the same as the original, rather than pointing to the original. That's easy to change by editing .hg/hgrc if you want to.
An ignored file is not in your repository, so it will not be cloned. You should copy these files by hand after you have cloned the repository.
When you copy those files, I think it won't be a problem if you overwrite other files that are in your repository (they're essentially the same files after all), so as long as you don't copy the .hg folder in the root of your checkout, you'll probably be fine.