Opened 6 years ago

Closed 5 years ago

# [PATCH] Handle references between imported tickets

Reported by: Owned by: Chris Nelson Chris Nelson normal TicketImportPlugin normal ticket dependency subtask wbs 0.11

### Description

This enhancement facilitates importing projects from Microsoft Project or similar programs by handling references to other tickets in the import such as dependencies and WBS (parent/child). Dependencies work well with the MasterTicket plugin. I know of no good support for parent/child tasks yet.

For example:

 summary #blockedby #wbs Design schematic 1 Layout board 1 2 Check board 2 2.1 Manufacture prototypes 2,3 2.2 Prototype verification 4 3

Once imported, this list might become:

 id summary blockedby wbs 3000 Design schematic 3001 Layout board 3000 3003 Check board 3001 3001 3004 Manufacture prototypes 3001,3003 3001 3005 Prototype verification 3004

This is provided in several patches which first change some plugin code to facilitate the enhancement, then add dependency support, then add WBS support. Each patch depends on those before it but can be used without those after it.

### Changed 6 years ago by Chris.Nelson@…

Fix a typo in a comment

### Changed 6 years ago by Chris.Nelson@…

Keep a list of added, modified tickets, count at end.

### Changed 6 years ago by Chris.Nelson@…

Move form to top of page. (Experienced users don't need the details every time.)

### Changed 6 years ago by Chris.Nelson@…

Handle relative ticket fields

### Changed 6 years ago by Chris.Nelson@…

Handle WBS numbers

### Changed 6 years ago by Chris.Nelson@…

Combined patch (all of the other changes in one file).

### comment:1 Changed 6 years ago by Chris.Nelson@…

Sorry for the compressed tar files but when I tried to upload a couple of my patches, TH complained about "blacklisted patterns" in the text.

### Changed 6 years ago by Chris.Nelson@…

Improved WBS patch

### Changed 6 years ago by Chris.Nelson@…

Revised comprehensive patch (with new WBS changes)

### comment:2 follow-ups:  4  5 Changed 6 years ago by François Granade

Owner: changed from François Granade to Chris.Nelson@…

I'd love to take your patch ! however, could i ask you to add a few tests ?

It should be easy - see for example [9725] for fix that has a test...

If you want I can make you committer if it's easier for you.

### comment:3 Changed 6 years ago by Adrian Fritz

Summary: Handle references between imported tickets → [PATCH] Handle references between imported tickets

### comment:4 in reply to:  2 Changed 6 years ago by Chris Nelson

I'd love to take your patch ! however, could i ask you to add a few tests ?

It should be easy - see for example [9725] for fix that has a test...

I'll take a look at that and attach another patch if I figure it out.

If you want I can make you committer if it's easier for you.

### comment:5 in reply to:  2 Changed 6 years ago by Chris Nelson

I'd love to take your patch ! however, could i ask you to add a few tests ?

It should be easy - see for example [9725] for fix that has a test... ...

A CSV file is easy but I have no idea what the .ctl files are or how to generate them.

### comment:6 Changed 6 years ago by François Granade

Hello Chris

the .ctl (control) file(s) are simply copies of the .out (output) file(s) generated by each test. The idea is: when you are happy with the output that you see when importing the file manually in your Trac instance, you just run the test(s) from the command line, and you rename or copy the .out file to .ctl, and then commit the .ctl. When rerunning the tests, the .ctl files will be compared with .out file generated, to ensure the result is the same.

Note that since the output aren't exactly the same on 0.11 and 0.12, there are two sets of control files: if possible at leat commit them for 0.11

Hope it helps

### comment:7 Changed 6 years ago by Ryan J Ollos

Owner: changed from Chris.Nelson@… to Chris Nelson changed from Chris.Nelson@… to Chris Nelson

### comment:8 Changed 5 years ago by falkb

Hi, could you please update the patch? The current SVN revision isn't patchable:

...
The text leading up to this was:
--------------------------
|diff --git a/0.11/talm_importer/importer.py b/0.11/talm_importer/importer.py
|index 6bcbdb9..e16d003 100644
|--- a/0.11/talm_importer/importer.py
|+++ b/0.11/talm_importer/importer.py
--------------------------
File to patch: talm_importer/importer.py
patching file talm_importer/importer.py
Hunk #1 succeeded at 203 (offset 12 lines).
Hunk #2 succeeded at 259 (offset 12 lines).
Hunk #3 succeeded at 325 (offset 17 lines).
Hunk #4 FAILED at 369.
1 out of 4 hunks FAILED -- saving rejects to file talm_importer/importer.py.rej
can't find file to patch at input line 71
Perhaps you used the wrong -p or --strip option?

...

patching file talm_importer/templates/importer.html
Hunk #1 succeeded at 31 with fuzz 2.
Hunk #3 FAILED at 110.
1 out of 3 hunks FAILED -- saving rejects to file talm_importer/templates/import
er.html.rej
...


### comment:9 Changed 5 years ago by François Granade

Patch updated in all.3.tgz -- should work now on the 0.11 branch (which also works on 0.12).

Chris, as soon as you have a little bit of tests on this, I'll be glad to apply the patch.

### comment:10 Changed 5 years ago by François Granade

Resolution: → fixed new → closed

Actually, I ended up applying the patch to the 0.11 branch - in [11745]. It may not work 100% correctly but it's not breaking anything. Marking this as fixed, even though I'd glad to have tests...

### comment:11 Changed 5 years ago by falkb

Thanks a lot, gonna test it on Monday

### comment:12 Changed 5 years ago by falkb

Nope, doesn't work:

 KeyError: u'#blockedby'

callstack is:

Datei "build/bdist.win32/egg/trac/web/main.py", Zeile 511, in _dispatch_request
dispatcher.dispatch(req)
Datei "build/bdist.win32/egg/trac/web/main.py", Zeile 237, in dispatch
resp = chosen_handler.process_request(req)
Datei "build/bdist.win32/egg/talm_importer/importer.py", Zeile 78, in process_request
encoding=req.session['importer.encoding'])
Datei "build/bdist.win32/egg/talm_importer/importer.py", Zeile 122, in _do_preview
Datei "build/bdist.win32/egg/talm_importer/importer.py", Zeile 389, in _process
relativeticketvalues.append(dict([(f, row['#'+f]) for f in relativeticketfields]))


