【问题标题】:How to list all files belonged to different branches in Mercurial?如何列出属于 Mercurial 中不同分支的所有文件?
【发布时间】:2012-06-22 20:25:29
【问题描述】:

我是 mercurial 的新手,对于新手的问题,我深表歉意。
我在 /home/Cassie/localRepo 创建了一个名为“localRepo”的本地存储库。我在那里有两个分支,default 和 src1-branch。对于默认分支,它有 file1、file3,对于 src1-branch,它有 file1、file2 和 file4。每当我尝试列出该存储库中的所有文件时,它只显示文件属于当前分支。

例如,如果当前分支是 src1-branch,那么如果我输入了

ls -l

只显示

file1 file2 file4

有没有办法查看所有文件属于同一个存储库,例如

file1 file2 file3 file4

我试过了

hg status --all

它仍然只显示file1 file2 和file4。

我的机器是 redhat linux 工作站 6,带有 mercurial 1.7 和 tortoisehg。

非常感谢,

【问题讨论】:

    标签: linux mercurial branch tortoisehg redhat


    【解决方案1】:

    hg manifest --all 列出所有修订版中的所有文件,包括已删除和重命名的文件。

    给定:

    o  5: Removed file1, Renamed file3->file6
    |
    | @  4: Added file5
    | |
    | o  3: Added file4
    | |
    o |  2: Added file3
    | |
    o |  1: Added file2
    |/
    o  0: Added file1
    

    hg manifest --all 的结果:

    file1
    file2
    file3
    file4
    file5
    file6
    

    【讨论】:

    • 感谢回复。不过可能是我的mercurial版本的原因,无法执行命令hg meanifest --all。我的系统中不存在这样的命令。还有其他想法吗?谢谢,
    • 升级? :^) 看起来--all 是在 1.9 中添加的。
    【解决方案2】:

    据我所知没有标准方法,但您可以使用您提到的方法。

    hg branches ------ tells you all the branch
    branch1
    branch2
    .....
    
    hg update -C branch1    ----- switches you to a branch1
    hg status --all         ----- provides all files for branch1
    
    hg update -C branch2    ----- switches you to branch2
    hg status --all         ----- provides all the files for branch2
    

    您可以合并所有分支的输出并删除多余的文件名。 你可以编写一个脚本来做到这一点。

    -C 也很危险,因为它会在更改为分支时丢弃文件。因此,仅当您要提交的工作目录中没有任何更改时才应使用。

    警告:这种想法通常不是查看两个不同分支中文件的好方法。

    您可以在 branch1 中添加一个文件 c.txt,然后在 branch2 中再次添加另一个 c.txt 具有不同的内容。

    在这种情况下,语义上是两个同名的不同文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-03
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多