如何列出 Mercurial (hg) 中存储库中的所有文件?

发布于 2024-09-04 08:33:22 字数 177 浏览 5 评论 0原文

Mercurial 中是否有一个命令可以列出当前受源代码控制的所有文件?

我可以执行 dir /s 来列出我的文件夹和子文件夹中的所有文件,但我不知道哪些文件已添加到我的存储库中。我有各种排除的文件类型和文件夹,我想验证在将它们设置到 .hgignore 文件中之前是否未添加任何文件类型和文件夹。

Is there a command in mercurial that will list all files currently under source control?

I can do a dir /s to list all files in my folder and subfolders, but I have no idea which have been added to my repository. I have a variety of excluded file types and folders and I want verify that none of them were added before I set them up in my .hgignore file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

幻梦 2024-09-11 08:33:22

hg status --all 将列出树中的所有文件,并用字母指示其状态:M 表示已修改,C 表示干净(由 hg 拥有),I 表示忽略。

对于忽略文件,请使用hg status -i。对于仅在下次提交时添加的文件,请使用hg status -a。这些仅显示您需要了解的内容,不需要扫描长文件列表。

hg status --all will list all the files in the tree, with a letter indicating its status: M for modified, C for clean (owned by hg), and I for ignored.

For just ignored files, use hg status -i. For just files that will be added on the next commit, use hg status -a. These show only what you need to know and don't require scanning a long file list.

燕归巢 2024-09-11 08:33:22

您还可以查看 hglocate 命令。当我想将文件限制到某个目录时,我会使用它以及 -I 选项。

要列出存储库中的所有文件:

hg locate

从存储库(“根”)目录:

hg locate -I dir/sub_dir/dir_of_interest

传递到 -I 的路径需要根据运行命令的目录进行更改。如果您从上例中的 dir 目录运行命令,则需要修改参数以定位:

hg locate -I sub_dir/dir_of_interest

输出文件列表将保持不变,显示每个文件在存储库中的完整路径。

尝试 hg help -vlocate 了解更多信息。

You might also check out the hg locate command. I use it, along with the -I option when I want to limit the files to a certain directory.

To list all files in your repository:

hg locate

From the repository ("root") directory:

hg locate -I dir/sub_dir/dir_of_interest

The path passed to -I needs to change depending on the directory in which you run the command. If you run the command from the dir directory in the example above, you'd need to modify your argument to locate:

hg locate -I sub_dir/dir_of_interest

The list of output files will remain the same, showing each file's full path in the repository.

Try hg help -v locate for more info.

不必在意 2024-09-11 08:33:22

hg manifest 将仅列出存储库中的文件,而 hg status --all 将列出存储库结构中的所有文件,并包含正在跟踪的标记和哪些不是。

hg manifest will list only the files in the repository, while hg status --all will list all the files in the repository's structure and include a marker for which are being tracked and which aren't.

菊凝晚露 2024-09-11 08:33:22

仅列出被忽略或添加的文件

列出被忽略的文件,请执行:hg status -i

对于刚刚添加的文件,请执行hg status -a

如果您不太喜欢打字,可以将它们缩短为 hg sta -ihg sta -a

status 的这两种用法比 locate 更简单,并且会为您提供您关心的特定文件状态,因此显着减少出错的可能性。

有关 hg status 的更多信息

要列出 Mercurial 存储库中的所有文件,请执行以下操作:hg status --all

列出文件时,系统会在文件前面添加前缀:

  M = modified
  A = added
  R = removed
  C = clean
  ! = missing (deleted by non-hg command, but still tracked)
  ? = not tracked
  I = ignored

如果您想仅列出文件夹中的文件,您可以提供路径:

  • hg st --all MyFolder – MyFolder 中的所有文件
  • hg sta -i MyFolder – 仅忽略 MyFolder 中的文件。

除了表示“已忽略”的 -i 和表示“已添加”的 -a 之外,还可以使用其他标志仅列出具有特定状态的文件。

获取帮助

阅读此处的其他非常有用的答案以获取状态的全面解释 命令。它被否决是因为作者试图表明您可以通过询问 Mercurial 关于 status 命令来发现上述所有内容,如下所示:

hg help status

您可以要求 Mercurial 告诉您关于它的任何命令都是这样的。如果您想要 Mercurial 命令的列表,请输入 hg help

Listing Only Ignored Or Added Files

To list only the ignored files, do: hg status -i.

For just added files, do hg status -a.

If you don't like typing much, you can shorten these to hg sta -i and hg sta -a.

This two uses of status are more simple than locate and will give you the specific files states that you are concerned about, so it is significantly less error prone.

More about hg status

To list all files in a mercurial repo do: hg status --all.

The files will be given a prefix before them when they are listed:

  M = modified
  A = added
  R = removed
  C = clean
  ! = missing (deleted by non-hg command, but still tracked)
  ? = not tracked
  I = ignored

If you want to list only the files in a folder, you can provide a path:

  • hg st --all MyFolder – all files in MyFolder
  • hg sta -i MyFolder – just ignored files in MyFolder.

