It's all about the answers!

Ask a question

How can I retrieve files from a changeset using the Java API?

Andy Jewell (24236174) | asked Mar 09 '17, 7:51 p.m.

I am trying to extract the files of a changeset using the Java API to the filesystem but haven't found a single reference in the forum for doing that.  Is the approach supposed to be to load a workspace and then copy out the files from the paths contained in the changeset?  Or is there a way to directly extract the files?  I seem to remember seeing something about the latter method but I can't find anything.

Any help or suggestions would be greatly appreciated!


Accepted answer

permanent link
Ralph Schoon (63.2k33646) | answered Mar 10 '17, 2:44 a.m.
edited Mar 10 '17, 2:48 a.m.

Here some clues: Getting an IFileItem

            IChangeSet changeSet = (IChangeSet);
            if (changeSet == null) {
                // It's possible that we don't have read access to this change
                // set?
            for (IChange change : (List<ichange>) changeSet.changes()) {
                IVersionableHandle after = change.afterState();
                IVersionable item = (IVersionable) scmService.fetchState(after,
                        null, null);
                if (item instanceof IFileItem) {
                    IFileItem fileItem = (IFileItem) item;


Getting the data for an IFileItem is here:

How to get the ISCMService in a Plain Java Client is explained here:

Andy Jewell selected this answer as the correct answer

Andy Jewell commented Mar 10 '17, 10:38 a.m.

 Perfect!  Thanks, Ralph!

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.