### comment:13 follow-up:  14 Changed 5 years ago by falkb

it seems it's because the .xls file uses '#BlockedBy' instead of '#blockedby' ...although the docs say it shouldn't matter.

### comment:14 in reply to:  13 ; follow-up:  15 Changed 5 years ago by François Granade

it seems it's because the .xls file uses '#BlockedBy' instead of '#blockedby' ...although the docs say it shouldn't matter.

I can't find where it's written in the doc, could you point me to it ? I doesn't seem easy to fix in the code, so I'd rather fix the docs...

### comment:15 in reply to:  14 ; follow-up:  16 Changed 5 years ago by falkb

I can't find where it's written in the doc, could you point me to it ? I doesn't seem easy to fix in the code, so I'd rather fix the docs...

I asked the user and it turns out he has read it on the web page displayed when one clicks on mainnav menu item "Import". The text says:

"...The fields must be Trac fields. The valid fields for this Trac instance are: ticket or id, summary, reporter, ...snip... , blockedby, blocking, ...snip... and . Field names are case-insensitive: 'summary', 'Summary', 'SUMMARY' refer to the same field. ..."

### comment:16 in reply to:  15 Changed 5 years ago by Chris Nelson

I can't find where it's written in the doc, could you point me to it ? I doesn't seem easy to fix in the code, so I'd rather fix the docs...

I asked the user and it turns out he has read it on the web page displayed when one clicks on mainnav menu item "Import". The text says:

"...The fields must be Trac fields. The valid fields for this Trac instance are: ticket or id, summary, reporter, ...snip... , blockedby, blocking, ...snip... and . Field names are case-insensitive: 'summary', 'Summary', 'SUMMARY' refer to the same field. ..."

It seems likely that the main plugin downcases field names and my patch fails to.

### comment:17 Changed 5 years ago by François Granade

Actually, I ended up fixing this issue with the case - in [11758] - now things should work correctly no matter the case of the field name.

### comment:18 Changed 5 years ago by falkb

Cool, the preview says everything is OK now, though due other reasons we haven't completed the import yet. Gonna report the result as soon as done...

### Modify Ticket

Action
as closed The owner will remain Chris Nelson.
The resolution will be deleted. Next status will be 'reopened'.