Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find deleted files in Mercurial repository history, quickly?

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.

like image 594
wsorenson Avatar asked Jun 18 '09 15:06

wsorenson


People also ask

How to remove files from hg?

' 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.

How do I revert a file in Mercurial?

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.

How do you Untrack a file in Heartgold?

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.


2 Answers

using templates is simple:

$ hg log --template "{rev}: {file_dels}\n" 
like image 162
dfa Avatar answered Oct 10 '22 22:10

dfa


Update for Mercurial 1.6

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" 
like image 26
anton.burger Avatar answered Oct 10 '22 22:10

anton.burger