This repository was archived by the owner on Feb 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathSurround.cs
More file actions
209 lines (191 loc) · 7.79 KB
/
Surround.cs
File metadata and controls
209 lines (191 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
using Exortech.NetReflector;
using ThoughtWorks.CruiseControl.Core.Util;
using System.Globalization;
namespace ThoughtWorks.CruiseControl.Core.Sourcecontrol
{
/// <summary>
/// <para>
/// Source Controller for Seapine Surround SCM
/// </para>
/// <para type="info">
/// The Seapine Surround provider is designed to work with Surround 4.1. It may not work with earlier versions of
/// Surround.
/// </para>
/// </summary>
/// <title>Seapine Surround Source Control Block</title>
/// <version>1.0</version>
/// <key name="type">
/// <description>The type of source control block.</description>
/// <value>pvcs</value>
/// </key>
/// <example>
/// <code>
/// <sourcecontrol type="surround">
/// <executable>C:\Program Files\Seapine\Surround SCM\sscm.exe</executable>
/// <serverconnect>127.0.0.1:4900</serverconnect>
/// <serverlogin>build:buildpw</serverlogin>
/// <branch>mybranch</branch>
/// <repository>myrepository/myproject</repository>
/// <workingDirectory>C:\myproject</workingDirectory>
/// <recursive>1</recursive>
/// <file>*.cpp</file>
/// <searchregexp>0</searchregexp>
/// <timeout units="minutes">10</timeout>
/// </sourcecontrol>
/// </code>
/// </example>
/// <remarks>
/// <para>
/// Contributed by Yan Shapochnik and Pete Vasiliauskas at Seapine Software.
/// </para>
/// </remarks>
[ReflectorType("surround")]
public class Surround : ProcessSourceControl
{
/// <summary>
///
/// </summary>
/// <remarks></remarks>
public const string TO_SSCM_DATE_FORMAT = "yyyyMMddHHmmss";
private const string DefaultServerConnection = "127.0.0.1:4900";
private const string DefaultServerLogin = "Administrator:";
/// <summary>
/// Initializes a new instance of the <see cref="Surround"/> class.
/// </summary>
public Surround()
: base(new SurroundHistoryParser(), new ProcessExecutor())
{
this.Executable = "sscm";
this.ServerConnect = DefaultServerConnection;
this.ServerLogin = DefaultServerLogin;
this.SearchRegExp = 0;
this.Recursive = 0;
}
/// <summary>
/// The local path for the Surround SCM command-line client
/// (eg. C:\Program Files\Seapine\Surround SCM\sscm.exe).
/// </summary>
/// <version>1.0</version>
/// <default>sscm</default>
[ReflectorProperty("executable")]
public string Executable { get; set; }
/// <summary>
/// The Surround SCM branch to monitor.
/// </summary>
/// <version>1.0</version>
/// <default>n/a</default>
[ReflectorProperty("branch")]
public string Branch { get; set; }
/// <summary>
/// The Surround SCM repository to monitor.
/// </summary>
/// <version>1.0</version>
/// <default>n/a</default>
[ReflectorProperty("repository")]
public string Repository { get; set; }
/// <summary>
/// A filename pattern to match to monitor and retrieve files.
/// </summary>
/// <version>1.0</version>
/// <default>None</default>
[ReflectorProperty("file", Required = false)]
public string File { get; set; }
/// <summary>
/// The local path to get files from Surround SCM to.
/// </summary>
/// <version>1.0</version>
/// <default>n/a</default>
[ReflectorProperty("workingDirectory")]
public string WorkingDirectory { get; set; }
/// <summary>
/// The IP address or machine name and port number of the Surround SCM server.
/// </summary>
/// <version>1.0</version>
/// <default>127.0.0.1:4900</default>
[ReflectorProperty("serverconnect", Required = false)]
public string ServerConnect { get; set; }
/// <summary>
/// Surround SCM login:password that CCNet should use.
/// </summary>
/// <version>1.0</version>
/// <default>Administrator</default>
[ReflectorProperty("serverlogin", Required = false)]
public string ServerLogin { get; set; }
/// <summary>
/// Treat the filename pattern as a regular expression. (Value 1 = true, 0 = false)
/// </summary>
/// <version>1.0</version>
/// <default>0</default>
[ReflectorProperty("searchregexp", Required = false)]
public int SearchRegExp { get; set; }
/// <summary>
/// Monitor and retrieve all files in child repositories of the specified repository. (Value 1 = true,
/// 0 = false).
/// </summary>
/// <version>1.0</version>
/// <default>0</default>
[ReflectorProperty("recursive", Required = false)]
public int Recursive { get; set; }
/// <summary>
/// Gets the modifications.
/// </summary>
/// <param name="from">From.</param>
/// <param name="to">To.</param>
/// <returns></returns>
/// <remarks></remarks>
public override Modification[] GetModifications(IIntegrationResult from, IIntegrationResult to)
{
string command = string.Format(System.Globalization.CultureInfo.CurrentCulture,"cc '{0}' -d{1}:{2} {3} -b'{4}' -p'{5}' {6} -z'{7}' -y'{8}'",
File,
from.StartTime.ToString(TO_SSCM_DATE_FORMAT, CultureInfo.CurrentCulture),
to.StartTime.ToString(TO_SSCM_DATE_FORMAT, CultureInfo.CurrentCulture),
(Recursive == 0) ?string.Empty : "-r",
Branch,
Repository,
(SearchRegExp == 0) ? "-x-" : "-x",
ServerConnect,
ServerLogin);
Modification[] modifications = GetModifications(CreateSSCMProcessInfo(command), from.StartTime, to.StartTime);
base.FillIssueUrl(modifications);
return modifications;
}
private ProcessInfo CreateSSCMProcessInfo(string command)
{
return new ProcessInfo(Executable, command);
}
/// <summary>
/// Labels the source control.
/// </summary>
/// <param name="result">The result.</param>
/// <remarks></remarks>
public override void LabelSourceControl(IIntegrationResult result)
{}
/// <summary>
/// Initializes the specified project.
/// </summary>
/// <param name="project">The project.</param>
/// <remarks></remarks>
public override void Initialize(IProject project)
{
Execute(CreateSSCMProcessInfo("workdir " + WorkingDirectory + " " + Repository + " -z" + ServerConnect + " -y" + ServerLogin));
}
/// <summary>
/// Gets the source.
/// </summary>
/// <param name="result">The result.</param>
/// <remarks></remarks>
public override void GetSource(IIntegrationResult result)
{
Log.Info("Getting source from Surround SCM");
result.BuildProgressInformation.SignalStartRunTask("Getting source from Surround SCM");
string command = string.Format(System.Globalization.CultureInfo.CurrentCulture,"get * -q -tcheckin -wreplace {0} -d'{1}' -b'{2}' -p'{3}' -z'{4}' -y'{5}'",
(Recursive == 0) ?string.Empty : "-r",
WorkingDirectory,
Branch,
Repository,
ServerConnect,
ServerLogin);
Execute(CreateSSCMProcessInfo(command));
}
}
}