You can use hg grep
, but it searches the contents of all files.
What if I just want to search the file names of deleted files to recover one?
I tried hg grep -I <file-name-pattern> <pattern>
but this seems to return no results.
' hg forget ' is just shorthand for ' hg remove -Af '. From the ' hg remove ' help: ...and -Af can be used to remove files from the next revision without deleting them from the working directory. Bottom line: ' remove ' deletes the file from your working copy on disk (unless you uses -Af ) and ' forget ' doesn't.
Revert changes already committed To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.
If you see the help for hg rm --help : hg remove [OPTION]... FILE... Schedule the indicated files for removal from the current branch. This command schedules the files to be removed at the next commit.
using templates is simple:
$ hg log --template "{rev}: {file_dels}\n"
You can use revsets for this too:
hg log -r "removes('**')"
(Edit: Note the double *
- a single one detects removals from the root of the repository only.)
Edit: As Mathieu Longtin suggests, this can be combined with the template from dfa's answer to show you which files each listed revision removes:
hg log -r "removes('**')" --template "{rev}: {file_dels}\n"
That has the virtue (for machine-readability) of listing one revision per line, but you can make the output prettier for humans by using %
to format each item in the list of deletions:
hg log -r "removes('**')" --template "{rev}:\n{file_dels % '{file}\n'}\n"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With