Folders not being added in Mercurial - mercurial

I looked at this question: ignoring folders in mercurial that mentions how to ignore a folder, but that's not what I need.
I'm using TortoiseHG and after I "add" all my folders, they show still as "?" instead of "+". The files within them show "+", but the folders themselves just show "?". Is this a problem with Mercurial on Windows XP? Or, is it a problem between my keyboard and my chair?

Mercurial adds only files in, and infers the folders from the actual file names. If you drop down to a command line and do hg status, you will see that folders are not listed at all. The files within the folder you added will be listed with the A tag, but the actual folders don't list in a hg status command.

You don't need to add the folders separately (in fact, Mercurial doesn't handle plain folders/directories at all). As long as your files are there, you're fine.

Related

How can i make mercurial to add wildcard for file name

we are working on a project, where the angularjs web project is compiled and binaries are stored in hg repo. The problem is angularjs js files are usually compiled with hashing for all binary files. Ex: binary files are suffixed with unique extensions for each file
main.1cc794c25c00388d81bb.js,
polyfills.eda7b2736c9951cdce19.js,
runtime.a2aefc53e5f0bce023ee.js,
common.7d1522841bf85b01f2e6.js,
1.620807da7415abaeeb47.js,
2.93e8bd3b179a0199a6a3.....etc.
The problem is every time a new binary in checkin in hg repo, it is being detected as new file and retained along with old file of same name. So, i need a way to fool the hg repo, to retain the file name but still consider them as old file replacing the previous one.
main.1cc794c25c00388d81bb.js ==> overwrite old main.js
polyfills.eda7b2736c9951cdce19.js ==> overwrite old polyfill.js
runtime.a2aefc53e5f0bce023ee.js ==> overwrite old polyfill.js
common.7d1522841bf85b01f2e6.js ==> overwrite old commom.js
1.620807da7415abaeeb47.js ==> overwrite old 1.js
2.93e8bd3b179a0199a6a3 ==> overwrite old 2.js
Could any one point out a way, to fool the hg to consider these files are just modification of previous files and not as new files ?
Can hgignore or some other extension be used...
A VCS shall track the state of files. And those are indeed new files. One can argue that those are the old files renamed - which can be recorded by the VCS.
So there are two solutions I see:
Record moving the old filenames to the new filenames. hg addremove --similarity XX might be of big help here. It will result in all the files having the new names each time - but if the similarity is good enough it will work nicely. You might need to adjust the XX to get a similarity measure (0 ... 100) which works for you best. Adding --dry-run for testing purposes might make testing easy. You WILL need to delete the old files before you run hg addremove though.
Have a pre-commit hook which iterates over *.js files and moves via an appropriate regex ..js to *.js omitting the hashing code, effectively overwriting the generic filenames with the newly generated hashed filenames.

Mercurial .hgignore file: is it possible to hide extensions in some directories but not others?

We are using Mercurial for keeping track of a number of linguistic papers. We want to keep our source files in Mercurial. The source files are mostly in XML, but the output file is in PDF. Therefore, we have added glob:*.pdf to our .hgignore file. Among our source files, we also have graphic files with extensions like .jpg, .png, and .svg. Recently, we've also added .pdf files as graphic files. Naturally, these PDF graphic files are not showing up when we do a hg status command.
So my question is this: is there a way to create a .hgignore pattern that will ignore *.pdf files in most directories but still show *.pdf in specified directories (directories where we store our graphic files)?
There's a good example which does nearly what you want in the Mercurial wiki.
Quote from the link:
/target/.*\.o$
This would match all files ending with .o below (within and in subdirectories at any depth of) the target directory.
If the number of directories where you want to ignore PDF files is somewhat limited (and not: "ignore *.pdf in all directories but this one"), you can use this solution.

Create a new repo from sub folder in Mercurial Repo using convert

