Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 161646 - support for Clone this bug
Summary: support for Clone this bug
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: 0.7   Edit
Hardware: All Windows XP
: P3 enhancement (vote)
Target Milestone: 2.2   Edit
Assignee: maarten meijer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 169426
  Show dependency tree
 
Reported: 2006-10-19 16:24 EDT by maarten meijer CLA
Modified: 2007-11-19 14:09 EST (History)
6 users (show)

See Also:


Attachments
Patch in reply to comment 7 (1.15 KB, patch)
2007-09-17 07:52 EDT, maarten meijer CLA
no flags Details | Diff
mylyn/context/zip (23.83 KB, application/octet-stream)
2007-09-17 07:52 EDT, maarten meijer CLA
no flags Details
Screen shot of menu position and text (55.77 KB, image/png)
2007-09-17 07:53 EDT, maarten meijer CLA
no flags Details
Bug 161646 - v1 - second upload (12.02 KB, patch)
2007-09-18 02:52 EDT, maarten meijer CLA
no flags Details | Diff
mylyn/context/zip (25.34 KB, application/octet-stream)
2007-09-18 02:52 EDT, maarten meijer CLA
no flags Details
mylyn/context/zip (38.06 KB, application/octet-stream)
2007-09-19 20:30 EDT, Mik Kersten CLA
no flags Details
Final edits (9.39 KB, patch)
2007-09-20 03:37 EDT, maarten meijer CLA
no flags Details | Diff
mylyn/context/zip (82.84 KB, application/octet-stream)
2007-09-20 03:37 EDT, maarten meijer CLA
no flags Details
Changed CloneTaskAction, delegated cloning, initial unit test (16.19 KB, patch)
2007-10-01 08:48 EDT, maarten meijer CLA
no flags Details | Diff
mylyn/context/zip (92.23 KB, application/octet-stream)
2007-10-01 08:48 EDT, maarten meijer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description maarten meijer CLA 2006-10-19 16:24:33 EDT
I need to go to the browser view to do a 'clone this bug' command.

I use this command in the situation where I have one application deployed on different sites.
Each site is a bugzilla product, so once I determine that a bug has occurences on different sites, I want to report that. I can then resolve (=deploy), verify (=see in production) and close for each site separately.

Can Mylar provide a Clone this Bug button on the form tab, or even as a popup menu item in the Task List?
Comment 1 Joseph Marques CLA 2006-11-21 13:02:46 EST
committers, I was thinking of working on this.  here are my thoughts:

semantics
* only tasks can be cloned at this point, simple task and repository tasks (we'll worry about the complications of cloning other things later if people request that feature explicitly)
* only one task can be cloned at a time (i suppose people could want to clone multiple issues simultaneously, but it's much more straightforward to do it this way
* clone ~= opening a new issue of the same type and intelligently filled in up with reasonable defaults from the selected issue (see questions below)

ui
* In the task list, have a rlight-click context menu option - "Clone" - just below rename above the separator bar
* if multiple issues are selected, it will fail with an informative error msg dialog explaining only one can be selected
* if a non-task item is selected, it will fail with an informative error msg dialog explaining that only simple or repository tasks can be cloned

questions:
1) should the new issue have an automatic link to the issue it was cloned from?
2) should the new issue have an empty list of comments?  (i'm thinking that linking the issues and leaving the description empty would be best because the most common use case for clone I can think of is when creating a single issue across various branches of development for a particular project, which to me means the comments would be divergent, just as the code bases are)
3) if you're cloning an issue that you didn't report, should the cloned issue keep the original reporter or be the current user?

Is there anything else anyone wants to see this fix contain?
Comment 2 maarten meijer CLA 2006-11-21 14:38:23 EST
I requested a button on the form page to implement the functionality in the browser. But...
the wider issue is bugtracking across multiple (n >= 2) code streams: see http://ask.slashdot.org/article.pl?sid=05/10/06/2248259 something which bugzilla offers only one solution for.
So maybe it should not be 'Clone this bug' (n += 1), but 'Cascade this bug' (1 += n), where you can copy the description to a range of products in one go: think of the list that pops up when doing a create new repository task.

1) Yes, the new issue should have a track back to the original, htough I'm not sure that this should be a 'dependency' (as in bugzilla with bug#, can only point back to the same bugzilla instance), but more of a 'related to" with a URL ref to the original issue. THis would allow cloning/cascading over mutiple repositories.

2) Empty comment list, it's a new issue. Cloning/cascading is just an convenience method.

3) Current user should be the reporter of the cloned issue, with maybe putting the original reporter on the cc list.

