Update of /cvsroot/ccnetcontrib/ccnetcontrib/src/VSSPlugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32474/src/VSSPlugin
Added Files:
LabelProjectVisitor.cs VSSSourceControl.cs AssemblyInfo.cs
ModificationList.cs CollectItemModifiedInDateRange.cs
CommonAssemblyInfo.cs VSSPlugin.csproj IVssItemVisitor.cs
CollectItemByLabelVisitor.cs .cvsignore
Log Message:
Moving VSSPlugin into common src tree, and adding vssplugin specific targets to build script.
--- NEW FILE: .cvsignore ---
bin
obj
VSSPlugin.csproj.user
--- NEW FILE: CommonAssemblyInfo.cs ---
using System.Reflection;
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
[assembly: AssemblyVersionAttribute("0")]
[assembly: AssemblyCopyrightAttribute("Copyright © 2004 ThoughtWorks Inc.")]
[assembly: AssemblyCompanyAttribute("ThoughtWorks")]
[assembly: AssemblyProductAttribute("CruiseControl.NET")]
--- NEW FILE: LabelProjectVisitor.cs ---
using SourceSafeTypeLib;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
public class LabelProjectVisitor : IVssItemVisitor
{
private readonly string label;
public LabelProjectVisitor(string label)
{
this.label = label;
}
public void Visit(IVSSItem item)
{
if (IsProject(item)) item.Label(label, "CCNet label");
}
private bool IsProject(IVSSItem item)
{
return item.Type == (int) VSSItemType.VSSITEM_PROJECT;
}
}
}
--- NEW FILE: ModificationList.cs ---
using System;
using System.Collections;
using SourceSafeTypeLib;
using ThoughtWorks.CruiseControl.Core;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
public class ModificationList
{
private ArrayList modifications = new ArrayList();
public void Add(IVSSVersion version, IVSSItem item)
{
modifications.Add(CreateModification(version, item));
}
private Modification CreateModification(IVSSVersion version, IVSSItem item)
{
Modification mod = new Modification();
mod.ModifiedTime = version.Date;
mod.Comment = version.Comment;
mod.FileName = item.Name;
mod.FolderName = item.Parent.Name;
mod.Type = version.Action;
mod.UserName = version.Username;
return mod;
}
public Modification[] Modifications
{
get { return (Modification[]) modifications.ToArray(typeof (Modification)); }
}
}
}
--- NEW FILE: CollectItemByLabelVisitor.cs ---
using SourceSafeTypeLib;
using ThoughtWorks.CruiseControl.Core;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
public class CollectItemByLabelVisitor : IVssItemVisitor
{
private readonly string expectedLabel;
private ModificationList modifications = new ModificationList();
public CollectItemByLabelVisitor(string expectedLabel)
{
this.expectedLabel = expectedLabel;
}
/// <summary>
/// Labels are applied at a project level but are attached to all files. However, the labelled version for the file references
/// the project item.
/// </summary>
/// <param name="item"></param>
public void Visit(IVSSItem item)
{
if (item.Deleted) return;
bool found = false;
IVSSVersions versions = item.get_Versions(0);
foreach (IVSSVersion version in versions)
{
if (!found && version.Label == expectedLabel)
{
modifications.Add(version, item);
found = true;
}
}
}
public Modification[] Modifications
{
get { return modifications.Modifications; }
}
}
}
--- NEW FILE: VSSSourceControl.cs ---
using System;
using System.Runtime.InteropServices;
using Exortech.NetReflector;
using SourceSafeTypeLib;
using ThoughtWorks.CruiseControl.Core;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
[ReflectorType("vssplugin")]
public class VSSSourceControl : ISourceControl
{
[ReflectorProperty("project")]
public string Project;
[ReflectorProperty("srcSafeIni", Required=false)]
public string SrcSafeIni;
[ReflectorProperty("username", Required=false)]
public string Username;
[ReflectorProperty("password", Required=false)]
public string Password;
[ReflectorProperty("labelComment", Required=false)]
public string LabelComment = "CCNet label";
[ReflectorProperty("autoGetSource", Required=false)]
public bool AutoGetSource = true;
public void Run(IIntegrationResult result)
{
result.Modifications = GetModifications(result.StartTime, DateTime.Now);
}
public bool ShouldRun(IIntegrationResult result)
{
return result.Working;
}
public Modification[] GetModifications(DateTime from, DateTime to)
{
CollectItemModifiedInDateRange visitor = new CollectItemModifiedInDateRange(from, to);
VisitAllItems(GetRootProject(), visitor);
return visitor.Modifications;
}
public Modification[] GetModifications(string label)
{
CollectItemByLabelVisitor visitor = new CollectItemByLabelVisitor(label);
VisitAllItems(GetRootProject(), visitor);
return visitor.Modifications;
}
/// <summary>
/// A label is automatically applied recursively to all files and subprojects.
/// </summary>
/// <param name="label">The label to apply to the project.</param>
/// <param name="timeStamp">This parameter is unused as VSS only creates a new label when it is applied to the latest version of the project.</param>
public void LabelSourceControl(string label, DateTime timeStamp)
{
IVSSItem project = GetRootProject();
project.Label(label, LabelComment);
}
private void VisitAllItems(IVSSItem root, IVssItemVisitor visitor)
{
visitor.Visit(root);
foreach (IVSSItem item in root.get_Items(true))
{
visitor.Visit(item);
if (IsProject(item)) VisitAllItems(item, visitor);
}
}
private bool IsProject(IVSSItem item)
{
return item.Type == (int)VSSItemType.VSSITEM_PROJECT;
}
public void GetSource(IIntegrationResult result)
{
if (! AutoGetSource) return;
IVSSItem project = GetRootProject();
string directory = result.WorkingDirectory;
project.Get(ref directory, (int)VSSFlags.VSSFLAG_RECURSYES + (int)VSSFlags.VSSFLAG_REPREPLACE + (int)VSSFlags.VSSFLAG_USERRONO);
}
private IVSSItem GetRootProject()
{
VSSDatabase vss = OpenVssDatabase();
try
{
VSSItem item = vss.get_VSSItem(Project, false);
if (! IsProject(item)) throw new CruiseControlException(string.Format("VSS item {0} is a file, not a project.", Project));
return item;
}
catch (COMException ex)
{
throw new CruiseControlException(string.Format("Unable to retrieve VSS root project: {0}", Project), ex);
}
}
private VSSDatabase OpenVssDatabase()
{
try
{
VSSDatabase vss = new VSSDatabase();
vss.Open(SrcSafeIni, Username, Password);
return vss;
}
catch (COMException ex)
{
throw new CruiseControlException(string.Format("Unable to connect to VSS database - {0}", ToString()), ex);
}
}
private Modification CreateModification(IVSSVersion version)
{
Modification mod = new Modification();
mod.ModifiedTime = version.Date;
mod.Comment = version.Comment;
mod.FileName = version.VSSItem.Name;
mod.FolderName = version.VSSItem.Parent.Name;
mod.Type = version.Action;
mod.UserName = version.Username;
return mod;
}
public void Initialize(IProject project)
{
throw new NotImplementedException();
}
public void Purge(IProject project)
{
throw new NotImplementedException();
}
public override string ToString()
{
return string.Format("Username: {0} Password: {1} SrcSafeIni: {2}", Username, Password, SrcSafeIni);
}
}
}
--- NEW FILE: VSSPlugin.csproj ---
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{F1F13F30-E452-42B4-9BCE-0A228FEE8C65}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "ThoughtWorks.CruiseControl.Contrib.VSSPlugin"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "ThoughtWorks.CruiseControl.Contrib.VSSPlugin"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Build"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = ""
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "..\..\build\VSSPlugin\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "1"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "SourceSafeTypeLib"
Guid = "{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}"
VersionMajor = "5"
VersionMinor = "1"
Lcid = "0"
WrapperTool = "tlbimp"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "ThoughtWorks.CruiseControl.Remote"
AssemblyName = "ThoughtWorks.CruiseControl.Remote"
HintPath = "..\..\lib\ThoughtWorks.CruiseControl.Remote.dll"
/>
<Reference
Name = "NetReflector"
AssemblyName = "NetReflector"
HintPath = "..\..\lib\NetReflector.dll"
/>
<Reference
Name = "ThoughtWorks.CruiseControl.Core"
AssemblyName = "ThoughtWorks.CruiseControl.Core"
HintPath = "..\..\lib\ThoughtWorks.CruiseControl.Core.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CollectItemByLabelVisitor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CollectItemModifiedInDateRange.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CommonAssemblyInfo.cs"
BuildAction = "Compile"
/>
<File
RelPath = "IVssItemVisitor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "LabelProjectVisitor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ModificationList.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "VSSSourceControl.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
--- NEW FILE: CollectItemModifiedInDateRange.cs ---
using System;
using SourceSafeTypeLib;
using ThoughtWorks.CruiseControl.Core;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
public class CollectItemModifiedInDateRange : IVssItemVisitor
{
private readonly DateTime to;
private readonly DateTime from;
private ModificationList modifications = new ModificationList();
public CollectItemModifiedInDateRange(DateTime from, DateTime to)
{
this.from = from;
this.to = to;
}
public void Visit(IVSSItem item)
{
IVSSVersions versions = item.get_Versions(0);
foreach (IVSSVersion version in versions)
{
if ((from < version.Date) && (to >= version.Date))
{
modifications.Add(version, item);
}
}
}
public Modification[] Modifications
{
get { return modifications.Modifications; }
}
}
}
--- NEW FILE: IVssItemVisitor.cs ---
using SourceSafeTypeLib;
namespace ThoughtWorks.CruiseControl.Contrib.VSSPlugin
{
public interface IVssItemVisitor
{
void Visit(IVSSItem item);
}
}
--- NEW FILE: AssemblyInfo.cs ---
using System.Reflection;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly : AssemblyTitle("CC.NET Contrib VSS Plugin")]
[assembly : AssemblyDescription("")]
[assembly : AssemblyConfiguration("")]
|