I am trying to extract a folder (call it Project1) from an existing Mercurial Repo (call in MainRepo) using the Convert extension for Mercurial to Mercurial conversion. I have followed the methods described by Mercurial developers (and elsewhere on the web) under Windows XP:
C:\MainRepo>echo include Project1 > ~myfilemap
C:\MainRepo>echo rename Project1 . >> ~myfilemap
C:\MainRepo>hg convert --filemap ~myfilemap . C:\Project1Repo
C:\MainRepo>cd \Project1Repo
C:\Project1Repo>hg update
This creates the new repo (Project1Repo) with the Mercurial folder/files in place.
But it does not:
1) Carry across the History relating to the changes made for the Project in folder Project1. (Only the very first history entry for MainRepo and a Convert item are present).
2) Copy across all the source code files from the MainRepo\Project1 to Project1Repo.
I have seen the other similar questions and answers in stackoverflow but these do not appear to help (I have followed methods discussed in them):
Can I clone part of a Mercurial repository?
So the question is: How do I extract a sub-folder from MainRepo with only the sub folder history intact and complete to a new Repo and transfer the source files at the same time? (though I guess a straight copy will do the last). It's keeping the history that is important - In this case I can make this after a date or Changeset number.
Any help much appreciated as I'm relatively new to this
Thanks
The workflow you listed is correct. That is the way the convert extension is intended to work.
Your question states that the repo output by hg convert is actually empty (except for "the very first history entry for MainRepo and a Convert item"). This would indicate that convert was not able to find the path specified in your filemap.
Are you certain that the path given your include statement is correct?
The directory name given in your include statement must be the full path from your repository root. For example, your include statement:
include Project1
requires that the path to Project1 actually be:
C:\MainRepo\Project1
If Project1 is actually located somewhere else in MainRepo, you will end up with an empty repo after the conversion.

mercurial: ignore .h generated from .idl

is it possible to use .hgignore in mercurial to ignore header files generated from idl files?
I have a very large project in VS2008 and, by default, the midl tool generates .h files from .idl files in the same folder and with the same name. Naturally, I do not want the generated files controlled. Is it possible to configure mercurial to ignore a xxx.h file if there is xxx.idl file in the same folder?
Is there any other solution to my problem? Renaming the files for those ~100 projects would take ages and is not really an option I want to consider...
As stevevls pointed out you can just ignore all .h files and then manually add the .h files you do want tracked (hg add overrides ignores).
Another option would be to put something like this in your .hg/hgrc
[ui]
ignore.generated = .hgignore-generated
and then create that file either manually or with a hook so that it lists all the generated .h files. The file could be tracked or untracked at your option. On unix this would auto create that file:
find . -name '*.idl' | sed 's/\.idl$/.h/ >| .hgignore-generated
I've no idea how to script that on windows, but one imagines powershell can do it.
Yes, this is possible. .hgignore is very flexible and accepts globs and regexes. You could probably get away with :
syntax:glob
*.h
See here for more details: http://www.selenic.com/mercurial/hgignore.5.html.

How do I make mercurial ignore any file with .xxx extension

I want Mercurial to ignore any file with a certain extension.
For example, I wanted to ignore files with a .SUO extension. (There's no need to version-control Visual Studio user settings.)
So I changed my .hgignore file to this:
syntax: glob
*.suo
However, this has no effect, and Mercurial still sees my .suo file.
What am I doing wrong here?
If, when running hg status before altering your .hgignore file, the .suo file had a ? in front of it, then it should be ignored now. If anything else (M or A for example) it is already tracked by the repository and will not magically stop being tracked. In such a case you'll need to do hg remove on the file to delete it and have hg stop tracking it, or just do hg forget on it to have hg stop tracking it but keep the file. Either should be followed by a commit.
The only files that will be omitted from the status listing if their path matches a pattern in the .hgignore file are files that are not tracked. It would make no sense to omit a file that is tracked, because you would never see whether it had been modified, added, or removed.
Edit: Mercurial does only track files (you can't make it track empty directories), but the patterns in .hgignore are simply run against strings of the file paths relative to the root of the repository. The very same relative paths that it shows you when you run hg status. So it does work how you say you want it to work because the following lines are a standard part of my own .hgignore files:
syntax: glob
*\obj\*
*\bin\*
*.csproj.user
*.suo
Again, when you run hg status and it shows a .suo file, what single character is at the beginning of that line? Is it a M, A, R, ! or ? character? What is the path after it?
Mercurial uses entries in a file called .hgignore to determine what files it completely ignores. It is normally located in the root file for your repository (and not in the .hg directory, which you might think).
You can find out more here:
http://www.selenic.com/mercurial/hgignore.5.html
Normally, we use regular expression syntax to ensure that case is not a factor in extensions:
# use regexp syntax.
syntax: regexp
(?i)\.dcu
(?i)\.identcache
(?i)\.dof
(?i)\.dsk
(?i)\.bak
(?i)\.old
That way, it ensures that even if for some reason the case of the extension changes, it is still ignored.
Example for ignoring/excluding files with .o extension:
.*\.o$
should translate to .*\.suo$ for .suo extensions.
I have used this method successfully
Check where .hgignore file is located and ensure it is either in $HOME or project root folder. Check the CASE (vs case) of the extension. I doubt if pattern matching is case insensitive.
edit: tested, the pattern matching is NOT case sensitive. Hence, add "*.SUO" if you want to ignore files with ".SUO" extension.