how to use tortoisehg's search tools?
Asked Answered
B

2

17

I want to search for a specific phrase (ie "comma_delimited") in a specific file (ie "index.php") in a specific branch (ie "ABC-123"). The reason for this is, that text is no longer in the file, and I want to see at which commit it was taken out, without looking at every revision of this file on this branch.

Is there a way to do this in tortoisehg? I see there is a Search button which brings up a search panel where you can enter patterns, but I have no clue how to use it (and don't know how to write patterns), and after googling for some time, found no useful info on it.

Thanks

Benne answered 12/6, 2012 at 9:20 Comment(0)
E
15

There are two search buttons - one to search the repository and the other is to filter the revision graph. Maybe you pressed the wrong one?

If you use the menu to select View / Search this selects the search view that you want.

It should show you a large panel below the revision graph with a number of controls to fill in.

  • Enter "comma_delimited" into the first edit control (on the same line as the Search and Stop buttons which are on the right)
  • Select the "All History" radio button below that edit control.
  • Enter **index.php into the edit control labelled "Includes" (or the full path to index.php if you have more than one and want to limit the search to a particular file)
  • Press the Search button

The list at the bottom of the window should now show details of the revisions that include that phrase. It will show when it was added (prefixed with a '+') and when it was removed (prefixed with a '-')

Here's an example search window: Example search window

Exonerate answered 12/6, 2012 at 9:59 Comment(2)
my repository has a very large history with many branches, i don't want to search for every revision of index.php, just the changes made in this branch. is that possible?Benne
There doesn't seem to be that option from the UI. Just looking at a single file rather than the whole repository does speed it up a lot so maybe that's enough. From the command line you can limit the search to a range of revisions or a single branch: hg grep --all -I "**index.php" -r "branch(branch_name)" comma_delimited but that doesn't seem to work in tortoisehg's search view.Exonerate
S
1

The TortoiseHg search field supports revsets. It looks like there is a grep(regex) function, but it looks like it is just a regex variant of the keyword function, which only searches "commit message, user name, and names of changed files". Bummer. It looks like you're only choice is to use Mercurial's grep command:

> hg grep -r ABC-123 'comma_delimited' index.php
Swann answered 12/6, 2012 at 15:0 Comment(1)
i checked out the link you posted... the grep will "Search commit message, user name, and names of changed files for string." but not the text in a file...Benne

© 2022 - 2024 — McMap. All rights reserved.