As well as the -i for "Ignored" and -a for "Added", other flags are available to list only the files having a particular status.

Getting help

Read the other very useful answer here for a comprehensive explanation of the status command. It has down votes because the author has tried to show that you can discover all of the above by asking Mercurial about the status command like this:

hg help status

You can ask Mercurial to tell you about any of it's commands like this. And if you want a list of Mercurial's commands, then type hg help.

晌融 2024-09-11 08:33:22
C:\>hg help -v status
hg status [OPTION]... [FILE]...

aliases: st

show changed files in the working directory

    Show status of files in the repository. If names are given, only files
    that match are shown. Files that are clean or ignored or the source of a
    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
    -C/--copies or -A/--all are given. Unless options described with "show
    only ..." are given, the options -mardu are used.

    Option -q/--quiet hides untracked (unknown and ignored) files unless
    explicitly requested with -u/--unknown or -i/--ignored.

    NOTE: status may appear to disagree with diff if permissions have changed
    or a merge has occurred. The standard diff format does not report
    permission changes and diff only reports changes relative to one merge
    parent.

    If one revision is given, it is used as the base revision. If two
    revisions are given, the differences between them are shown. The --change
    option can also be used as a shortcut to list the changed files of a
    revision from its first parent.

    The codes used to show the status of files are:

      M = modified
      A = added
      R = removed
      C = clean
      ! = missing (deleted by non-hg command, but still tracked)
      ? = not tracked
      I = ignored
        = origin of the previous file listed as A (added)

options:

 -A --all             show status of all files
 -m --modified        show only modified files
 -a --added           show only added files
 -r --removed         show only removed files
 -d --deleted         show only deleted (but tracked) files
 -c --clean           show only files without changes
 -u --unknown         show only unknown (not tracked) files
 -i --ignored         show only ignored files
 -n --no-status       hide status prefix
 -C --copies          show source of copied files
 -0 --print0          end filenames with NUL, for use with xargs
    --rev             show difference from revision
    --change          list the changed files of a revision
 -I --include         include names matching the given patterns
 -X --exclude         exclude names matching the given patterns

global options:
 -R --repository      repository root directory or name of overlay bundle file
    --cwd             change working directory
 -y --noninteractive  do not prompt, assume 'yes' for any required answers
 -q --quiet           suppress output
 -v --verbose         enable additional output
    --config          set/override config option (use 'section.name=value')
    --debug           enable debugging output
    --debugger        start debugger
    --encoding        set the charset encoding (default: cp1252)
    --encodingmode    set the charset encoding mode (default: strict)
    --traceback       always print a traceback on exception
    --time            time how long the command takes
    --profile         print command execution profile
    --version         output version information and exit
 -h --help            display help and exit
C:\>hg help -v status
hg status [OPTION]... [FILE]...

aliases: st

show changed files in the working directory

    Show status of files in the repository. If names are given, only files
    that match are shown. Files that are clean or ignored or the source of a
    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
    -C/--copies or -A/--all are given. Unless options described with "show
    only ..." are given, the options -mardu are used.

    Option -q/--quiet hides untracked (unknown and ignored) files unless
    explicitly requested with -u/--unknown or -i/--ignored.

    NOTE: status may appear to disagree with diff if permissions have changed
    or a merge has occurred. The standard diff format does not report
    permission changes and diff only reports changes relative to one merge
    parent.

    If one revision is given, it is used as the base revision. If two
    revisions are given, the differences between them are shown. The --change
    option can also be used as a shortcut to list the changed files of a
    revision from its first parent.

    The codes used to show the status of files are:

      M = modified
      A = added
      R = removed
      C = clean
      ! = missing (deleted by non-hg command, but still tracked)
      ? = not tracked
      I = ignored
        = origin of the previous file listed as A (added)

options:

 -A --all             show status of all files
 -m --modified        show only modified files
 -a --added           show only added files
 -r --removed         show only removed files
 -d --deleted         show only deleted (but tracked) files
 -c --clean           show only files without changes
 -u --unknown         show only unknown (not tracked) files
 -i --ignored         show only ignored files
 -n --no-status       hide status prefix
 -C --copies          show source of copied files
 -0 --print0          end filenames with NUL, for use with xargs
    --rev             show difference from revision
    --change          list the changed files of a revision
 -I --include         include names matching the given patterns
 -X --exclude         exclude names matching the given patterns

global options:
 -R --repository      repository root directory or name of overlay bundle file
    --cwd             change working directory
 -y --noninteractive  do not prompt, assume 'yes' for any required answers
 -q --quiet           suppress output
 -v --verbose         enable additional output
    --config          set/override config option (use 'section.name=value')
    --debug           enable debugging output
    --debugger        start debugger
    --encoding        set the charset encoding (default: cp1252)
    --encodingmode    set the charset encoding mode (default: strict)
    --traceback       always print a traceback on exception
    --time            time how long the command takes
    --profile         print command execution profile
    --version         output version information and exit
 -h --help            display help and exit
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文