如何从空工作目录使用“hg cat”?
我有一个位于 x:/projects/repo1 的存储库。工作目录已使用 hg update null
清空。我想从那里提取一些文件的最新版本到本地目录。
我尝试了这个:
x:\projects\repo1> hg cat -o c:\sql\%s scripts\*.sql -r tip
我收到此错误:
scripts\*.sql: No such file in rev 14f07c26178b
如果工作目录不为空,则相同的命令可以正常工作。这不起作用有充分的理由吗?或者您知道将某些文件从那里提取到本地目录的另一种方法吗?
I have a repo located at x:/projects/repo1. The working directory has been emptied using hg update null
. I want to extract the latest version of some files from there to a local directory.
I tried this:
x:\projects\repo1> hg cat -o c:\sql\%s scripts\*.sql -r tip
I get this error:
scripts\*.sql: No such file in rev 14f07c26178b
The same command works fine if the working directory is not empty. Is there a good reason why this does not work? Or do you know another way of extract some files from there to a local directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
hg cat
命令适用于单个文件。如果您想要多个文件,请使用 hg archive 命令,这会使 zip 文件或目录充满文件。这是你的命令:The
hg cat
command is for single files. If you want multiple files use thehg archive
command, which makes zipfiles or directories full of files. Here's your command:看来
hg cat
不支持路径中的通配符。因此,您应该使用完整的文件名:当您的工作副本是最新的
tip
修订版时,您的 shell 会为您进行通配符替换。hg manifest
命令也可能有助于获取跟踪的文件列表。It seems that
hg cat
doesn't support wildcard symbols in paths. So you should use the full file name:When your working copy is up to date with the
tip
revision, your shell does wildcard substitution for you.The
hg manifest
command also might be helpful for getting tracked file listings.这个答案是您对 Andrey 的评论答案:
hg manifest
采用--rev
参数,您可以使用它来查看存储库中所有文件的列表:获取匹配的文件列表提示处的模式,使用:
从那里您可以将输出重定向到文件并将每一行编辑为
hg cat
命令,就像您原来的问题一样。看来(至少对我来说,已经做了一些实验)hg cat 使用工作目录的内容(而不是指定版本的存储库的内容)进行全局匹配,因此一旦您知道文件的确切名称,您就可以在任何版本中hg cat
它。This answer is to your comment on Andrey's answer:
hg manifest
takes a--rev
argument that you can use to see the list of all files in your repository:To get the list of files matching a pattern at the tip, use:
From there you could redirect the output to a file and edit each line into a
hg cat
command like in your original question. It appears (to me, at least, having done some experimentation) thathg cat
uses the contents of the working directory -- rather than the contents of the repository at the revision specified -- for glob-matching, so once you know the exact name of the file, you canhg cat
it at any revision.