Reusing patches for JFace Viewers

Hello readers,

In this post, we will continue to talk about generifying JFace viewers, as part of our Google Summer of Code project. As mentioned before, there is an existing attempt to generify JFace viewers. Let’s see in more details how to reuse the existing patches to continue the work.

It’s been a while since my last post. I’ve been working in the past weeks on old patches from last Google Summer of Code. Hendrik did a first attempt to add Generics support to JFace viewers but due to time constraints, he wasn’t able to finish in time. Fortunately, in this year, we can save time by reusing Hendrik’s patches.

Working in the master branch wouldn’t be appropriated so, as Lars suggested, I forked eclipse.platform.ui to my Github account. However, now I have a problem: I want to keep track of the Eclipse repository while I work in my Github branch but I don’t want to have duplicated code.

To solve this problem, I just added a new remote pointing to my Github repository (Step 1). Then, I set the local branch master to the Github remote (Step 2). In case I want to check what’s going on in the Eclipse branch, I can fetch it and compare FETCH_HEAD with master (Step 3):

# Step 1
> git remote add github
> git branch -D master # Delete old master

# Start of Step 2
> git fetch github master
> git checkout FETCH_HEAD

# End of Step 2. To make master point to github: git push -u github master
> git checkout -b master

# Start of Step 3
> git fetch origin master
> git branch -v # The output allows me to compare them

At this point, I can work without disturbing other developers. Now, I need all patches that Hendrik submitted last year. Fortunately, Git has some helpful commands to show me exactly what I’m looking for. Hendrik migrated his work to a separated branch (johna/402445) to work without disturbing developers but he had some patches on master. Here is how I retrieve all Hendrik’s work on master:

# Everything authored by Hendrik on master branch.
# The parameter --oneline gives me only the Commit header
> git log --oneline --author="Hendrik Still"
e5dba45 Bug 434283 - Update the JFace databinding snippets
4340ee4 Bug 415875 - [JFace][Snippets] Snippet055HideShowColumn hides column, but does not shows column again
09f1124 Bug 413974 - [Viewers] Add generics to the TableViewer
1184903 Bug 414067 - [Viewers] Add generics to CustomHashtable
5ccf110 Bug 414565 - [JFace][snippets] Update JFace snippets to generified viewers
328236b Bug 414559 - [JFace][snippets] Move requirement for JFace Snippets to Java 1.5
271b294 Bug 414356 - [Viewers] Add generics to the ListViewer
d5c62ff Bug 412273 - [Viewers] Add generics to the ComboViewer

Considering the commit header, we can group patches by the following groups:

  1. Commits related to JFace Viewers
  2. Commits related to JFace Tests
  3. Commits related to JFace Snippets

Now that we have identified what we want to retrieve, we need to migrate them to my Github repository. Every commit on Git has a hash code. This is an identifier and important information to manipulate a commit. In my case, I want to migrate a set of commits, so I proceed with the following Git command for each commit:

# Example
d5c62ff Bug 412273 - [Viewers] Add generics to the ComboViewer
> git cherry-pick d5c62ff

Git will try to include the given commit to the local history. If no conflict occurs, Git just outputs a message and you are ready to push it to the remote branch. Otherwise, you have to resolve each merge conflict. I used the Merge Tool from EGit on Eclipse to make the work easier. After resolving the conflicts, you just need to add them to the Git index and proceed with the following command:

> git cherry-pick --continue

Now you are ready to push all changes. If you want to abort the process, instead of “–continue”, use “–abort” as in the example below:

> git cherry-pick --abort

The approach is similar for patches. The only difference is that I don’t have to check the hash code of a commit since I have access to the command to cherry-pick a particular patch:


  • Patch to integrate:
  • Command given: git fetch git:// refs/changes/85/16585/3 && git cherry-pick FETCH_HEAD

As partial results, all patches related to JFace Snippets and Viewers are fully migrated. Check Issue #17 and Issue #18 for more details.

I will continue to migrate Hendrik’s patches and start to add Generics to the remaining Viewers. In addition, I would like to thank Hendrik, Lars, and all members from the platform-ui-dev list for the insights and handy help on my work.

If you have any questions or concerns, feel free to comment below.
Thank you for your time, see you soon!

About Jeanderson Candido

I'm currently undergrad in Computer Science at Federal University of Campina Grande (UFCG), Brazil. Since My first year, I've been involved in researches related to Software Engineering. I was visiting student at Walsh University, USA for a year (2012-2013) and research assistant at PLASMA (University of Massachusetts, USA) during the 2013 Summer. Nowadays I'm a contributor of the Eclipse project and research assistant at Software Productivity Group (SPG at UFCG).
This entry was posted in Jeanderson Candido and tagged , . Bookmark the permalink.