Feature #22701
closedAllow forward reference to parent when importing issues
0%
Description
When importing issues via CSV with parent relations, the parent issues need to be positioned before child issues. Otherwise the relation will be ignored.
To work around this limitation, the issue import could be extended to use multiple passes:
- one to import basic issue properties
- one to import relations to other issues
This way it becomes easier to create the CSV files for imports, since order is no longer important.
This change would also be a prerequisite to import general issue relations. Since those cannot be more complex that parent relations and cannot necessarily be linearized properly.
Attached you find a patch series based on trunk r15361.
While implemented the changes, I tried to keep the Import
free from issue related information. Other existing Import
sub classes - within plugins e.g. - should need as little updates as possible.
0001 Extend test data for issue import¶
This change adds two rows to the existing issue import fixture file. These rows contain a parent and a child issue, while the parent is placed after the child. This would not import properly given the current implementation.
The patch also updates the existing tests, where the number of imported issues is asserted.
0002 Add test for issue relations to following rows¶
This patch extends the existing parent issue import test to also verify that the newly introduced parent child relation is properly imported. This test fails with the current implementation.
0003 Multi-pass CSV import¶
This patch defines a required_passes
method within Import
which returns 1
by default and may be overwritten in sub classes. The IssueImport
does so and returns 1
if no parent_id
mapping was set, otherwise it returns 2
.
The run
method is split into run
and run_pass
. The first one is recursive and called once for each pass. It also handles the max_*
options. The second is only responsible for reading the rows, creating or updating the ImportItems and passing everything to build_object
.
Since build_object
may now be called multiple times (once for each pass), the argument list was extended to provide more context. If somebody created a custom import in a plugin, this would need to be changed by the plugin's author.
In the IssueImport
, build_object
is now split into build_issue
and build_relations
, the first is called in the first pass, the second in pass 2.
The patch also contains a migration, which adds a completed_passes
field to ImportItem
. This is needed to properly (re-)store progress for multi-step imports, like the ones via the web UI.
Finally the patch adds some test to make sure, that the general behavior of multi-step imports did not change with the introduction of multi-pass imports.
Disclaimer: I know, this is a rather large change to fix a minor nuisance. But as mentioned earlier, I think, this change is a necessary prerequisite to support importing "Related Issues" properly, which I would like to contribute next, if this patch is accepted.
Files
Related issues
Updated by Jan from Planio www.plan.io over 8 years ago
- Target version set to Candidate for next minor release
Updated by Go MAEDA over 8 years ago
- Category set to Importers
- Target version changed from Candidate for next minor release to 3.4.0
Updated by Jean-Philippe Lang almost 8 years ago
- Subject changed from Multi-Pass CSV import to improve parent issue imports to Allow forward reference to parent when importing issues
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Resolution set to Fixed
Feature added in r16241 using a callback mechanism instead of the more complex multi-pass solution proposed in the patch.
It can be extend easily to support issue relations in the future as well.
Updated by Gregor Schmidt almost 8 years ago
Interesting approach. Thanks for taking care of this issue.
Updated by Toshi MARUYAMA over 7 years ago
- Has duplicate Feature #25799: Issue Import - Dynamic Parent pasks added
Updated by Mischa The Evil almost 7 years ago
- Related to Feature #28198: Support issue relations when importing issues added