Skip to content

Commit

Permalink
Adding a label to versions automatically created during a revert
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Oct 29, 2014
1 parent feb74ec commit ff91459
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -66,7 +66,8 @@ public void revertToVersion(final Session session, final String absPath,
throw new PathNotFoundException("Unknown version \"" + label + "\"!");
}
final VersionManager versionManager = workspace.getVersionManager();
versionManager.checkin(absPath);
final Version prevert = versionManager.checkin(absPath);
versionManager.getVersionHistory(absPath).addVersionLabel(prevert.getName(), prevert.getIdentifier(), false);
versionManager.restore(v, true);
versionManager.checkout(absPath);
}
Expand Down
Expand Up @@ -88,10 +88,13 @@ public void testRevertToVersionByLabel() throws RepositoryException {
final VersionManager mockVersionManager = mock(VersionManager.class);
final VersionHistory mockHistory = mock(VersionHistory.class);
final Version mockVersion1 = mock(Version.class);
final Version mockVersion0 = mock(Version.class);
when(mockHistory.hasVersionLabel(versionLabel)).thenReturn(true);
when(mockHistory.getVersionByLabel(versionLabel)).thenReturn(mockVersion1);
when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
when(mockVersionManager.getVersionHistory(EXAMPLE_VERSIONED_PATH)).thenReturn(mockHistory);
when(mockVersionManager.checkin(EXAMPLE_VERSIONED_PATH)).thenReturn(mockVersion0);
when(mockVersion0.getName()).thenReturn("1.0");

testObj.revertToVersion(mockSession, EXAMPLE_VERSIONED_PATH, versionLabel);
verify(mockVersionManager).restore(mockVersion1, true);
Expand All @@ -105,6 +108,7 @@ public void testRevertToVersionByUUID() throws RepositoryException {
final VersionManager mockVersionManager = mock(VersionManager.class);
final VersionHistory mockHistory = mock(VersionHistory.class);
final Version mockVersion1 = mock(Version.class);
final Version mockVersion0 = mock(Version.class);
when(mockHistory.getVersionByLabel(versionUUID)).thenThrow(new VersionException());
final VersionIterator mockVersionIterator = mock(VersionIterator.class);
when(mockHistory.getAllVersions()).thenReturn(mockVersionIterator);
Expand All @@ -115,6 +119,8 @@ public void testRevertToVersionByUUID() throws RepositoryException {
when(mockFrozenNode.getIdentifier()).thenReturn(versionUUID);
when(mockWorkspace.getVersionManager()).thenReturn(mockVersionManager);
when(mockVersionManager.getVersionHistory(EXAMPLE_VERSIONED_PATH)).thenReturn(mockHistory);
when(mockVersionManager.checkin(EXAMPLE_VERSIONED_PATH)).thenReturn(mockVersion0);
when(mockVersion0.getName()).thenReturn("1.0");

testObj.revertToVersion(mockSession, EXAMPLE_VERSIONED_PATH, versionUUID);
verify(mockVersionManager).restore(mockVersion1, true);
Expand Down

0 comments on commit ff91459

Please sign in to comment.