DESCRIPTION

Add preliminary synchronization support within Eclipse for branches.

Implements synchronization participants and resource variants for
allowing clients to synchronize Eclipse resources against the Git
index and a given branch.

Synchronization can be launched for project's context menu by 'Team ->
Synchronize...' and from 'Repositories View' from branch context menu.

In 'Synchronize repository' dialog user can choose source and
destination branch (or tag). He can also define does local uncommited
changes should be included in 'Synchronize view'.

CQ: 4122
Bug: 309582
Also-by: Jaylon Avila xxx@xxx.xxx
Change-Id: Ib838a6c88eccbef8c7ffb6aa1c602bdc8778dbc6
Signed-off-by: Leslie Stephenson xxx@xxx.xxx


COMMENTS

author: Leslie Stephenson
date: 2010-06-01 22:45:49.000000000

Uploaded patch set 9.

-------------------------------------
author: Leslie Stephenson
date: 2010-06-01 22:55:12.000000000

Patch Set 9: No score

Patch set 8 had some issues which are fixed in patch set 9. Patch set 9 also contains SWTBot test cases for synchronization with and without local changes.

Right now I'll move to adding commit separation into synchronize view so that we can review and merge changes based on commit not on single file change ... or maybe I should polish this patch set so that it can be merged with actual functionality ? Right now I'm not quite sure what would be better ...

-------------------------------------
author: Douglas Trujillo
date: 2010-06-04 22:57:03.000000000

Patch Set 9: No score; No score

- both tests fail after Sycnronize... dialog has come up with WidgetNotFoundException
- such long wait times seem unreasonable
- I think we should not make this change bigger and bigger, the review overhead is already quite high since this is already a huge change
- including tests is definitively a good way to stabilize this proposal
- I will continue testing manually soon, I need some sleep now

Line:135, org.eclipse.egit.ui/plugin.properties -> this is an unresolved merge conflict !

Line:2, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> Was this class started in 2009 ? Or is this copy&paste problem ?

Line:59, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> Do you really want to wait 6000s here ? This is almost 2 hours, that's insane for an automated test.

Line:94, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> again crazy wait time

Line:185, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> English in comment should be improved (hope I didn't corrupt what you want to say):

EGit decorates the project node shown in the package explorer. 
The '>' decorator indicates that there are uncommitted changes present in the project. 
Also the repository and branch name are added as a suffix ('[<repo name> <branch name>]' suffix). 
To bypass this decoration we use here this loop.

Line:26, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTesCase.java -> Typo in class name
s/EGitTesCase/EGitTestCase/

Line:1595, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java -> why this change ? we try to avoid pure formatting changes in places not touched by the change

-------------------------------------
author: Douglas Trujillo
date: 2010-06-04 22:57:15.000000000

Patch Set 9: I would prefer that you didn't submit this



-------------------------------------
author: Leslie Stephenson
date: 2010-06-05 11:47:35.000000000

Patch Set 9:

It looks that I should pay more attention on what I'm exactly pushing to review :|

> - both tests fail after Sycnronize... dialog has come up with WidgetNotFoundException

Strange, on my Linux this works fine. Could you sen a stack trace ?

> -I think we should not make this change bigger and bigger, the review overhead is already quite high since this is already a huge change

OK, so now I'll work on stabilization of this change. I'll add two more tests for synchronizing with tags (branch vs. tag and tag vs. tag).

Line:135, org.eclipse.egit.ui/plugin.properties -> Ups, I don't have idea how can I miss this conflict :/

Resolved, done.

Line:2, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> This part comes from time when before I've extracted EGitTestCase class and it was to indicate authors of restetWorkbench() and closeWelcomePage() methods. Now it can be removed.

Done.

Line:59, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> This should be 600s (10mins), one zero to much, done.

Line:94, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> same as above, done.

Line:185, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> Thank you for pointing this out. You didn't corrupt anything, this is what I want to say. Done

Line:26, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTesCase.java -> Done

Line:1595, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java -> Done

-------------------------------------
author: Douglas Trujillo
date: 2010-06-05 13:14:26.000000000

Patch Set 9:

The failures are caused by platform dependent path separator [1]. On Windows the title of the synchronize dialog is
'Synchronize repository: egit\.git' and your tests expect hardcoded 'Synchronize repository: egit/.git'. I also noticed that after the edit steps the test ide starts building. Maybe this could be switched off for these tests in order to reduce the chance of hitting timeout problems.

[1] stack trace:
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find widget.
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:348)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shells(SWTBotFactory.java:112)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:102)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:93)
	at org.eclipse.egit.ui.views.synchronize.SynchronizeViewTest.shouldReturnListOfChnages(SynchronizeViewTest.java:73)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
	at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
	at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
	at java.lang.Thread.run(Thread.java:619)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find shell matching: with text 'Synchronize repository: egit/.git'
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:346)
	... 33 more

-------------------------------------
author: Leslie Stephenson
date: 2010-06-05 13:20:59.000000000

Patch Set 9:

In this case seams reasonable to remove '.git' part from repository name, and leave only parent folder name as a repository name. What do you think about this solution ?

I'll try to turn of workspace rebuilding.

