partial static class User
{
static bool EditEnabled(string user, string file, Op op)
{
return (CanStep(user) &&
!revisions[user].ContainsKey(file) &&
(Repository.FileExists(file, version[user]) ?
op != Op.Add : op == Op.Add));
}
[Action]
static void Edit([Domain("Users")] string user,string file,Op op)
{
Map
userRevisions = revisions[user];
Systems with Complex State 177
revisions = revisions.Override(user, userRevisions.Add(file,
(op == Op.Delete ? Op.Delete : Op.Add)));
}
}
Revert action
Edits may be undone using the Revert action. This restores the client??™s view a given
file to be consistent with the last update (checkout) operation.
partial static class User
{
static bool RevertEnabled(string user, string file)
{
return CanStep(user) && revisions[user].ContainsKey(file);
}
[Action]
static void Revert([Domain("Users")] string user, string file)
{
revisions = revisions.Override(user,
revisions[user].RemoveKey(file));
}
}
Commit action
The Commit action begins the process of recording edits made by a client in the
global repository.
partial static class User
{
static bool CommitEnabled(string user)
{
return CanStep(user);
}
[Action]
static void Commit([Domain("Users")] string user)
{
commitPending = commitPending.Add(user);
178 Modeling Systems with Structured State
IdentifyConflicts(user, version[user]);
version = version.
Pages:
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247