elliotchance / gedcom

👪 A Go library and CLI tools for encoding, decoding, traversing, merging, comparing, querying and publishing GEDCOM files.
MIT License
94 stars 21 forks source link

Document context for copying nodes #305

Closed elliotchance closed 4 years ago

elliotchance commented 4 years ago

A bug was found in DeepCopy (or really anything that ends up copying a node) that some nodes (such as the husband, wife or child) cannot be created without a FamilyNode. The bug was that the FamilyNode was not being tracked at a high enough level so duplicated nodes would not inherit it correctly. Even though there was already code to do that, it wasn't working correctly.

This lead to a greater look at how the APIs work and I realised that the document must be provided in many cases because any process that directly or indirectly needs to copy a node will need this proper context.

Even though this patch breaks several of the existing APIs (by adding a document parameter) none of the behaviour has changed. If you are unsure when updating the library you should create a new document and pass it in for that parameter.

Fixes #301


This change is Reviewable