equal
deleted
inserted
replaced
33 } |
33 } |
34 catch { |
34 catch { |
35 case ERROR(_) => None |
35 case ERROR(_) => None |
36 case _: XML.Error => None |
36 case _: XML.Error => None |
37 } |
37 } |
|
38 } |
|
39 |
|
40 |
|
41 /* consolidation status */ |
|
42 |
|
43 def maybe_consolidated(markups: List[Markup]): Boolean = |
|
44 { |
|
45 var touched = false |
|
46 var forks = 0 |
|
47 var runs = 0 |
|
48 for (markup <- markups) { |
|
49 markup.name match { |
|
50 case Markup.FORKED => touched = true; forks += 1 |
|
51 case Markup.JOINED => forks -= 1 |
|
52 case Markup.RUNNING => touched = true; runs += 1 |
|
53 case Markup.FINISHED => runs -= 1 |
|
54 case _ => |
|
55 } |
|
56 } |
|
57 touched && forks == 0 && runs == 0 |
38 } |
58 } |
39 |
59 |
40 |
60 |
41 /* command status */ |
61 /* command status */ |
42 |
62 |
417 |
437 |
418 |
438 |
419 /* document versions */ |
439 /* document versions */ |
420 |
440 |
421 def update(old_id: Document_ID.Version, new_id: Document_ID.Version, |
441 def update(old_id: Document_ID.Version, new_id: Document_ID.Version, |
422 edits: List[Document.Edit_Command], consolidate: Boolean) |
442 edits: List[Document.Edit_Command], consolidate: List[Document.Node.Name]) |
423 { |
443 { |
424 val edits_yxml = |
444 val edits_yxml = |
425 { |
445 { |
426 import XML.Encode._ |
446 import XML.Encode._ |
427 def id: T[Command] = (cmd => long(cmd.id)) |
447 def id: T[Command] = (cmd => long(cmd.id)) |
444 def encode_edits: T[List[Document.Edit_Command]] = list((node_edit: Document.Edit_Command) => |
464 def encode_edits: T[List[Document.Edit_Command]] = list((node_edit: Document.Edit_Command) => |
445 { |
465 { |
446 val (name, edit) = node_edit |
466 val (name, edit) = node_edit |
447 pair(string, encode_edit(name))(name.node, edit) |
467 pair(string, encode_edit(name))(name.node, edit) |
448 }) |
468 }) |
449 Symbol.encode_yxml(encode_edits(edits)) } |
469 Symbol.encode_yxml(encode_edits(edits)) |
|
470 } |
|
471 |
|
472 val consolidate_yxml = |
|
473 { |
|
474 import XML.Encode._ |
|
475 Symbol.encode_yxml(list(string)(consolidate.map(_.node))) |
|
476 } |
|
477 |
450 protocol_command( |
478 protocol_command( |
451 "Document.update", Document_ID(old_id), Document_ID(new_id), edits_yxml, consolidate.toString) |
479 "Document.update", Document_ID(old_id), Document_ID(new_id), edits_yxml, consolidate_yxml) |
452 } |
480 } |
453 |
481 |
454 def remove_versions(versions: List[Document.Version]) |
482 def remove_versions(versions: List[Document.Version]) |
455 { |
483 { |
456 val versions_yxml = |
484 val versions_yxml = |