June 29, 2010

Searching File Content in Surround SCM

Surround SCM
A few months back (has it been over a  year already?), I posted a sample tool to search file contents in Surround SCM. Since that time, we have made two important additions to Surround SCM that I felt warranted a fresh approach to this tool. I have re-written this tool with two major differences:
  • I used the Surround SCM API instead of the CLI.
  • The tool is designed to be launched by a custom menu in the Surround SCM client, giving you a more native feel.
There are other minor enhancements as well:
  • Choose whether to do a case sensitive search or not.
  • Choose whether to search recursively or not.
  • Choose whether to save your password or not (in plain text).
Other than that, the basic functionality is the same.  Specify a directory where the tool will get the latest version of the files in the "Current" repository and branch.  The tool will search the file contents and return in sscm:// format if  it contain the specified text.  Click on the Go To File to see the file in the Surround SCM client. As with the original tool, it will only search those files of type "text", "UTF-8" and "UTF-16". You can download the file here.  I have included a sample XML file that you can use to configure the plug in in your Surround SCM client.

Using the tool

Once you set up the plugin file and place it in the Surround SCMplugins directory, and use the icon provided, you should be able to access the tool like this: [caption id="attachment_2652" align="aligncenter" width="384" caption="Repository Context Menu"]Repository Context Menu[/caption] When the tools open for the very first time, or when a configuration file is not found, you will be prompted to enter information needed to connect to Surround SCM using the API: [caption id="attachment_2653" align="aligncenter" width="580" caption="Initial Window"]Initial Window[/caption] The following information is needed: Temporary Folder Location: Specify a local folder on your machine where the tool can get the files to do the search.  Make sure that this is not your working directory and that it is not under some directory where permissions might be an issue.  After the tool search is finished, it deletes the files. Surround SCM Server Address: Enter the IP address or host name of your Surround SCM server. Surround SCM Server Port: Enter the port number of your Surround SCM server. User Name: Specify the user name to use for the tool to log in using the Surround SCM API.  You can use your user name, however, you may want to talk to your Administrator about creating an API-only user. Password: The password for the user specified. If you check the box below to save the username, it will be saved in clear text.

Searching for file content

Once the connection information is configured you can start searching for file content.  Following are all the fields and options: Branch: Read only field, populated by the tool when it loads.  Contains the currently selected branch. Repository: Read only field, populated by the tool when it loads. Contains the currently selected repository. Text to search: Enter the text to search for in the contents of files.  By default the search will not be case sensitive.  Wildcards and regular expressions are not currently supported. Search OptionsCase Sensitive: Check the "Case Sensitive" box if you wish to do a case sensitive search. Recursive: Check the "Recursive" box if you wish your search to also include all child repositories. Find: Once you have entered the text to search and optionally checked any of the search options, click on this button to start the search. Results: Window that displays the files found to contain the specified text. Go To File: Uses the sscm:// protocol to show the file in Surround SCM. This opens a new Surround SCM Source Tree Window. Note: This is a tool that I created on my own and it is not an official Seapine Software release. If you have any questions please send them to me or just leave a comment.