## Adding History support

There are two parts to adding History support to your repository:

- Providing implementations for the core history interfaces; see the Providing History section
- Creating the UI elements for the History Page which gets displayed in the History View; see the Showing History section

### Providing History

The core history interfaces allow users to access the history of an item by querying the IFileHistoryProvider returned by the RepositoryProvider. To do this, you need to:

- Provide an implementation for IFileHistory by extending FileHistory.
- Provide an implementation for IFileRevision by extending FileRevision.
- Provide an implementation for IFileHistoryProvider by extending FileHistoryProvider.
- Provide an implementation for getFileHistoryProvider to allow users to fetch the IFileHistoryProvider from your RepositoryProvider.

### Showing History

To display history for items in your repository, you can provide one or more HistoryPages which will be shown in the History view. To do this, you need to:

- Provide an implementation for IHistoryPage by extending History Page.
- Provide an implementation for IHistoryPageSource by extending HistoryPageSource. When a resource is selected to be shown in the History view it will try to adapt the FileHistoryProvider it gets from your repository provider to a HistoryPageSource. If it doesn't succeed, it will then try to adapt the repository provider itself. For non-resource objects, the History view will try to adapt the object to a HistoryPageSource. The FileSystem History view example registers an adapter factory that adapts a FileHistoryProvider to an IHistoryPageSource.
- Create a Show History Action, provide an object contribution for the Action. See org.eclipse.ui.popupMenus for more info.

### FileSystem History example

The FileSystem example illustrates how you can provide history and a history page for repository items. Select a resource in a FileSystem managed project and choose Team > Show History. The FileSystem History page will be displayed in the History view with all of the local revisions as well as the FileSystem revision displayed. You can right click on any revision and select Open from the context menu to open the revision.

### FileRevisionEditorInput

To support the Open functionality, the FileSystem history example had to create its own FileSystemRevisionEditorInput (see org.eclipse.team.examples.filesystem.ui.FileSystemRevisionEditorInput). This class adapts to IFileRevision and to IFileState, which can be used to determine whether the editor contains remote contents (IFileRevision) or local history contents (IFileState).

Likewise, the existing FileRevisionEditorInput's that come with the SDK and are used by the CVS History page and Local History page all adapt to IFileRevision which can be used to determine if the revision contained in the editor is that of a remote revision.