use of org.suigeneris.jrcs.rcs.Version in project xwiki-platform by xwiki.
the class XWikiAttachment method getVersionList.
/**
* Get the list of all versions up to the current. We assume versions go from 1.1 to the current one This allows not
* to read the full archive file.
*
* @return a list of Version from 1.1 to the current version.
* @throws XWikiException never happens.
*/
public List<Version> getVersionList() throws XWikiException {
final List<Version> list = new ArrayList<Version>();
final String currentVersion = this.version.toString();
Version v = new Version("1.1");
for (; ; ) {
list.add(v);
if (v.toString().equals(currentVersion)) {
break;
}
v = v.next();
}
return list;
}
use of org.suigeneris.jrcs.rcs.Version in project xwiki-platform by xwiki.
the class XWikiAttachmentArchive method getVersions.
/**
* @return an array of versions which are available for this attachment, ordered by version number descending.
*/
public Version[] getVersions() {
final Archive rcsArchive = getRCSArchive();
Version[] versions;
if (rcsArchive != null) {
final Node[] nodes = rcsArchive.changeLog();
versions = new Version[nodes.length];
for (int i = 0; i < nodes.length; i++) {
versions[i] = nodes[i].getVersion();
}
} else {
// No archive means there is no history and only the current version
versions = new Version[] { this.attachment.getRCSVersion() };
}
return versions;
}
use of org.suigeneris.jrcs.rcs.Version in project xwiki-platform by xwiki.
the class XWikiDocumentArchive method updateArchive.
/**
* Update history with new document version.
*
* @param doc - document for this version
* @param author - author of version
* @param date - date of version
* @param comment - version comment
* @param version - preferably document version in history
* @param context - used for loading nodes content
* @throws XWikiException in any error
*/
public void updateArchive(XWikiDocument doc, String author, Date date, String comment, Version version, XWikiContext context) throws XWikiException {
Version oldLatestVer = getLatestVersion();
Version newVer = version;
if (newVer == null || oldLatestVer != null && newVer.compareVersions(oldLatestVer) <= 0) {
newVer = createNextVersion(oldLatestVer, doc.isMinorEdit());
}
XWikiRCSNodeInfo newNode = new XWikiRCSNodeInfo(new XWikiRCSNodeId(getId(), newVer));
newNode.setAuthor(author);
newNode.setComment(comment);
newNode.setDate(date);
XWikiRCSNodeContent newContent = makePatch(newNode, doc, context);
updateNode(newNode);
this.updatedNodeInfos.add(newNode);
this.updatedNodeContents.add(newContent);
}
use of org.suigeneris.jrcs.rcs.Version in project xwiki-platform by xwiki.
the class XWikiAttachmentArchiveTest method getVersions.
@Test
public void getVersions() throws Exception {
Archive rcsArchive = new Archive(new Object[] { "line" }, "file.txt", "5.2");
rcsArchive.addRevision(new Object[] { "line modified" }, "");
archive.setRCSArchive(rcsArchive);
assertArrayEquals(new Version[] { new Version(5, 2), new Version(5, 3) }, archive.getVersions());
}
use of org.suigeneris.jrcs.rcs.Version in project xwiki-platform by xwiki.
the class XWikiAttachmentArchiveTest method getVersionsWhenThereIsNoHistory.
@Test
public void getVersionsWhenThereIsNoHistory() {
Version version = new Version(3, 4);
when(attachment.getRCSVersion()).thenReturn(version);
assertArrayEquals(new Version[] { version }, archive.getVersions());
}
Aggregations