January 18, 2011
Using a Script to Handle Long File Check Ins
Large binary files can result in long check ins that tie up the client and affect your productivity. A slow connection to the server can aggravate this. Using the Command Line Interface (CLI) for those check ins can free your client up of this operation and allow you to continue with your work. You can also create a custom menu in Surround SCM to launch a batch file that checks in the file in the background. First, the custom menu requires an XML file. Following is an example of what the contents of the XML file could be:
<Surround-Plugin version="1.0" author="[email protected]" >
<menu-item name="Binary Check In" icon="reqmnt_doc_review_24x24.png" >
<location type="contextfile" />
<action path="C:batchbincheckin.bat" wait-for-completion="false"></action>
</Surround-Plugin>The XML file is configured to have a file context menu item labeled "Binary Check In". It's also using the "reqmnt_doc_review_24x24.png" file as an icon, which is found in the "workflow icons" directory in the TestTrack Server installation directory. When the Binary Check In menu item is selected, it calls a batch file named "bincheckin.bat", which is stored on the local path "C:batch". Also, notice that the plug-in will not wait for the batch file to complete, as that would defeat the purpose of creating the plug-in. [caption id="attachment_6886" align="aligncenter" width="221" caption="Surround SCM custom menu"][/caption] Refer to the Surround SCM Custom Menus blog post for more details on the available options. The content of the batch file is as follows:
set mypath=%SSCM_LOCALFILE% :Loop IF "%mypath:~-1,1%"=="" ( GOTO End ) SET mypath=%mypath:~0,-1% GOTO :Loop
sscm checkin "%SSCM_FILE%" -cc"batch check in" -fThe batch file does the following:
- Gets the local path to the file being checked in.
- Starting from the end of the path, removes a character at a time until it finds a back slash (""). This returns the working directory.
- Changes to the returned working directory.
- Runs the check in command.