Next feature request would be to have a nice graphviz like View showing the graph or tree of related bugs color coded for resolution/status/priority ;-)
Comment 3 Joseph Marques CLA 2006-11-21 14:56:38 EST
My suggested solution for this issue was trying to keep things as simple as possible, while still hitting most of the common use cases.  The original description does mention, "or even as a popup menu item in the Task List", so that's what I went with.  However, I suppose this functionality could *also* be exposed as a clone button on an opened task.

1) It wasn't my intention to make this a generic, cross-type clone operation.  It meant meant to clone bugzilla issues -> bugzilla issues, jira issues -> jira issues, etc.  If this is a needed feature, can we get some other comments on it?

2) OK, good, we're in agreement.

3) Sounds like a good suggestion to me.
Comment 4 Willian Mitsuda CLA 2006-11-21 15:41:39 EST
Joseph, I believe the original intend of this bug was to support the native "clone" from bugzilla.

You came out with a more generic, repository-aware, multi-repository, very powerful solution, which is very good :)

I never had thought about this before, and sounds like a excellent idea.
Comment 5 Robert Elves CLA 2006-11-21 15:56:25 EST
This sounds great so far. Regarding the ui, if we go with adding clone to the popup we can just disable the action in the case of multiple selections / invalid tasklistelement selections. 
Comment 6 Joseph Marques CLA 2006-11-21 16:05:40 EST
Thanks guys.  I appreciate the feedback.   ; )

I think it's important to try and add value above and beyond what the underlying repos already provide - it gives people a greater incentive to use Mylar instead of more familar interfaces.  

Generally, I'd love to see Mylar completely blur the lines between what the different repositories provide.  Towards that end, my aim is consistency, and thus why I wanted to implement it as a generic layer for all types of tasks.
Comment 7 Mik Kersten CLA 2006-11-21 17:06:10 EST
This sounds excellent Maarten, and my thoughts are in line with the discussion above and I like the spec in comment#1.  Doing the simplest thing to get this working first is actually the generic thing, so here are some concrete steps for how I suggest proceeding, and then we can build this out from there:
1) Add clone action to Task List popup menu, this will grab the ITask object selected
2) Make the action reuse the MultiRepositoryAwareWizard for selecting the repository
3) After the repository is selected, if the repository has a new task editor (AbstractRepositoryConnector.canCreate..(..)) open that new editor and fill in all generic fields that you can
4) Provide an URL-based link back to the originating bug in the description, probably right at the top.

After this generic support is there, we will be able to delegate to connectors for duplicating connector-specific common fields.  This won't support turning repository tasks into local until bug 124321 is resolved.  Also, this solution could remove the need for bug 152211.

Also note that this functionality is similar to NewTaskFromErrorAction, since it also pre-populates the content of the task.  The attached context has the elements mentioned here as landmarks.
Comment 8 Joseph Marques CLA 2006-11-21 17:23:42 EST
Mik, thanks for the pointers.  I'll keep it in mind, and get on this tonight.
Comment 9 Eugene Kuleshov CLA 2007-09-10 20:43:55 EDT
Since there have been no feedback reassigning to default.
Comment 10 maarten meijer CLA 2007-09-17 07:51:30 EDT
 (In reply to comment #7)
 Hi Mik,
 
 this has been open for too long so I decided to help out here. 
> 1) Add clone action to Task List popup menu, this will grab the ITask object
> selected
See attachment image, I have used CMD-D for duplicate. Need to do a proper icon still.
> 2) Make the action reuse the MultiRepositoryAwareWizard for selecting the
> repository
Done, can create a new repository task
> 3) After the repository is selected, if the repository has a new task editor
> (AbstractRepositoryConnector.canCreate..(..)) open that new editor and fill in
> all generic fields that you can
Only two text fields are easily settable, the rest are menu's
> 4) Provide an URL-based link back to the originating bug in the description,
> probably right at the top.
This works.

> After this generic support is there, we will be able to delegate to connectors
> for duplicating connector-specific common fields. 
I think we must add an single overrideable copyFrom(AbstractTask task) method where an editor can set all fields from the originating task, which then chains back up using super();
I'm a bit stuck now for what is in AbstractTask and what in the bugzilla one
Comment 11 maarten meijer CLA 2007-09-17 07:52:35 EDT
Created attachment 78540 [details]
Patch in reply to comment 7

