Modify ↓
#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 , 6 years ago
Keywords: | merge history added |
---|
comment:2 by , 6 years ago
comment:3 by , 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 , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
As far as I remember it preserves the history of the oldest node (i.e. lower id).