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

I have a repo located in 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 -oc:\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 to extract some files from there to a local directory?

+3
source share
3 answers

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

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

hg cat does not seem to support wildcard characters in paths. Therefore, you should use the full file name:

 hg cat -r tip scripts/foo.sql 

When your working copy is updated with the tip version, your shell performs wildcard substitution for you.

The hg manifest command can also be useful for tracking file lists.

+2
source

This answer to your comment on Andrey answer :

hg manifest accepts the --rev argument, which you can use to list all the files in your repository:

 hg manifest --rev tip 

To get a list of files matching the 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 can redirect the output to a file and edit each line in the hg cat , as in the original question. It seems (at least I did some experiments) that hg cat uses the contents of the working directory and not the contents of the repository for the specified revision - to match the glob, therefore, the exact file name, you can hg cat it with any revision.

+2
source

All Articles