Still need to work out how to set all the other fields from the originating task.
Comment 12 maarten meijer CLA 2007-09-17 07:52:38 EDT
Created attachment 78541 [details]
mylyn/context/zip
Comment 13 maarten meijer CLA 2007-09-17 07:53:49 EDT
Created attachment 78542 [details]
Screen shot of menu position and text
Comment 14 Mik Kersten CLA 2007-09-17 23:30:53 EDT
Excellent!  The patch contains the comment text, could you please cut it again?
Comment 15 maarten meijer CLA 2007-09-18 02:52:51 EDT
Created attachment 78610 [details]
Bug 161646 - v1 - second upload

Adding clone this bug in the way Mik described
Comment 16 maarten meijer CLA 2007-09-18 02:52:52 EDT
Created attachment 78611 [details]
mylyn/context/zip
Comment 17 maarten meijer CLA 2007-09-18 03:54:27 EDT
I was planning on putting the copying in AbstractRepositoryTaskEditor method thus:
	/**
	 * Fill the new task editor from an existing task. Implement in subclasses to
	 * copy more fields when from the same or a 'friend' repository kind.
	 *
	 * @param task the task to copy fields from
	 */
	public void fillFromTask(AbstractTask task) {
		// ignore
		this.setSummaryText(task.getSummary() + " (cloned)");
		this.setDescriptionText("Clone of bug#" + CopyTaskDetailsAction.getTextForTask(task));
		// TODO set other standard repository fields here, like:
		// priority, severity, resolution, status, reporter , etc

		// TODO override this in the subclasses to set extra fields!
	}

Then this can be overridden in subclasses. But I also found AbstractNewRepositoryTaskEditor.
What is the difference and is that a better place?
Comment 18 maarten meijer CLA 2007-09-18 07:50:19 EDT
The following worked...

5663: LoadTest (cloned)
https://landfill.bugzilla.org/bugzilla-tip/show_bug.cgi?id=5663
Comment 19 Mik Kersten CLA 2007-09-19 20:30:20 EDT
Patch applied.  Great stuff Maarten!  Please review my changes, in particular noting the following:
* Renamed action to CloneTaskAction
* Suppress showing it for local tasks because the interaction was a bit weird, but we consider adding
* Changed to use BaseSelectionListenerAction
* Changed to use target task's prefix (e.g. "issue" for JIRA vs. "bug" for Bugzilla)

Could you also provide a unit test that invokes this action on a MockRepositoryTask or a BugzillaTask and verifies that the summary was set properly on the new task?

Shawn: this is very closely related to your efforts on bug 203471, so you may want to look over this and comment.
Comment 20 Mik Kersten CLA 2007-09-19 20:30:57 EDT
Created attachment 78803 [details]
mylyn/context/zip
Comment 21 maarten meijer CLA 2007-09-20 03:30:36 EDT
 (In reply to comment #19)
> * Renamed action to CloneTaskAction
also renamed instance variable
> * Suppress showing it for local tasks because the interaction was a bit weird,
> but we consider adding
> * Changed to use BaseSelectionListenerAction
> * Changed to use target task's prefix (e.g. "issue" for JIRA vs. "bug" for
> Bugzilla)
Use AbstractNewRepositoryTaskEditor. instead of AbstractRepositoryTaskEditor.
Moved all of that into a new method in AbstractNewRepositoryTaskEditor.
Added a stub method in the bugzilla implementation (still need to find out how it stores it attributes)
> 
> Could you also provide a unit test that invokes this action on a
> MockRepositoryTask or a BugzillaTask and verifies that the summary was set
> properly on the new task?
will do
> Shawn: this is very closely related to your efforts on bug 203471, so you may
> want to look over this and comment.
Comment 22 maarten meijer CLA 2007-09-20 03:37:36 EDT
Created attachment 78822 [details]
Final edits

