Fetch files from repository
Hi,
I'm developing an Eclipse plug-in that analyses authorship data of projects residing in a jazz repository.
In particular, as a first step I want to show for each line of every single project file, the author and other informations.
I've already figured out how to connect to a team repository, get the components from it, navigate through their folders structure and for every file (IFileItemHandle) found, get the related changeset which contains the authoring info I need.
What I'd like to do now is to get the actual file from the repository so that I can, for example, annotate every single line of it with the retrieved authoring info.
I tried to look around the Wiki and mess around a bit but haven't been able to solve the problem.
Here's is the source code that for every file, retrieves the related changesets:
So, in other words, what is the easiest way to get the source file related to a FileItem/FileItemHandle?
cheers
Giacomo
I'm developing an Eclipse plug-in that analyses authorship data of projects residing in a jazz repository.
In particular, as a first step I want to show for each line of every single project file, the author and other informations.
I've already figured out how to connect to a team repository, get the components from it, navigate through their folders structure and for every file (IFileItemHandle) found, get the related changeset which contains the authoring info I need.
What I'd like to do now is to get the actual file from the repository so that I can, for example, annotate every single line of it with the retrieved authoring info.
I tried to look around the Wiki and mess around a bit but haven't been able to solve the problem.
Here's is the source code that for every file, retrieves the related changesets:
if(tmp instanceof IFileItemHandle){
List<IChangeSetHandle> cs = FileSystemCore.getFileSystemManager(repository).getFileSystemView(conn).getBlame(comp, (IFileItemHandle)tmp, null, null);
for(Iterator<IChangeSetHandle> csIter = cs.iterator(); csIter.hasNext();){
IChangeSetHandle tempCs = csIter.next();
IChangeSet contribution = (IChangeSet) repository.itemManager().fetchCompleteItem(tempCs, IItemManager.DEFAULT, null);
IContributor author = (IContributor) repository.itemManager().fetchCompleteItem(contribution.getAuthor(), IItemManager.DEFAULT, null);
}
So, in other words, what is the easiest way to get the source file related to a FileItem/FileItemHandle?
cheers
Giacomo
2 answers
Using M6ish APIs (some tweaking may be necessary, but this is the
general idea):
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IVersionableManager vm = wm.versionableManager();
IContentManager contentManager = teamRepository.contentManager();
IChange c = //; find the change in the change-set for that item
IFileItemHandle after = c.afterState();
if( after != null )
{
IFileItem f = vm.fetchCompleteState(after, null);
IContent content = f.getContent();
InputStream s = contentManager.retrieveContentStream(content, null);
// s is your file
}
HTH,
JohnC
SCM Server
ghezzi wrote:
general idea):
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IVersionableManager vm = wm.versionableManager();
IContentManager contentManager = teamRepository.contentManager();
IChange c = //; find the change in the change-set for that item
IFileItemHandle after = c.afterState();
if( after != null )
{
IFileItem f = vm.fetchCompleteState(after, null);
IContent content = f.getContent();
InputStream s = contentManager.retrieveContentStream(content, null);
// s is your file
}
HTH,
JohnC
SCM Server
ghezzi wrote:
Hi,
I'm developing an Eclipse plug-in that analyses authorship data of
projects residing in a jazz repository.
In particular, as a first step I want to show for each line of every
single project file, the author and other informations.
I've already figured out how to connect to a team repository, get the
components from it, navigate through their folders structure and for
every file (IFileItemHandle) found, get the related changeset which
contains the authoring info I need.
What I'd like to do now is to get the actual file from the repository
so that I can, for example, annotate every single line of it with the
retrieved authoring info.
I tried to look around the Wiki and mess around a bit but haven't been
able to solve the problem.
Here's is the source code that for every file, retrieves the related
changesets:
if(tmp instanceof IFileItemHandle){
List<IChangeSetHandle> cs =
FileSystemCore.getFileSystemManager(repository).getFileSystemView(conn).getBlame(comp,
(IFileItemHandle)tmp, null, null);
for(Iterator<IChangeSetHandle> csIter = cs.iterator();
csIter.hasNext();){
IChangeSetHandle tempCs = csIter.next();
IChangeSet contribution = (IChangeSet)
repository.itemManager().fetchCompleteItem(tempCs,
IItemManager.DEFAULT, null);
IContributor author = (IContributor)
repository.itemManager().fetchCompleteItem(contribution.getAuthor(),
IItemManager.DEFAULT, null);
}
So, in other words, what is the easiest way to get the source file
related to a FileItem/FileItemHandle?
cheers
Giacomo