开发者

How to get mercurial to notice files added into subdirectories? (hg st, hg add)

开发者 https://www.devze.com 2023-02-02 03:21 出处:网络
If I add a new file into my project\'s root, it appears with a ? status in hg st, and gets added with hg add.

If I add a new file into my project's root, it appears with a ? status in hg st, and gets added with hg add.

However, if I add a new file into a subdirectory, it doesn't appear in hg st at all, and only gets added if I explicitly add the file (not even if I add the file's containing directory).

How can I get mercurial to notice files in subdirectories, in a similar way to how subversion开发者_如何学编程 notices them?

Thanks


Well, plain hg add without any extra arguments adds files in sub-directories as well, it basically adds all files with status unknown to be tracked.

However, if you specify a simple mask, it only operates on your current working directory (ie. the working directory of the hg command, not the working directory associated with the repository), so if you're currently situated in the sub-directory, it will add those files, if you're in the root directory, it will add those files instead.

In other words, this:

hg add test*

Only operates on files in the directory you're currently situated.

You can override that behavior by specifying a mask that tells hg to operate on sub-directories:

hg add **/test*

This says "add all files that match 'test*' in the current directory and all sub-directories.

If you remove one of the asterixes, you only operate on sub-directories of the current working directory.

It would help if you posted what specific commands you executed, and the output, if any, and the output of hg st before and after.


Did you hg init in the subdirectory as well? If so, don't. Below illustrates the issue:

C:\>hg init project
C:\>cd project
C:\project>hg init sub
C:\project>echo >file1
C:\project>echo >sub\file2
C:\project>hg st
? file1

Delete the subfolder's .hg directory to fix it:

C:\project>rd /s/q sub\.hg
C:\project>hg st
? file1
? sub\file2

Unlike Subversion, Mercurial only uses an .hg directory at the root of a project.

0

精彩评论

暂无评论...
验证码 换一张
取 消