Global version
namespace RevisionControl
{
partial static class Repository
{
public static int currentRevision = 0;
}
}
In C# the keyword partial may be used to break up a class definition into several
blocks. We use this here to indicate that blocks of code separated by explanatory
text all belong to the same class.
The state of the revision control system includes a global version number currentRevision.
This represents number of times any change has been committed to
the repository.
172 Modeling Systems with Structured State
In the code snippets that follow, we will omit for brevity the RevisionControl
namespace declaration that defines the model??™s scope, but this can be assumed.
Revision data type
In addition to the int and string data types, we will use an additional data record
to define the concept of a ???revision.???
enum Op { Add, Delete, Change }
class Revision : CompoundValue
{
public readonly Op op;
public readonly int revisionNumber;
public Revision(Op op, int revisionNumber)
{
this.op = op;
this.revisionNumber = revisionNumber;
}
}
The enumeration Op defines the kind of edit operations provided by the revision
control system. Edits may consist of adding a file, changing the contents of an existing
file, or deleting a file.
We define a new compound value type Revision that is a pair of values: an
operation and a revision number that says in which version of the repository the
change appears.
Pages:
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242