tags:

views:

70

answers:

3

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?

+2  A: 

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.

Andrey Vlasovskikh
This is useful. However, I don't know the name of the files I want to extract. I cant list them using `hg manifest` or `hg status --all` because both commands don't work well either on an empty working directory.
Sly
@Sly `hg manifest` has the `-r` option to specify the revision you want to see.
Andrey Vlasovskikh
The windows shell does not expand wildcards, the application does.
Martin Geisler
+2  A: 

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.

Niall C.
Yep, these commands allow listing any revision.
Andrey Vlasovskikh
+1  A: 

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
Ry4an
+1. Much easier than my way. :)
Niall C.