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开发者_如何学Go this does not work? Or do you know another way of extract some files from there to a local directory?
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
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.
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.
精彩评论