How to use `hg cat` from an empty working directory?

拈花ヽ惹草 提交于 2020-01-24 11:16:09

问题


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?


回答1:


The hg cat command is for single files. If you want multiple files use the hg archive command, which makes zipfiles or directories full of files. Here's your command:

x:\projects\repo1> hg archive --include scripts\*.sql -r tip c:\sql



回答2:


It seems that hg cat doesn't support wildcard symbols in paths. So you should use the full file name:

hg cat -r tip scripts/foo.sql

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.




回答3:


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:

hg manifest --rev tip

To get the list of files matching a pattern at the tip, use:

hg stat --all --include *.sql --rev tip --no-status
hg stat -A -I *.sql --rev tip -n                    # using abbreviations.

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) that hg 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 can hg cat it at any revision.



来源:https://stackoverflow.com/questions/3322207/how-to-use-hg-cat-from-an-empty-working-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!