5. ISCCItem and ISCCBridge interfaces.
In the NesterovskyBros.SCCBridge namespace are defined two interfaces for accessing to a repository. The first interface is ISCCItem that defines common repository's item properties. The second one is ISCCBridge that defines set of methods supported by the repository. Listing 1 and 2 show the properties and methods of the interfaces.
As you can see, the interfaces describe properties and methods common fashion that is used by wide spectrum of version control systems. So, it is easy to implement these interfaces almost for any of such kind of systems. The current version of SCCBridge includes two implementations of the interface: the first implementation for Visual SourceSafe and the second one for a file system. The implementation for CVS will be implemented in the next versions of SCCBridge project.
The ISCCBridge interface and its implementations for Visual SourceSafe and file system are stored in SCCBridge.dll. The SCCBridge.dll assembly uses also Interop.SourceSafeTypeLib.dll satellite assembly for accessing to Visual SourceSafe.
6. BridgeServer web service.
The crucial element of SCCBridge project is the web service. It provides freedom of version control system selection, and, at the same time it provides the common straightforward interface to any system selected by you. There is another benefit of such approach. The client can access to the repository from any place where there is access to Internet and he will obtain all benefits using of version control system. It is possible due to communication with server via HTTP without relaying on specific ports or another network protocols. By the way, the latest version of the project is implemented with using of WSE 2.0, so, there is no any restriction to implement web service standalone (without IIS) and via TCP/IP connection. This could be done even without big changes in the project infrastructure.
In the most cases the methods of the web service just wraps functionality of ISCCBridge interface, but it also implements some specific to web service properties. The following listing (Listing 3) describes methods of this web service.
The common scenario of communication with the web service is:
7. BridgeConsole command line tool.
BridgeConsole is a console application. The main goal of the application is access to the BridgeServer web service, but it also can be used as a simple command line building tool. Besides commands for access to the remote repository via BridgeServer web service it supports also wide used commands like "mkdir", "copy", "remove", "exec", XSL transformations and etc. The XSD scheme of instructions file is defined by http://www.nesterovsky-bros.com/schema/BridgeConsole.xsd. Take a look at the Table 1 below to understand syntax of main commands supported by the application. BridgeConsole was used also for testing of both server and client sides of SCCBridge project.
Whenever the application cannot connect to a web service that supports BridgeServer contract due to incorrect either server URL or user's credentials, it will continue running, but all commands concerning to remote version control system will lead to exceptions. All exceptions will be caught and written out to the log or to the standard output stream.
<add project="/proj1"
recursive="true" comment="test">
<mask>c:\temp\proj1\*.*</mask>
</add>
|
Add the specified list of files/folders to the repository. |
<delete>
<item>/proj1/file.txt</item>
<item>/proj1/proj2</item
>
</delete >
|
Delete the specified list of files/folders from the repository. |
<destroy>
<item>/proj3</item>
</destroy>
|
Destroy the specified list of files/folders into the repository. |
<check-in recursive="true"
comment="test2">
<item>/proj1/file1.c</item>
<item>/proj4</item>
</check-in>
|
Check the specified list of files/folders in. |
<check-out recursive="true">
<item>/proj1/file1.c</item>
<item>/proj1/file1.h</item>
<item>/proj4</item>
</check-out>
|
Check the specified list of files/folders out. |
<undo-check-out>
<item>/proj1/file1.h</item>
</undo-check-out>
|
Performs undo check out for the specified list of files/folders. |
<get-version repository="/proj1/file1.c" version="1"/> | Gets the specified version of the file from the repository. |
<get-latest-version recursive="true">
<item>/proj1/file1.c</item>
<item>/proj4</item>
</get-latest-version>
|
Gets the latest versions of the specified list of files/folders from the repository. |
<history recursive="true" repository="/" to ="c:\temp\history1.xml"/> |
Gets history list for the specified file/folder and store the result XML to
the specified place.
|
<label
recursive="true" name="label1">
<item>/proj1 </item>
</label>
|
Creates a label with the specified name in the repository. |
<list recursive="true" repository="/" to="c:\temp\list1.xml" includeDeleted="true"/> | Gets the current state of the repository and save it as a XML file to the specified place. |
<get-label repository="/" label="label1"/> | Retrieves from the repository files and folders marked with the specified label name. Operation starts from the specified position in the repository. |
<move project="/">
<item>/proj4/proj5</item>
</move>
|
Moves the specified list of files/folders to under another parent into the repository. |
<branch>
<item>/proj5</item>
</branch>
|
Creates a branch into the repository, for the specified list of files/folders. |
<share project="/"
comment="share1">
<item>/proj5/file2.txt</item>
<item>/proj5/proj6</item>
</share>
|
Share for the specified list of files/folders with the new parent project into the repository. |
<pin repository="/proj5" version="1"/> | Pin the specified version of the file or folder. |
<unpin>
<item>/proj5</item>
</unpin>
|
Remove pin. |
<recover>
<item>/proj1/subproj</item>
</recover>
|
Restore into the repository, previously marked as deleted, list of files/folders. |
<cloak>
<item>/proj5</item>
</cloak>
|
Mark the specified list of folders as unused. |
<uncloak>
<item>/proj5</item>
</uncloak>
|
Remove mark was set by previous command. |
<comment>
A simple text comment.
</comment>
|
Write out text comment to the log or standard output stream. There is a variable substitution. Whenever you write "{$now}" to the output stream will be written out current date and time. |
<copy to="c:\temp">
<mask>c:\projects\*.*</mask>
</copy>
|
Copies locally files/folders according to the specified mask to another place. |
<rename-move from="c:\temp\folder1" to="c:\temp\dir1"/> | Renames or moves the specified file/folder to another one locally. |
<remove>
<mask>c:\temp\dir1\test.*</mask>
</remove>
|
Deletes files/folders locally, according to the specified mask. |
<mkdir name="c:\temp\dir2"/> | Creates locally a folder with the specified name. |
<exec
name="c:\winnt\system32\notepad.exe">
<arg>/p</arg>
<arg>c:\temp\dir1\license.txt</arg>
</exec>
|
Executes the specified external applications with the list of arguments determined by children arg elements. |
<transform xml="c:\temp\dir1\main.xml"
xsl="c:\temp\dir1\processor.xsl"
to="c:\temp\dir1\result.txt">
<arg name="param1">value
1</arg>
</transform>
|
Performs XSL transformation. |
Here is the simple example of file-instructions (e.g. stored in instr.xml) for BridgeConsole application:
<?xml version="1.0" encoding="utf-8"?> <commands working-folder="c:\temp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema/BridgeConsole.xsd"> <comment> ------------------------------------------------------------------ Create folders and copy files to the working folder ------------------------------------------------------------------ </comment> <mkdir name="c:\temp\folder1"/> <mkdir name="c:\temp\folder1\folder2"/> <mkdir name="c:\temp\folder3"/> <mkdir name="c:\temp\folder3\folder4"/> <copy to="c:\temp\folder1"> <mask>D:\Projects\NesterovskyBros\BridgeConsole\*.*</mask> </copy> <copy to="c:\temp\folder1\folder2"> <mask>D:\Projects\NesterovskyBros\BridgeConsole\tests\*.*</mask> <copy> <comment> ------------------------------------------------------------------ {$now}: Tests of "Add" ------------------------------------------------------------------ </comment> <comment>Add the folder "c:\temp\folder1" and its content to the repository recursively:</comment> <add project="/" comment="append folder1 as dir1 to the repository" recursive="true"> <mask>c:/temp/folder1</mask> </add> <comment> ------------------------------------------------------------------ {$now}: Tests "CheckOut" and "List" ------------------------------------------------------------------ </comment> <comment>Check-out "/folder1/folder2" recursively:</comment> <check-out recursive="true"> <item>/folder1/folder2</item> </check-out> <comment>Gets the list of all items in the repository:</comment> <list repository="/" recursive="true" to="c:\tmp\list1.xml"/> <comment> ------------------------------------------------------------------ {$now}: Tests "CheckIn" ------------------------------------------------------------------ </comment> <comment>Check in "/folder1" folder recursively:</comment> <check-in recursive="true" comment="test recursive check in"> <item>/folder1</item> </check-in> <comment> ------------------------------------------------------------------ {$now}: Tests of "History" ------------------------------------------------------------------ </comment> <comment>Retrieve history of whole repository:</comment> <history repository="/" recursive="true" to="c:\tmp\history1.xml"/> </commands>
To execute BridgeConsole in command line type in: BridgeConsole.exe -Uadmin -Iinstr.xml
8. Using of ISCCBridge interface in applications.
Before using of ISCCBridge interface directly you have to do following basic steps:
The example below demonstrates how to retrieve a list of items from the Visual SourceSafe repository.
9. Using of SCCClient library in applications.
There are two ways utilization of ISCCBridge interface remotely. The first way is to use SCCClient library from SCCClient.dll assembly. This assembly also requires another satellite assembly - SharpZipLib.dll, which is a freeware implementation of GZip, Zip and another useful compressing protocols.
This is preferable approach, since SCCClient library does a lot of work behind the scenes. It keeps track the current states of local files, synchronizes only different files with the repository, allows to execute commands on folders (e.g. add or check out folder not only single file), supports additional functionality against the pure web service functionality (e.g. cloaking/uncloaking projects). The library also assumes control of communication with the web service. It creates DIME messages, compress and uncompress files, etc.
The second way is to use web service directly. This is rather heavy way, it guesses that you either have to use some library for GZip compressing and WSE anyway, or will communicate with the web service not from .NET application. In this case you have to implement DIME format of messages. See http://msdn.microsoft.com/msdnmag/issues/02/12/DIME/default.aspx to understand it.
Lets take a look at the first approach (utilization of SCCClient library). After creating of a new project you have to do following:
See example below, which demonstrates how to use SCCClient library.
The latest version of SCCClient library exposes its functionality also as a COM object. This allows also to use this library from non-managed code. The following classes are exposed to COM objects:
See SCCClient.tlb file and sources for more details. Take a look also at the listing below that demonstrates how to use SCCClient library from unmanaged C++: