Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial - determine where file was removed?

Tags:

If you do hg log myfile -v you see a list of changesets that the file was modified in.

In our case, in the most recent changeset, the file was removed. But you can't tell this by looking at the verbose (-v) output of hg log. Is there an easy Mercurial command you can use to determine if and when a file has been removed from the repo?


Update: Note that this is on a Windows client, and we are using Mercurial v 1.4.3

Update 2: Appears the answers below would work with a more recent version of Mercurial, however an upgrade isn't in the cards right now. Any other ideas for v 1.4.3 ???

like image 520
Marcus Leon Avatar asked Mar 24 '11 13:03

Marcus Leon


People also ask

How do I Untrack a file in Mercurial?

Mercurial offers a combination command, hg addremove , that adds untracked files and marks missing files as removed. The hg commit command also provides a -A option that performs this same add-and-remove, immediately followed by a commit.

How do you use a hg strip?

hg strip [-k] [-f] [-B bookmark] [-r] REV... The strip command removes the specified changesets and all their descendants. If the working directory has uncommitted changes, the operation is aborted unless the --force flag is supplied, in which case changes will be discarded.

What is hg status?

hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.

What is hg command?

DESCRIPTION. The hg command provides a command line interface to the Mercurial system.


2 Answers

You can check which revision deleted a file (any many other interesting features) using revsets:

hg log -r 'removes(<myfile>)'

Some examples:

hg log -r 'removes(build.xml)' // where build.xml used to be in the current directory

hg log -r 'removes("**/build.xml")' // where build.xml may have been in sub directories

See hg help revsets for details.

like image 91
Tim Henigan Avatar answered Sep 29 '22 14:09

Tim Henigan


The --removed flag should get you what you are looking for:

hg log myfile -v --removed 

From the help for hg log:

    --removed              include revisions where files were removed 
like image 37
Den Avatar answered Sep 29 '22 14:09

Den