What should happen when I copy a tree that contains a clone?
On Wed, May 20, 2020 at 9:06 AM Thomas Passin <tbp1...@gmail.com> wrote:What should happen when I copy a tree that contains a clone?Leo copies the tree to the clipboard as is, that is, retaining gnx's. What happens next depends on how you paste the tree:- The paste-node (Ctrl-Shift-v), command allocates new gnx's for all pasted nodes.- The paste-retaining-clones command (Paste Node As Clone, from the Outline menu), retains the gnx's for all pasted nodes.Either way, if the pasted tree contains clones (nodes with more than one link to them in the pasted tree) then those nodes will be cloned after the paste.
This sounds as if a cloned node in the original tree will end up as a cloned node in the final tree. That is not what I see, though. The node that is a clone in the original tree becomes a copy (not a clone) in the pasted tree. That would fit in with "new gnx's for all pasted nodes".
Thanks for this excellent clarification. This should be doable with a a new command, say, paste-retaining-only-clones. I have just created #1593 for this.
Thanks for this excellent clarification. This should be doable with a a new command, say, paste-retaining-only-clones. I have just created #1593 for this.Edward
On Saturday, May 23, 2020 at 7:09:20 AM UTC+10, Edward K. Ream wrote:On Fri, May 22, 2020 at 1:06 PM Thomas Passin <tbp1...@gmail.com> wrote:This sounds as if a cloned node in the original tree will end up as a cloned node in the final tree. That is not what I see, though. The node that is a clone in the original tree becomes a copy (not a clone) in the pasted tree. That would fit in with "new gnx's for all pasted nodes".You misunderstand me. If there are two (cloned nodes) A in the copied tree, those clones will be clones of each other in any pasted tree, as I have just verified.It's harder to describe what happens than to verify what happens. I'm quite sure Leo does the correct thing in all situations.I want to declare my interest in this subject. I have use cases similar to what it seems Thomas has, which would benefit significantly from the functionality I believe he's seeking.Edward, I also think I understand what you're referring to, but I think you are referring to a different concern (preserving the nature of clones that are internal to the tree being copied). I believe Thomas is referring to how clones are handled when copying a tree that contains clones of nodes that are outside the tree being copied. If so, I'm interested in this problem also. Also, I think Thomas is not indicating a bug, but rather enquiring about additional functionality.What I think both Thomas and I are interested in achieving is as follows. Let's say we have a tree like below. Note that all nodes are NOT clones unless specifically stated:
[snip]
Let's say we have a tree like below. Note that all nodes are NOT clones unless specifically stated:Node A+ Node A1+ Node A2+ Node A3Node B+ Node A1 (a clone)+ Node B2+ Node A3 (a clone)
Let's say we have a tree like below. Note that all nodes are NOT clones unless specifically stated:Node A+ Node A1+ Node A2+ Node A3Node B+ Node A1 (a clone)+ Node B2+ Node A3 (a clone)There is a problem in your example. A1 and A2 can't be clones in node B unless A1 and A3 are clones in Node A (or somewhere else). Did you mean that A1 and A2 in A should also be clones? It makes a difference.This question is: "what nodes should be clones after the copy and paste?" There are at least two possible answers:1. [non-local] All nodes in B that were clones when B was copied, provided that they could again be clones after being pasted.2. [local] Only nodes in B that were clones of other nodes in B when the copy was made.I infer answer 1 if A1 and A3 in A should have been labeled "a clone". Otherwise, I infer answer 2.
Node X
+ Node X1
+ Node X2
+ Node X3
Node X + Node X1 + Node X2 + Node X3Node Y + Node Y1 # an "internal" clone of Y1 below + Node Y2 + Node Y1 # an "internal" clone of Y1 above + Node Y3 + Node X3 # an "external" clone of X3 which is under Node XNode X
+ Node X1
+ Node X2
+ Node X3
Node Y
+ Node Y1 # an "internal" clone of Y1 below
+ Node Y2
+ Node Y1 # an "internal" clone of Y1 above
+ Node Y3
+ Node X3 # an "external" clone of X3 which is under Node X
Node Y # a copy
+ Node Y1 # a copy, but an internal clone of Node Y1 (below)
+ Node Y2 # a copy
+ Node Y1 # a copy, but an internal clone of Node Y1 (above)
+ Node Y3 # a copy
+ Node X3 # an "external" clone of X3 which is under Node X
Node A+ Node A1 (a clone)+ Node A2+ Node A3 (a clone)
Node B+ Node A1 (a clone)+ Node B2+ Node A3 (a clone)
Node A+ Node A1 (a clone)+ Node A2+ Node A3 (a clone)
Node B+ Node A1 (a clone)+ Node B2+ Node A3 (a clone)
Node C
+ Node A1 (a clone)+ Node B2+ Node A3 (a clone)
@file FA+ Node A@file FB+ Node B@file FC+ Node C
or
Said simpler:Does cloning a normal node, make BOTH nodes clones?
Or is there still an idea of "this is the original" (A>A1) and "this is a clone of the original" (B>A1)
I'm going to assume you made a typo in your reference to A2, because A2 is not involved in the proposed clone-preserving copy-and-paste.
Y
+ Node Y1 # a copy, but an internal clone of Node Y1 (below)
+ Node Y2 # a copy
+ Node Y1 # a copy, but an internal clone of Node Y1 (above)
+ Node Y3 # a copy
+ Node X3 # an "external" clone of X3 which is under Node X
For brevity, I denote clones that are internal to the source tree only as "local clones". In the templating use case, I think there's a strong case to be made for NOT linking local clones under the source node in the the copied tree. Doing so allows provisioning of clones internally in the source "template" that define content that is shared around the children of the template, but is likely to be different in deployments (copies) of that template.
I hope that makes sense.
Please note I edited my earlier post to clear up some potential ambiguities.
Also, after posting I realized that I also needed to clarify that a clone in the source tree is only considered to be a local clone if it has no clones outside the source tree, in which case those nodes in the duplicated tree will be cloned within the duplicated tree but distinct from the source tree. So a source tree that contains multiple clones within the source tree but also at least one clone outside the source tree is NOT considered a local clone for our purposes. So these clones in the copied tree will be also be clones of those nodes in the source tree.
Personally I have felt (more than once) a need for this kind of command in the past. It is hard to make a simple rule that this command should follow to decide which nodes to clone and which nodes to copy. Whatever rule we decide on, it will lead to ambiguous situations when tree changes between copy and paste command.
Perhaps this can be simplified to this command: `paste-retaining-marked-nodes`. User can mark nodes that are to be retaining identity after paste. All other nodes should have new identities after paste. I guess this would be trivial to implement and user would have full power over the effect of the command.
Couldn't a paste-as-template just traverse the tree and make new
clones where they already are clones and just copy as new nodes
everywhere else?
CONCLUSION:Thomas really needs 'include' of the code snippet instead of cloned code. Clones are no good for his case.
Couldn't a paste-as-template just traverse the tree and make new
clones where they already are clones and just copy as new nodes
everywhere else?
Might it be an easy enough rule to say that:
On Wed, May 27, 2020 at 4:56 AM Seth Johnson <seth.p...@gmail.com> wrote:Couldn't a paste-as-template just traverse the tree and make new
clones where they already are clones and just copy as new nodes
everywhere else?Much easier said than done, as I recently discovered.
we need a new copy command, after which the paste-retaining-clones command can be used as is.
CONCLUSION:Thomas really needs 'include' of the code snippet instead of cloned code. Clones are no good for his case.
we need a new copy command, after which the paste-retaining-clones command can be used as is.
Using the marked flag might not work as expected, because it might already have been set for some other reason. Perhaps a node should have a new flag denoting its cloned status.
Mark bits are really relevant only when copying node. After the copy has been made, the information which nodes were marked is on the clipboard and therefore is available to the paste-retaining-marked command. Even after unmark-all command as long as the clipboard is not changed, paste-retaining-marked will do its job correctly.Of course there can be assigned another flag for this purpose but I've never used marks for anything else but for clone-marked-nodes command. Perhaps there is something else that this flag can be used for but I am not aware of it. If its main purpose is to mark nodes user wish to clone in the future, then it seems to me a fair use case for this command.
On 5/27/20, vitalije <vita...@gmail.com> wrote:
> @Differance
Speaking roughly, I think regardless of the structure of the tree
you've put in the clipboard, you can identify some that are clones of
each other within the tree -- can't you look at vnodes to see the
clones?
On 5/27/20, Seth Johnson <seth.p...@gmail.com> wrote:
The simple approach is if there are more than one of the same
vnode in the outline you've grabbed to paste-as-template, those all
get a new vnode and become clone-nodes pointing to that instead. If
they are loners within the outline you've grabbed, make them plain,
non-clone nodes.
def is_unique(v):
while v is not c.hiddenRootNode:
if len(v.parents) == 1:
v = v.parents[0]
else:
return False
return True> Indeed we can look at vnodes and we'll see that each node found on the
> clipboard has a corresponding node with the exactly the same gnx among the
> known vnodes (providing that we copied from the same outline and that
> outline has not been modified since). If we use this information to decide
> whether node should be cloned or not then each node will be cloned and we
> would have just what paste-retaining-clones does.
Right! And you would be able to identify "internal sets" that match
and easily template-as-encapsulated with new vnodes, if the user
chooses to do the encapsulated template mode.