# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /data/work/src/netbeans-cm # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java --- versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java Base (BASE) +++ versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java Locally Modified (Based On LOCAL) @@ -41,6 +41,7 @@ */ package org.netbeans.modules.versioning.core.spi; +import java.io.File; import java.io.IOException; import java.util.Date; import javax.swing.Action; @@ -115,6 +116,7 @@ private Action[] actions; private RevisionProvider revisionProvider; private MessageEditProvider mep; + private ParentProvider parentProvider; /** * Creates a new HistoryEntry instance. @@ -188,6 +190,40 @@ } /** + * Creates a new HistoryEntry instance. + * + * @param files involved files + * @param dateTime the date and time when the versioning revision was created + * @param message the message describing the versioning revision + * @param username full description of the user who created the versioning revision + * @param usernameShort short description of the user who created the versioning revision + * @param revision full description of the versioning revision + * @param revisionShort short description of the versioning revision + * @param actions actions which might be called in regard with this revision + * @param revisionProvider a RevisionProvider to get access to a files contents in this revision + * @param messageEditProvider a MessageEditProvider to change a revisions message + * @param parentProvider a ParentProvider to provide this entries parent entry. Not necessary for VCS + * where a revisions parent always is the time nearest previous revision. + * + */ + public HistoryEntry( + VCSFileProxy[] files, + Date dateTime, + String message, + String username, + String usernameShort, + String revision, + String revisionShort, + Action[] actions, + RevisionProvider revisionProvider, + MessageEditProvider messageEditProvider, + ParentProvider parentProvider) + { + this(files, dateTime, message, username, usernameShort, revision, revisionShort, actions, revisionProvider, messageEditProvider); + this.parentProvider = parentProvider; + } + + /** * Determines if this HistoryEntry instance supports changes. * * @return true if it is possible to access setter methods in this instance @@ -298,8 +334,22 @@ revisionProvider.getRevisionFile(originalFile, revisionFile); } } + + /** + * Returns this revisions parent entry or null if not available. + * + * @param file the file for whitch the parent HistoryEntry should be returned + * @return this revisions parent entry + */ + public HistoryEntry getParentEntry(VCSFileProxy file) { + if(parentProvider != null) { + return parentProvider.getParentEntry(file); } + return null; + } + } + /** * Adds a listener for history change events. * @@ -357,6 +407,23 @@ } /** + * Implement and pass over to a {@link HistoryEntry} in case you want + * {@link HistoryEntry#getParentProvider()} to return relevant values. + * + * @since 1.30 + */ + public interface ParentProvider { + /** + * Return a {@link HistoryEntry} representing the parent of the {@link HistoryEntry} + * configured with this ParentProvider. + * + * @param file the file for whitch the parent HistoryEntry should be returned + * @return the parent HistoryEntry + */ + HistoryEntry getParentEntry(VCSFileProxy file); + } + + /** * Event notifying a change in the history of some files. */ public static final class HistoryEvent { Index: versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java --- versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java Base (BASE) +++ versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java Locally Modified (Based On LOCAL) @@ -117,6 +117,27 @@ assertTrue(provider.revisionprovided); } + public void testHistoryEntryProvidesParent() throws IOException { + ParentProviderImpl provider = new ParentProviderImpl(); + VCSFileProxy file = VCSFileProxy.createFileProxy(new File("")); + VCSHistoryProvider.HistoryEntry h = + new VCSHistoryProvider.HistoryEntry( + new VCSFileProxy[] {file}, + new Date(System.currentTimeMillis()), + "msg", + "user", + "username", + "12345", + "1234567890", + new Action[0], + null, + null, + provider); + HistoryEntry parent = h.getParentEntry(file); + assertNotNull(parent); + assertEquals(ParentProviderImpl.PARENT_MSG, parent.getMessage()); + } + public void testHistoryEntryDoesntProvideRevision() throws IOException { RevisionProviderImpl provider = new RevisionProviderImpl(); provider.revisionprovided = false; @@ -135,6 +156,25 @@ // nothing happend } + public void testHistoryEntryDoesntProvideParent() throws IOException { + RevisionProviderImpl provider = new RevisionProviderImpl(); + provider.revisionprovided = false; + VCSFileProxy file = VCSFileProxy.createFileProxy(new File("")); + VCSHistoryProvider.HistoryEntry h = + new VCSHistoryProvider.HistoryEntry( + new VCSFileProxy[] {file}, + new Date(System.currentTimeMillis()), + "msg", + "user", + "username", + "12345", + "1234567890", + new Action[0], + null); + h.getParentEntry(file); + // nothing happend + } + public void testHistoryEntryEditable() throws IOException { MessageEditProviderImpl provider = new MessageEditProviderImpl(); provider.message = null; @@ -231,4 +271,23 @@ this.message = message; } } + + private class ParentProviderImpl implements VCSHistoryProvider.ParentProvider { + static final String PARENT_MSG = "im.the.parent"; + @Override + public HistoryEntry getParentEntry(VCSFileProxy file) { + return new HistoryEntry( + new VCSFileProxy[] {file}, + new Date(System.currentTimeMillis()), + PARENT_MSG, + "user", + "username", + "12345", + "1234567890", + new Action[0], + null, + null); } + } + +}