mercurial - 仅在 hg list 中列出工作目录文件和目录?

标签 mercurial

我正在尝试使用以下命令获取当前文件和目录的列表:

hg manifest -r tip

然而,这带来了这样的列表:
.hgtags
folder1/blah.c
folder1/blah.h
foo.json
folder2/bleh.c
folder2/bleh.h
test.json

如何仅列出以下内容?
.hgtags
folder1
foo.json
folder2
test.json

最佳答案

在 Unix 机器上,您可以尝试:

hg manifest -r tip | cut -d "/" -f 1 | sort -u

或者
hg manifest -r tip | cut -d "/" -f 1 | uniq
  • cut -d "/" -f 1 : 选择由“/”分隔的第一部分
  • uniq : 过滤掉重复的行

  • 或者使用 Python(更跨平台):

    您需要安装 python-glib(通过 pip)
    import hglib
    repo = hglib.open("/path/to/repo")
    manifest = repo.manifest("tip")
    files = set(f[4].split('/')[0] for f in manifest)
    

    关于mercurial - 仅在 hg list 中列出工作目录文件和目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50421063/

    相关文章:

    git - 我如何在 git 中更新我的代码库而不必删除、存储或 checkin 我当前的更改?

    git - mercurial (hg) 语法等同于 git 的 "^",表示在指定提交之前提交

    mercurial - 如何使用 'hg log' 列出一系列修订?

    git - 是否有 Git 命令导入 hg 存储库

    git - dvcs 部分 merge (git、hg merge 跟踪)

    python - 如何正确安装 dulwich 以使 hg-git 在 Windows 上运行?

    mercurial - 将子存储库与 bitbucket 一起使用

    mercurial - Mercurial怎么可能是版权和自由软件呢?

    linux - Mercurial 并排差异(最大术语宽度)

    mercurial - Phabricator、扩散、 Mercurial : "abort: integrity check failed"