Bug 410661 - "Open Commit" does not work
Summary: "Open Commit" does not work
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Client (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: Mark Macdonald CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 411282
  Show dependency tree
 
Reported: 2013-06-12 16:10 EDT by Mark Macdonald CLA
Modified: 2013-06-21 09:25 EDT (History)
4 users (show)

See Also:
mamacdon: review?
ken_walker: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Macdonald CLA 2013-06-12 16:10:02 EDT
1. Go to the git repository page
2. Press Ctrl+Shift+H
3. A notification appears saying "No commits found"

It is supposed to prompt for the SHA-1 of a commit or something.
Comment 1 Maciej Bendkowski CLA 2013-06-14 10:24:48 EDT
As far as I can tell, the problem is caused by missing parameter collection in case of a key-binded command, which is never rendered. The command relies on the given commit name parameter, which is in our case 'undefined'.
Comment 3 Mark Macdonald CLA 2013-06-14 10:27:24 EDT
ha ha, oops -- wrong bug. Ignore comment 2
Comment 4 Szymon Brandys CLA 2013-06-20 09:31:12 EDT
As per Maciek's comment, the problem is something in the command framework. Right now the command is added this way:
commandRegistry.registerCommandContribution("repoPageActions", "eclipse.orion.git.openCommitCommand", 1000, null, true, new KeyBinding.KeyBinding('h', true, true)) and keyBindingOnly is true. When we change keyBindingOnly to false, the param collector works again.

Talked to Mark and he said to assign bug to him.
Comment 5 Mark Macdonald CLA 2013-06-20 12:12:46 EDT
This has been broken since early in 3.0 -- I bisect'ed it to this commit:

> 477cf3c06a42cd86fb12904fbc2cbd58032b524b is the first bad commit
> commit 477cf3c06a42cd86fb12904fbc2cbd58032b524b
> Author: sfranklin <susan_franklin@us.ibm.com>
> Date:   Mon Mar 11 14:21:57 2013 -0400
> 
>     Bug 390356 - command service is not a service at all. Work in progress.  Needs merging.

This commit separated the command "registry" (commandRegistry.js) from the core commands (commands.js). It created a different code path for commands triggered by a keybinding: the command's callback is invoked directly from commands.js _processKey(), which does not gather any parameters. 

For commands that get rendered by the commandRegistry (i.e. commands with keyBindingOnly == false), the rendering process wraps their callbacks inside a function that calls _invoke() first to gather parameters. That's why only commands with keyBindingOnly == true have this bug, since they are never rendered as menus or buttons in the UI.
Comment 6 Mark Macdonald CLA 2013-06-20 13:01:34 EDT
Patch is below. It changes _processKey() to execute commands using 
commandRegistry._invoke() if possible. This allows Open Commit's parameters to be gathered, which fixes the problem.

Also commandRegistry.showKeyBindings() contains a copy of _processKey() that lets you invoke commands from the Show Keys menu. I had to make a similar change there, or else you'd run into the same problem when triggering Open Commit from Show Keys.

Patch
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=afa85b2
Comment 7 Mark Macdonald CLA 2013-06-20 13:27:02 EDT
Since Open Commit seems to be the only command broken in this way, and changing the commandRegistry/commands is riskier, decided to go with a safer patch

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=31f9e0f

^ In this one, Open Commit simply invokes itself through the command registry if it is missing its parameters. I will open a new bug for the general problem.
Comment 8 Silenio Quarti CLA 2013-06-20 13:32:16 EDT
(In reply to comment #7)
> Since Open Commit seems to be the only command broken in this way, and
> changing the commandRegistry/commands is riskier, decided to go with a safer
> patch
> 
> http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/
> ?id=31f9e0f
> 
> ^ In this one, Open Commit simply invokes itself through the command
> registry if it is missing its parameters. I will open a new bug for the
> general problem.

+1 for this fix.
Comment 9 Ken Walker CLA 2013-06-20 14:37:41 EDT
Verified fix
Comment 10 Mark Macdonald CLA 2013-06-20 14:41:49 EDT
pushed to master
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=05e1be6
Comment 12 Szymon Brandys CLA 2013-06-21 02:58:51 EDT
(In reply to comment #7)
> ^ In this one, Open Commit simply invokes itself through the command
> registry if it is missing its parameters. I will open a new bug for the
> general problem.

Could you link the general bug to this one, please?
Comment 13 Szymon Brandys CLA 2013-06-21 03:23:07 EDT
(In reply to comment #12)
> Could you link the general bug to this one, please?

Found it.