-------------------------------------
author: Douglas Trujillo
date: 2010-06-05 13:56:53.000000000

Patch Set 9:

I would just fix the problem with the platform dependent path separator. In other places e.g. RepositoriesView we also show the full path to the GITFOLDER.

When playing around I hit the following error quite frequently:


!ENTRY org.eclipse.core.jobs 4 2 2010-06-05 15:41:12.984
!MESSAGE An internal error occurred during: "Git Resource Synchronization".
!STACK 0
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
 ^
	at java.util.regex.Pattern.error(Pattern.java:1713)
	at java.util.regex.Pattern.compile(Pattern.java:1466)
	at java.util.regex.Pattern.<init>(Pattern.java:1133)
	at java.util.regex.Pattern.compile(Pattern.java:823)
	at java.lang.String.replaceAll(String.java:2189)
	at org.eclipse.egit.ui.internal.synchronize.GitResourceVariantTree.getMembersAndStore(GitResourceVariantTree.java:399)
	at org.eclipse.egit.ui.internal.synchronize.GitResourceVariantTree.members(GitResourceVariantTree.java:105)
	at org.eclipse.team.core.variants.AbstractResourceVariantTree.mergedMembers(AbstractResourceVariantTree.java:200)
	at org.eclipse.team.core.variants.AbstractResourceVariantTree.collectChanges(AbstractResourceVariantTree.java:173)
	at org.eclipse.team.core.variants.AbstractResourceVariantTree.collectChanges(AbstractResourceVariantTree.java:113)
	at org.eclipse.team.core.variants.AbstractResourceVariantTree.refresh(AbstractResourceVariantTree.java:90)
	at org.eclipse.team.core.variants.AbstractResourceVariantTree.refresh(AbstractResourceVariantTree.java:54)
	at org.eclipse.team.core.variants.ResourceVariantTreeSubscriber.refresh(ResourceVariantTreeSubscriber.java:159)
	at org.eclipse.team.core.variants.ResourceVariantTreeSubscriber.refresh(ResourceVariantTreeSubscriber.java:126)
	at org.eclipse.team.internal.ui.synchronize.RefreshSubscriberParticipantJob.doRefresh(RefreshSubscriberParticipantJob.java:116)
	at org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.run(RefreshParticipantJob.java:309)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

I couldn't really find out when the synchronize action is activated in the repositories view context menu. Sometimes it's there sometimes its greyed out.

Some more thoughts about tests :

Could you cover all possible permutations in 
GitSyncInfo.calculateKind() with tests ?

I think the GitResourceVariantComparator would also deserve a test.

In general I think you should think about a way to move most of the logic down into org.eclipse.egit.core and then write core tests for the basic logic. They are faster, and don't depend on brittle label text search logic.

Line:67, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> typo in method name

s/Chnages/Changes/

Line:21, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/dto/GitSynchronizeDataSet.java -> missing javadoc

Line:28, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/dto/GitSynchronizeData.java -> missing javadoc for public class

Line:47, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/dto/GitSynchronizeData.java -> this javadoc looks incomplete

Line:58, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/dto/GitSynchronizeData.java -> this javadoc looks incomplete

Line:520, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java -> typo in method name

Line:42, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronize.java -> style nit: unnecessary blank line

-------------------------------------
author: Leslie Stephenson
date: 2010-06-05 14:14:34.000000000

Patch Set 9:

> I would just fix the problem with the platform dependent path separator. In other places e.g. RepositoriesView we also show the full path to the GITFOLDER.

Full patch to the GITFOLDER can make synchornize dialog extremely huge in some cases.

> When playing around I hit the following error quite frequently:

I'll inspect that.

> I couldn't really find out when the synchronize action is activated in the repositories view context menu. Sometimes it's there sometimes its greyed out.

I've already fix it. Right now it is depend on project name (it should be equal with repository name), I've reimplemented that and check does we have any project in workspace that is connected with selected repository

> Could you cover all possible permutations in GitSyncInfo.calculateKind() with tests ?

OK

> I think the GitResourceVariantComparator would also deserve a test.

OK

> In general I think you should think about a way to move most of the logic down into org.eclipse.egit.core and then write core tests for the basic logic. They are faster, and don't depend on brittle label text search logic.

Yes, this is a good idea. I'll try to move as much I can to egit.core.

Line:42, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitSynchronize.java -> Done

-------------------------------------
author: Malia Sampson
date: 2010-06-14 18:08:51.000000000

Patch Set 9: No score; No score

Dariusz, let us know if you need any help if you're constructing a new patch. We will want to go through the IP process soon so we can get this into the 0.9.0 stream and start iterating.

-------------------------------------
author: Leslie Stephenson
date: 2010-06-14 18:36:13.000000000

Patch Set 9:

Currently I'm intensively testing synchronization, and I think that I found a bug in EGit/JGit. I'll fill a bug report ASAP.

Line:67, org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/views/synchronize/SynchronizeViewTest.java -> Done

Line:520, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java -> Done

-------------------------------------
author: Gerrit Johnathan Pham
date: 2010-06-18 00:07:45.000000000

Your change could not be merged due to a path conflict.

Please merge (or rebase) the change locally and upload the resolution for review.

-------------------------------------
