find a deleted string, hg grep help ?

Greg Ward greg-hg at gerg.ca
Tue Aug 10 13:20:22 UTC 2010


On Tue, Aug 10, 2010 at 5:53 AM, rupert.thurner
<rupert.thurner at gmail.com> wrote:
> how can one find the revision when a string was deleted? the commands
> i considered, in our case we deleted a file, which was referenced out
> of other files:
>  hg grep
>  hg log --template "{rev}: {file_dels}\n" | grep -v ':\s*$' | grep
> Test

I would bisect for the removal.

  hg update
  hg bisect -b         # bad = "it's gone"
  hg update <long ago> # to some point where you know the string was there
  hg bisect -c "grep <the string> <file>"

Untested.  Should work though.

General tip on using bisect: especially if you have a very
branchy/nonlinear history, go back farther than you think is
necessary.  That makes it more likely that the endpoints of the
bisection will really enclose the change, rather than merely enclosing
a merge that happened to bring the change into the subset of the graph
that your bisect encloses.  Since bisection is O(log N), it doesn't
really matter if your initial range is 500 changesets or 700.
(Especially if the test is as fast and simple as a grep!)

Greg



More information about the Mercurial mailing list