我试图使用以下命令获取当前文件和dirs的列表:
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发布于 2018-05-27 21:50:18
在Unix机器上,您可以尝试:
hg manifest -r tip | cut -d "/" -f 1 | sort -u或
hg manifest -r tip | cut -d "/" -f 1 | uniqcut -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)发布于 2018-12-09 09:52:37
用于在版本控制下的pwd中列出文件的Mercurial专用命令是:
hg files "glob:*"由于manifest和files命令都是面向文件的,因此使用只使用Mercurial的方法可能根本不可能达到指定的目标。
https://stackoverflow.com/questions/50421063
复制相似问题