How To: Diff/Compare Two Labels in Visual SourceSafe


This batch script creates a text file containing the differences between two
labels of a SourceSafe project and all of its sub-projects. It was originally posted
to microsoft.public.visualsourcesafe by Weston Morris.  Thanks Weston!

"urn:schemas-microsoft-com:office:office" />@ECHO
OFF

 REM
This batch file will create a text file containing the differences

 REM
between 2 labels of a project and all sub-projects off of that project.

 

 REM
The project name and labels must not contain any spaces.

 

 REM
The env variable SSDIR must point to the the path where VSS is installed on your machine.

 

 if
“%SSDIR%” == “” GOTO NO_SSDIR

 if
“%1″==”HELP” GOTO HELP

 if
“%1″==”/?” GOTO HELP

 if
“%1″==”-?” GOTO HELP

 if
“%1″==”?” GOTO HELP

 if
“%1″==”” GOTO NO_PROJ

 if
“%2″==”” GOTO NO_NEW_LABEL

 if
“%3″==”” GOTO NO_OLD_LABEL

 

 :COMPARE

 ECHO
Gathering data. Please wait….

 del
delta.txt /F /Q

 echo
%ssdir%\win32\ss history %1 -VL%2~%3 %4 %5 %6 %7 %8 %9 -i- -odelta.txt

     %ssdir%\win32\ss
history %1 -VL%2~%3 %4 %5 %6 %7 %8 %9 -i- -odelta.txt

 IF
ERRORLEVEL 100 GOTO VSS_FAILURE

 IF
ERRORLEVEL 1 GOTO VSS_NO_FILES

 

 REM
Exit code 0, history command was successful

 ECHO
Complete.

 delta.txt

 GOTO
EXIT

 

 REM
Exit code 1,

 :VSS_NO_FILES

 ECHO
No changes in that range of labels.

 GOTO
EXIT

 

 REM
Exit code 100, VSS failure

 :VSS_FAILURE

 ECHO
VSS Failed. 

 ECHO
Do you have access to the database?

 ECHO
Is this a valid project name? “%1”

 ECHO
Is this a valid newer label?  “%2”

 GOTO
EXIT

 

 :NO_SSDIR

 ECHO
You must have the SSDIR env variable set up to point to the folder where

 ECHO
VSS was installed on your machine.

 GOTO
EXIT

 

 :NO_PROJ

 :NO_OLD_LABEL

 :NO_NEW_LABEL

 ECHO
You must supply a VSS project, new label and old label.

 GOTO
EXAMPLES

 

 :EXAMPLES

 :HELP

 ECHO
Command Syntax:

 ECHO    DUMP_DELTA
{project name} {new project label}

 ECHO               {old
project label} [other VSS options]

 ECHO    {project
name} is the VSS project name (no spaces allowed in the name)

 ECHO    {new
project label} is the newer label (no spaces allowed in the label)

 ECHO    {old
project label} is the older label (no spaces allowed in the label)

 ECHO    [other
VSS options] are a list of other SS options such as:

 ECHO        -R  Display
the history of an entire project list.

 ECHO        -L  Display
only versions that have labels.

 ECHO        -F-
Do not display individual file updates in the project history.

 ECHO        -B  Display
a brief history.

 ECHO        -U  Display
only changes made by a particular user.

 ECHO        -I-
Ignore: Do not ask for input under any circumstances.

 ECHO        -Y
Specify a username and/or password.

 ECHO
Examples of how to start this batch file:

 ECHO    DUMP_DELTA
DP1XXX_3.1.4 DP1XXX_3.1.0

 ECHO    DUMP_DELTA
PR_233 PR_230 -R -UWeston

 GOTO
EXIT

 

 :EXIT

++++++++++++++++++++++++++
This
posting is provided “AS IS” with no warranties, and confers no rights.

Comments (6)

  1. Martin Brown says:

    There is a minor flaw in this script. It assumes that the source safe executable files (ss.exe) are in the same place as the database. To resolve this you can remove the %ssdir%win32 from the front of the command and ensure that ss.exe is on the path before running the script.

  2. Thanks! This will come in handy for sure.

  3. jayshree says:

    Labels used in our VSS database contain spaces. Is there any way i can get list of changed files between two labels then.

    Please advise

  4. essiac says:

    Thanks for the great tips about <a href="http://nolanfam.250free.com/essiac.html"”>http://nolanfam.250free.com/essiac.html" title="essiac">essiac</a> and [URL=http://nolanfam.250free.com/essiac.html]essiac[/URL]