How to access ChangeSets in Eclipse (Mylyn/Team)? - java

I want to access the ChangeSets of SVN, CVS and Git programatically via Java. I.e. I want the data which is shown in the "Synchronize"-view.
I tried several approaches to find the correct usage in the code, and here's the few documentation I could find (but without success):
I managed to access the Synchronize-View via TeamUI.getSynchronizeManager(), but not the changesets.
An other thing I tried was to get the cangesets via FocusedTeamUiPlugin.getDefault().getContextChangeSetManagers() (got the manager and then the ChangeSetProvider where I tried to get the ChangeSets) - but they always are empty (because they are created when I first call it).
So, how can I access ChangeSets (with Java) in Eclipse (Mylyn)? In the end, I need the number of commits and code churn (loC added/removed/edited). Or is there probably an other, better approach?
Any help is appreciated really much!

I don't think Eclipse has implemented this feature as a public API yet. However, these links may help:
Internal changeset class and other API: http://www.cct.lsu.edu/~rguidry/ecl31docs/api/index.html?org/eclipse/team/internal/core/subscribers/ChangeSet.html
A feature enhancement request where they talk about why they haven't implemented it yet (but it's dated 2008, however the bug is still open?) https://bugs.eclipse.org/bugs/show_bug.cgi?id=116084
Sorry I couldn't be of more help! Maybe this will help you in the right direction...

You could perhaps go around Eclipse:
Apply rsync to get the CVS "*,v" files from the CVS server. It works for me.
Apply cvs2svn's "cvs2git" command to the CVS repos. It works for me.
Apply "git svn clone" (documented under "git-svn") to the SVN repos. I have not tried it.
Finally, use JGit's API to get the changesets from all of the repos, which at this point are all git repos. I think you'll particularly need these:
class Git
class FileResolver
class BaseConnection
interface Repository
class CheckoutCommand
class LogCommand
class RevCommit
class DiffCommand
class DiffEntry
class DiffFormatter

I've looking for this for 1 month now.
I tried to programm a plugin for eclipse, which is able to read the changeset of a Project ("working copy" of the repository).
What I've done now is an ugly work-around.
I used Runtime.exec() to run a cmd-command / Shell- command.
If you install a svn-commandline Client, you can type svn status -v -u
It gives you a list of all files of the working copy with the changeset info.
Then you can parse through the list to find all lines which start with "M" - for "modified" to get the Path of the changed file.

Related

JGit - Checkout to specific remote commit ID hash

I'm trying to access specific commitId files using the JGit library.
Using Git command this would look like : git checkout [COMMIT_ID], then my folder would checkout to the specific commit and get any file from it.
Now using JGit, I'm calling the Git.cloneRepository() function to get my repository (can't clone from a specific commitId here I think sadly). Then I'm trying to checkout using this : gitRepo.checkout().setName(gitCommitId).call()
But this is getting me the folliwing error : Remote origin did not advertise Ref for branch COMMIT_ID. This Ref may not exist in the remote or may be hidden by permission settings.
Which is odd because the CLI git command does work.
Maybe it is not something feasible through this lib but I didn't find anything else on the web yet.
setName(String name) is more for branch name, not for commit ID.
setStartPoint(RevCommit startCommit) does use a commit ID.
As seen here, git.checkout().setAllPaths(true).setStartPoint(gitCommitId).call(); would work better after your clone.

Renaming package with the same package name across 4 repositories

