this is a late reply and you possibly don't need it anymore, but I think I have finally understood the issue regarding "overlapping lenses in union.put", so I want to share my experience with you.
As you and David explained, Augeas has trouble when putting a tree into a file that (potentially) has nodes, which can be matched by more than one lens. This problem can be avoided in get direction, because parent nodes might be distinguishable in some way. We can make use of that key difference, by giving alternate node options to Augeas (as opposed to alternate expressions).
Say we have a tree
/a/color = "blue"
/b/color = "red"
Depending on the lens definitions for nodes "a" and "b", the "color" subnode might have to be read/written differently. Yet just from looking at the tree, Augeas cannot distinguish between either "color" node definition. That is what David said in his mail: "when Augeas sees a lens construct like 'l1|l2' it only looks at the labels of the tree node it's currently at to decide whether to use l1 or l2". In this situation, the label is identical for both nodes, hence the conflict.
How can we avoid this problem with actually applying ugly hacks? We change the construct such that Augeas has to consider the depth of the tree. Without concrete examples, this will be difficult to understand, so lets expand on the above example with these lens definitions:
let a = key "a" . [ label "color" . store /red|blue|green|yellow/ ]
let b = key "b" . [ label "color" . del /dark-/ "dark-" . store /red|blue|green|yellow/ ]
let lns = [ a | b ]
So for "b"-nodes color strings are prefixed with "dark-". When parsing a source file, Augeas can clearly distinguish between when to apply lenses "a" or "b". But because in either case the resulting "color"-node is identical, saving the tree to a file fails. We make Augeas aware of the difference on node-level, by alternating between nodes:
let lns = [ a ]|[ b ]
I hope this was somewhat understandable and helpful to you (or others finding this mail with Google J ).
augeas-devel mailing list
augeas-devel redhat com