Moved cloning/setting to overridable method AbstractNewRepositoryTaskEditor
Renamed instance variable
Added stub in bugzilla implementation
Comment 23 maarten meijer CLA 2007-09-20 03:37:39 EDT
Created attachment 78823 [details]
mylyn/context/zip
Comment 24 maarten meijer CLA 2007-09-20 04:46:11 EDT
 (In reply to comment #19)
> Could you also provide a unit test that invokes this action on a
> MockRepositoryTask or a BugzillaTask and verifies that the summary was set
> properly on the new task?
All existing unit tests for actions only test the static methods in those Actions.
As I have put the copy in a overridable method in the editor, I can;' test, as there is no MockEditor :-(
Please provide some tips on how to do this!
Comment 25 Eugene Kuleshov CLA 2007-09-28 16:52:11 EDT
Mik, Rob, this is a bugday bug that need followup. Can you please advise on testing issues and review attached patch. It also seems like patch went stale and need to be recreated, which is unfortunate.
Comment 26 Mik Kersten CLA 2007-09-28 17:12:16 EDT
Eugene: the patch was applied and was included in 2.1.

Maarten: a good way to test this would be to tell a new MockRepositoryTask to duplicate itself, then inspect the workbench to see what editors are open, find the new editor, and check that its Description was populated correctly.  It may be more straightforward for you to just create a MockTaskEditor as you imply.  Let me know if you would like additional pointers to similar test code.  Also see: http://wiki.eclipse.org/index.php/Mylyn_Contributor_Reference#Writing_Tests
Comment 27 maarten meijer CLA 2007-10-01 08:28:39 EDT
 (In reply to comment #26)
> Maarten: a good way to test this would be to tell a new MockRepositoryTask to
> duplicate itself, then inspect the workbench to see what editors are open, find
> the new editor, and check that its Description was populated correctly.  It may
> be more straightforward for you to just create a MockTaskEditor as you imply.
> Let me know if you would like additional pointers to similar test code.  Also
> see: http://wiki.eclipse.org/index.php/Mylyn_Contributor_Reference#Writing_Tests

I've tried to follow your tips. I create a new MockRepository and the copy one task.
To do this, I've refactored the run() method. run() now gets the selection form the TaskManager and calls a new
 static method cloneTask(AbstractTask task) that will do the repository selection and cloning.
 I can thus call cloneTask(task) with a task from the MockRepository in my unit test.
 
 However the new task editor can not be retrieved in this part as apparently UI threads are blocked during the unit test.
 So the new task editor only comes up once the unit test has failed :-(
 
This can occur in real life as well so I have added a waitUI() method like delay() in chapter 2.8 Writing Plug-in Tests in "Building Commercial Quality Plug-ins"

Next problem is that I feel that the Editor should derive from AbstractNewRepositoryTaskEditor, not AbstractRepositoryTaskEditor like in your code.
After all this is an editor for a task created but not yet present in a repository.

Then the actual copying of fields can be delegated to a method in every subclass of AbstractNewRepositoryTaskEditor, like BugzillaNewRepositoryTaskEditor.
This is the method to override to copy more fields than the two done now. 

Alas MockRepository returns a TaskEditor which is not a subsclass of AbstractNewRepositoryTaskEditor :-(
Comment 28 maarten meijer CLA 2007-10-01 08:48:31 EDT
Created attachment 79469 [details]
Changed CloneTaskAction, delegated cloning, initial unit test

I've split the cloneTaskAction so it can be called easier from a unit test.

The MockRepository does not subclass AbstractNewRepositoryTaskEditor so fails and produces some text to copy paste.

The copying should be in the editor or subclass, as that allows the copying of more field sfor a known original Task type.
Comment 29 maarten meijer CLA 2007-10-01 08:48:35 EDT
Created attachment 79470 [details]
mylyn/context/zip
Comment 30 Mik Kersten CLA 2007-10-26 14:00:13 EDT
Rob: please review.
Comment 31 Robert Elves CLA 2007-11-14 17:09:52 EST
We're holding off on this until we can make use of the api that emerges from bug#209402.
Comment 32 Steffen Pingel CLA 2007-11-15 21:09:01 EST
The API that let's connectors initialize the new task editor from existing tasks has been merged. Maarten, please take a look at the changes that were made to CloneTaskAction and AbstractTaskDataHandler.cloneTaskData(). Please comment if the implementation is not sufficient to support cloning of tasks.

I'll look into improving support for JIRA and Bugzilla which still clone the old way that only sets summary and description but does not copy other attributes.
Comment 33 maarten meijer CLA 2007-11-17 09:58:51 EST
 (In reply to comment #32)
> .... Please comment if
> the implementation is not sufficient to support cloning of tasks.
In my old implementation I also put a '(Cloned)' suffix after the summary, but that is cosmetic.
I still wonder how we're going to handle moving a bug from say bugzilla to JIRA. use the adapter mechanism and create some sort of generic task?
I'm happy for now and see the value of creating api. Now you can clone a bug, create a bug from a comment, create a sub-task, all the time back linking to the originator.
Comment 34 Steffen Pingel CLA 2007-11-19 14:09:21 EST
 (In reply to comment #33)
> I still wonder how we're going to handle moving a bug from say bugzilla to JIRA.
> use the adapter mechanism and create some sort of generic task?

Yes, implementing mapping support for converting between different task models or to a more extensive generic format is certainly on the table for 3.0.