I have 4 repositories that have the same package names in them such as:
com.companyname.ateam.uiautomation
Each is in 4 repositories (Utils, WebDriver, Page, Test).
I want to rename the packages to actually be useful for each repository.
Then my next step is to merge at least 'page' and 'tests' into the same repositories.
In IntelliJ I have tried refactor.rename and refactor.move. It seems that since they all import from each other that the IDE just goes in and renames everything it finds with the package name and breaks the imports/references.
I spent a little time in Eclipse trying as well and it breaks the same things.
I a have also tried rename and move for asingle directory inside the package with the same results.
Has anyone dealt with this have a solution or tips? Many google searches haven't turned up this situation.
For those in the future. I didn't find a clean/intelligent way of doing this. I had to go the manual route.
For each repo I had to:
Add new package
Drag assets into new package
Build package and manually and find an replace reference issues.
The refactor rename caused many more issues and I couldn't find a cleaner way of doing this. It was time intensive. Thank you for all that read.
Has anyone dealt with this have a solution or tips? Many google searches haven't turned up this situation.
Use the git filter-branch command
git filter-branch
git filter-branch --tree-filter 'sed <do what you want to do in here on your files>'

how to complete user defined class methods using javacomplete

I am working under Mac OS X 10.7. I got javacomplete working with the help of pathogen, but it only completes JDK classes, not the classes I've created. When trying to omni-complete one of my objects I'm getting 'Pattern not found'. Is this really limited to JDK classes? If not, can anybody describe their config.
BTW, I've tried created ctags but it didn't work with javacomplete either. However, ctrl-x ctrl-] works fine with ctags created.
You need to set up the class path for your sources.
From the javacomplete documentation:
3. Set classpath using the following function: >
javacomplete#AddClassPath('jarfile_or_classes_path')
javacomplete#DelClassPath('jarfile_or_classes_path')
javacomplete#SetClassPath('semicolon_separated_string')
Another two variables will be used if they are existing:
|g:java_classpath| global classpath
|b:classpath| associated with current buffer
I have added the following to my .vimrc to auto-complete android projects:
if filereadable('AndroidManifest.xml')
call javacomplete#SetClassPath('/home/tidbeck/android/sdk/android-sdk-linux_x86/platforms/android-17/android.jar:libs/android-support-v4.jar:bin/classes')
call javacomplete#SetSourcePath('src')
endif
Two things that I noticed:
javacomplete#AddClassPath does not support jar files even though the docs say so
I had to remove my tags file to get completion to working
I've used javacomplete plugin along with supertab and i found that the easiet way to enable method completion is by using another plugin called easytags.vim that automatically creates tags as you compile your classes. From memory it did provide user defined Class and method completion.
After installing the vim plugin you have to add these lines into .vimrc:
" Only do this part when compiled with support for autocommands.
if has("autocmd")
autocmd Filetype java setlocal omnifunc=javacomplete#Complete
endif
I am, too, was unable to get it working with an existing tags file (created by ctags). As mentioned, one workaround is to unset the vim option tags inside .vimrc. But this was not an option for me.
I just manipulated javacomplete.vim to "ignore" the tags file.
Patch follows:
--- autoload/javacomplete.vim 2011-01-30 21:33:46.000000000 +0100
+++ /home/kndl/.vim/autoload/javacomplete.vim 2015-02-12 20:46:48.227465321 +0100
## -2510,7 +2510,8 ##
fu! s:GetClassInfoFromSource(class, filename)
let ci = {}
if len(tagfiles()) > 0
- let ci = s:DoGetClassInfoFromTags(a:class)
+ " kndl: Deactivate ctags feature as this does not work. It seems that I am unable to build an accepted tags file.
+ "let ci = s:DoGetClassInfoFromTags(a:class)
endif
if empty(ci)

Committing and Pushing to GitHub using JGit - Bare Repo?

