Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#16808 closed defect (wontfix)

Merging two nodes does not preserve the longest history

Reported by: pangoSE Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: merge history Cc:

Description

Hi
Merging two nodes does not always preserve the longest history.
Is it possible to implement this?

Cheers

Attachments (0)

Change History (5)

comment:1 by Don-vip, 6 years ago

Keywords: merge history added

comment:2 by stoecker, 6 years ago

As far as I remember it preserves the history of the oldest node (i.e. lower id).

comment:3 by Don-vip, 6 years ago

Yes:

    /**
     * Find which node to merge into (i.e. which one will be left)
     *
     * @param candidates the collection of candidate nodes
     * @return the selected target node
     */
    public static Node selectTargetNode(Collection<Node> candidates) {
        Node oldestNode = null;
        Node targetNode = null;
        Node lastNode = null;
        for (Node n : candidates) {
            if (!n.isNew()) {
                // Among existing nodes, try to keep the oldest used one
                if (!n.getReferrers().isEmpty()) {
                    if (targetNode == null || n.getId() < targetNode.getId()) {
                        targetNode = n;
                    }
                } else if (oldestNode == null || n.getId() < oldestNode.getId()) {
                    oldestNode = n;
                }
            }
            lastNode = n;
        }
        return Optional.ofNullable(targetNode).orElse(oldestNode != null ? oldestNode : lastNode);
    }

comment:4 by stoecker, 6 years ago

Resolution: wontfix
Status: newclosed

comment:5 by pangoSE, 6 years ago

Thanks for the quick response.

Last edited 6 years ago by pangoSE (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.