November 11, 2009

SSCM Migrate

Surround SCM

Works with Surround SCM 2010 and later

Will not work with Surround SCM 2009 and earlier

SSCMigrate is a sample tool that copies a branch into a new mainline. It can be any branch, however, only that branch is migrated. Any child branch will not be migrated. This is a sample tool and it is not a finished product by any means. Depending on your needs, this may give you a good starting point. At this time only the following historic events are handled:
  • AddToRepository - Historic event when a brand new file is added to a branch from disk. This event is mapped as an AddToRepository event on the new mainline.
  • AddFromBranch - Historic event when a file is added to a branch as a result of a promote. This event is mapped as an AddToRepository event on the new mainline.
  • CheckIn - Historic event when a file is modified as part of a check in. This event is mapped as a CheckIn event on the new mainline
  • PromoteFromBranchWithMerge - Historic event when a file is modified as part of a promote that required a merge. This event is mapped as a CheckIn event on the new mainline
  • PromoteFromBranchWithoutMerge - Historic event when a file is modified as part of a promote that did not require a merge. This event is mapped as a CheckIn event on the new mainline
Some events would be trivial to add, like rebases. Simply copy and paste the code used for any of the above events, and change it to look for a rebase event. Others, however, might require more complex logic, like handling shares. Labels are not part of this tool at this time. If all file versions match, then it should be trivial to implement as well. Currently all historic events on the new branch are made by a single user, so user history is lost. For each historic event that is handled, only the comments are copied. In order for user history to be mantained, the tool would need to disconnect and connect as the user that performed the action. It would need to know the username and password of every user. A more practical approach could be to add the user that performed the action as well as the date of the action on the source branch to the comments on the new branch.

Tech Details

This sample is written in C# using Visual Studio 2008. The entire project is provided for your perusal. To run this 'as-is', you must have a folder called migrate at the root of your C: drive. This is the working directory for this application to get files from the old branch and add them to the new one. To change this, edit the value assigned to the workDir variable.

Using the tool

At the time of this writing, creating a mainline branch is not possible with the API, so it must be created first manually. The tool itself takes all information as parameters, and they are as follows (in the correct order):
  • Old (source) mainline
  • Old (source) branch
  • New mainline (created manually before running the tool)
  • Surround SCM user name
  • Surround SCM user password
  • Surround SCM server address/name
  • Surround SCM server port (default is 4900)
If any parameter is missing the tool will close.

Example

The following example migrates the branch "Bug Reporter - Staging" in the "WysiCorp" mainline to a new mainline called "BugReporter". SCMMigrate "WysiCorp" "Bug Reporter - Staging" "BugReporter" Administrator password localhost 4900 The following example migrates the mainline "WysiCorp" to a new mainline called "BugReporter". SCMMigrate "WysiCorp" "WysiCorp" "BugReporter" Administrator password localhost 4900

Known Issues

The only known issues so far deal with the events that are not currently handled.

Security

Keep in mind that the API does respect security, so any repositories not visible to the user will not be migrated. The user will have to be able to do the following (this may not be an all inclusive list):
  • Access source branch and all repositories
  • Access history on all files on source branch
  • Get all historical versions of all files
  • Add files to new mainline
  • Check out files from new mainline
  • Check in files to new mainline
  • Any other security permission to handle any enhancements made to the tool, like handling shares.
There may be other security permissions needed not identified as of this writing.

Download

Download the entire Visual Studio 2008 project from here. There is a binary available in the binDebug folder.

Need something more robust?

If your needs require a more complex solution, contact our services group. Note: Seapine does not provide support for sample scripts.