Today I signed up for github, and converted an existing filesystem into a git repo using the technique described here:
http://crashingdaily.wordpress.com/2009/09/02/initing-a-new-remote-git-repository-with-existing-files/
Most importantly (I think) it involved this line:
git --bare init
I then followed the rest of github.com's setup tutorials (this was part of that) and was done. The existing filesystem was within Dropbox, so I performed the same setup on the two other machines that use the filesystem (now a git repo).
Tonight I tried to get JGit to add a file, commit it and then push it. Here's the gist of the code up until the point it breaks:
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File("path/to/my/repo"))
.readEnvironment() // scan environment GIT_* variables
.findGitDir() // scan up the file system tree
.build();
Git git = new Git(repository);
AddCommand add = git.add();
try{
add.addFilepattern("PlayState.as").call();`
This is basically taken verbatim from a JGit tutorial, incidentally. It throws an exception at that last quoted line and states:
org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
at org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:838)
at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:886)
at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:136)
at flipa.FLIPAGame.writeToFlixel(FLIPAGame.java:77)
at flipa.FLIPAGame.main(FLIPAGame.java:58)
Now, I'm not saying it's unreasonable to claim that, because truth be told I am not the best friend of version control. I get that a bare repo is one with just git in and no other files, but it seems to me that now it has files in it. I've already manually added, committed and pushed to github using git from Terminal. So I can't immediately see why it won't even recognise the repo.
Any takers?
EDIT - For clarification, killing off this repo is no big deal if someone can propose another solution. I want a git repo to use the filesystem in my dropbox, and be able to commit to github via Java.
For your code, I would say the options setGitdir() and findGitDir() are not supposed to be used at the same time.
To retrieve an existing repository, I use findGitDir(new File("path/to/my/repo") and it is enough.
This sounds like you've added the files to a bare repository. A bare repository should not be touched, except through git push and pull commands (or git commands in general). As a guide, I don't ever look in my bare repositories.
It should be used as a central location. Once you've created the git bare repo, you should clone it and then work on it from the clone, pushing and pulling from the clone.
$ cd /dropbox/repo
$ git init --bare
$ cd /workdir
$ git clone file:///dropbox/repo
$ add files in here
$ git add .
$ git commit -m "initial version"
$ git push origin master
$ more changes here
$ git add etc.
The difference between this and github is the git clone, which then comes from a different place. To be quite honest, unless you've got a really good reason to have a local copy, I'd just forget about the dropbox repo and just use github.
Your third line of code, right after .build(); should be:
repository.create();
This is the equivalent of the "git init" command.
In your case since you are working in an existing directory, you may find more convenient using Git.open().
Git git = Git.open(new File(".git"));
System.out.println("Repository: " + git.getRepository().toString());
//Do some git action for instance:
RevCommit rev = git.commit().setAmend(true)
.setAuthor("me", "me#mail.com")
.setMessage("Testing commit from jGit").call();
git.close();
Source: Article written by RĂ¼diger Herrmann available in Code Affine.

Overtone Livecoding with Emacs/Slime/Swank/cake - Could not locate overtone.live__init.class

I am trying to use emacs and slime to connect to swank to live code using Overtone. I have the whole thing pretty much working, but when i try to run
(ns foo
(:use [overtone.live]
[overtone.inst.synth]))
(definst bar [] (saw 220))
I get the error 'Could not locate overtone/live__inti.class or overtone/live.clj on classpath:' Which i gather basically means that the class files are not where it is looking for them. I am not sure what to do to fix this.
Important note: Slime/Swank/Cake are deprecated means of connecting Overtone and Emacs. Instead, consider using nREPL via Leiningen 2+ and CIDER
it looks like you haven't got the Overtone jar on the classpath. Things to check:
You have overtone-X-Y-X.jar in your project's lib directory
Your project isn't called Overtone (that can cause issues with tools like lein)
Finally, you might want to take a look at this setup video: http://vimeo.com/25190186 which describes the process of getting an Overtone dev environment setup.
Good luck and come join the mailing list and share your thoughts: http://groups.google.com/group/overtone
Have you tried confirming that overtone is in your java classpath?
(System/getProperty "java.class.path")
It's most likely a temporary fix, as I'm just getting my feet wet with clojure and overtone, but I included overtone as a global dependecy in my ~/.cake directory and installed it with:
cake deps --global
Additionally, I'd reccomend updating to the latest version of overtone as it looks like the vimeo link is a few versions behind what is currently reflected on clojars:
http://clojars.org/overtone

Categories

Resources