Index: src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java =================================================================== --- src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java (revision 3816) +++ src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java (working copy) @@ -79,4 +79,24 @@ assertEquals("Title", this.document.getDisplayTitle(this.context)); } + + public void testMinorMajorVersions() { + // there is no version in doc yet, so 1.1 + assertEquals("1.1", this.document.getVersion()); + + this.document.setMinorEdit(false); + this.document.incrementVersion(); + // no version => incrementVersion sets 1.1 + assertEquals("1.1", this.document.getVersion()); + + this.document.setMinorEdit(false); + this.document.incrementVersion(); + // increment major version + assertEquals("2.1", this.document.getVersion()); + + this.document.setMinorEdit(true); + this.document.incrementVersion(); + // increment minor version + assertEquals("2.2", this.document.getVersion()); + } } Index: src/test/java/com/xpn/xwiki/doc/XWikiDocumentArchiveTest.java =================================================================== --- src/test/java/com/xpn/xwiki/doc/XWikiDocumentArchiveTest.java (revision 3816) +++ src/test/java/com/xpn/xwiki/doc/XWikiDocumentArchiveTest.java (working copy) @@ -154,7 +154,7 @@ // Set a username with a space System.setProperty("user.name", "Vincent Massol"); - archive.updateArchive("Main.WebHome", originalText); + archive.updateArchive("Main.WebHome", originalText, null); // Try to construct again the archive from the last modification. This will happen when // XWiki loads a document from the database for example. We verify here that a username Index: src/main/java/com/xpn/xwiki/store/XWikiHibernateVersioningStore.java =================================================================== --- src/main/java/com/xpn/xwiki/store/XWikiHibernateVersioningStore.java (revision 3816) +++ src/main/java/com/xpn/xwiki/store/XWikiHibernateVersioningStore.java (working copy) @@ -239,7 +239,7 @@ Session session = getSession(context); XWikiDocumentArchive archivedoc = getXWikiDocumentArchive(doc, context); - archivedoc.updateArchive(doc.getFullName(), text); + archivedoc.updateArchive(doc.getFullName(), text, doc.getVersion()); saveXWikiDocArchive(archivedoc, bTransaction, context); if (bTransaction) { endTransaction(context, true, false); @@ -256,4 +256,3 @@ } } } - Index: src/main/java/com/xpn/xwiki/store/jcr/XWikiJcrPropertyVersioningStore.java =================================================================== --- src/main/java/com/xpn/xwiki/store/jcr/XWikiJcrPropertyVersioningStore.java (revision 3816) +++ src/main/java/com/xpn/xwiki/store/jcr/XWikiJcrPropertyVersioningStore.java (working copy) @@ -81,8 +81,8 @@ public void updateXWikiDocArchive(XWikiDocument doc, String text, boolean bTransaction, XWikiContext context) throws XWikiException { try { XWikiDocumentArchive archivedoc = getXWikiDocumentArchive(doc, context); - archivedoc.updateArchive(doc.getFullName(), text); - saveXWikiDocArchive(archivedoc, bTransaction, context); + archivedoc.updateArchive(doc.getFullName(), text, doc.getVersion()); + saveXWikiDocArchive(archivedoc, bTransaction, context); } catch (Exception e) { Object[] args = { doc.getFullName() }; throw new XWikiException( XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_JCR_LOADING_OBJECT, Index: src/main/java/com/xpn/xwiki/doc/XWikiDocument.java =================================================================== --- src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (revision 3816) +++ src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (working copy) @@ -150,6 +150,9 @@ // Comment on the latest modification private String comment; + + // Is latest modification is minor edit + private boolean isMinorEdit = false; // Used to make sure the MetaData String is regenerated private boolean isContentDirty = true; @@ -276,7 +279,9 @@ public Version getRCSVersion() { if (version == null) { - version = new Version("1.1"); + // if we assign this.version = new Version("1.1") before save (ex: $doc.getVersion() in a page), then version will be > 1.1 after the first save + // version 1.0 do not work for some reason inside JRCS + return new Version("1.1"); } return version; } @@ -632,7 +637,11 @@ if (version == null) { version = new Version("1.1"); } else { - version = version.next(); + if (isMinorEdit()) { + version = version.next(); + } else { + version = version.getBranchPoint().next().newBranch(1); + } } } @@ -1511,7 +1520,10 @@ if (comment != null) { setComment(comment); } - + + // Read the minor edit checkbox from the form + setMinorEdit(eform.isMinorEdit()); + String tags = eform.getTags(); if (tags != null) { setTags(tags, context); @@ -1749,6 +1761,7 @@ setxWikiClass((BaseClass) document.getxWikiClass().clone()); setxWikiClassXML(document.getxWikiClassXML()); setComment(document.getComment()); + setMinorEdit(document.isMinorEdit()); clonexWikiObjects(document); copyAttachments(document); @@ -1795,6 +1808,7 @@ doc.setxWikiClass((BaseClass) getxWikiClass().clone()); doc.setxWikiClassXML(getxWikiClassXML()); doc.setComment(getComment()); + doc.setMinorEdit(isMinorEdit()); doc.clonexWikiObjects(this); doc.copyAttachments(this); doc.elements = elements; @@ -1915,6 +1929,10 @@ if (!getComment().equals(doc.getComment())) { return false; } + + if (isMinorEdit() == doc.isMinorEdit()) { + return false; + } if (!getxWikiClass().equals(doc.getxWikiClass())) { return false; @@ -2108,6 +2126,10 @@ el = new DOMElement("comment"); el.addText(getComment()); docel.add(el); + + el = new DOMElement("minorEdit"); + el.addText(String.valueOf(isMinorEdit())); + docel.add(el); List alist = getAttachmentList(); for (int ai = 0; ai < alist.size(); ai++) { @@ -2292,6 +2314,9 @@ setValidationScript(getElement(docel, "validationScript")); setComment(getElement(docel, "comment")); + String minorEdit = getElement(docel, "minorEdit"); + setMinorEdit(Boolean.valueOf(minorEdit).booleanValue()); + String strans = getElement(docel, "translation"); if ((strans == null) || strans.equals("")) { setTranslation(0); @@ -4016,6 +4041,17 @@ this.comment = comment; setMetaDataDirty(true); } + + public boolean isMinorEdit() + { + return isMinorEdit; + } + + public void setMinorEdit(boolean isMinorEdit) + { + this.isMinorEdit = isMinorEdit; + setMetaDataDirty(true); + } public BaseObject newObject(String classname, XWikiContext context) throws XWikiException { Index: src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java =================================================================== --- src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java (revision 3816) +++ src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java (working copy) @@ -1,12 +1,13 @@ package com.xpn.xwiki.doc; -import com.xpn.xwiki.XWikiException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tools.ant.filters.StringInputStream; import org.suigeneris.jrcs.rcs.Archive; import org.suigeneris.jrcs.util.ToString; +import com.xpn.xwiki.XWikiException; + public class XWikiDocumentArchive { private static final Log log = LogFactory.getLog(XWikiDocumentArchive.class); @@ -70,7 +71,7 @@ } } - public void updateArchive(String docname, String text) throws XWikiException { + public void updateArchive(String docname, String text, String newver) throws XWikiException { // JRCS used the user.name System property to set the author of a change. However JRCS // has a bug when the user name has a space in the name @@ -87,9 +88,12 @@ try { Object[] lines = ToString.stringToArray(text); - if (archive != null) - archive.addRevision(lines, ""); - else + if (archive != null) { + if (newver==null) + archive.addRevision(lines, ""); + else + archive.addRevision(lines, newver, ""); + } else archive = new Archive(lines, docname, "1.0"); } catch (Exception e) { Index: src/main/java/com/xpn/xwiki/api/XWiki.java =================================================================== --- src/main/java/com/xpn/xwiki/api/XWiki.java (revision 3816) +++ src/main/java/com/xpn/xwiki/api/XWiki.java (working copy) @@ -2315,6 +2315,14 @@ { return xwiki.isEditCommentMandatory(context); } + + /** + * API to check if the minor edit feature is active + * minor edit are activated in xwiki.cfg or in the XWiki Preferences + */ + public boolean hasMinorEdit() { + return xwiki.hasMinorEdit(context); + } /** * API to rename a page (experimental) Rights are necessary to edit the source and target page Index: src/main/java/com/xpn/xwiki/api/Document.java =================================================================== --- src/main/java/com/xpn/xwiki/api/Document.java (revision 3816) +++ src/main/java/com/xpn/xwiki/api/Document.java (working copy) @@ -292,6 +292,11 @@ { return doc.getComment(); } + + public boolean isMinorEdit() + { + return doc.isMinorEdit(); + } /** * return the list of possible traduction for this document @@ -1410,6 +1415,10 @@ { getDoc().setComment(comment); } + + public void setMinorEdit(boolean isMinor) { + getDoc().setMinorEdit(isMinor); + } public void save() throws XWikiException { Index: src/main/java/com/xpn/xwiki/XWiki.java =================================================================== --- src/main/java/com/xpn/xwiki/XWiki.java (revision 3816) +++ src/main/java/com/xpn/xwiki/XWiki.java (working copy) @@ -4911,6 +4911,16 @@ return false; return "1".equals(Param("xwiki.editcomment.mandatory", "0")); } + + public boolean hasMinorEdit(XWikiContext context) + { + String bl = getXWikiPreference("minoredit", "", context); + if ("1".equals(bl)) + return true; + if ("0".equals(bl)) + return false; + return "1".equals(Param("xwiki.minoredit", "1")); + } /** * @deprecated use {@link XWikiDocument#rename(String, XWikiContext)} instead Index: src/main/java/com/xpn/xwiki/web/EditForm.java =================================================================== --- src/main/java/com/xpn/xwiki/web/EditForm.java (revision 3816) +++ src/main/java/com/xpn/xwiki/web/EditForm.java (working copy) @@ -50,11 +50,13 @@ private String title; private String comment; + + private boolean isMinorEdit = false; private String tags; private boolean lockForce; - + public void readRequest() { XWikiRequest request = getRequest(); @@ -71,6 +73,7 @@ setDefaultLanguage(request.getParameter("default_language")); setTags(request.getParameterValues("tags")); setLockForce("1".equals(request.getParameter("force"))); + setMinorEdit(request.getParameter("minor_edit")!=null); } public void setTags(String[] parameter) @@ -231,6 +234,16 @@ { this.comment = comment; } + + public boolean isMinorEdit() + { + return isMinorEdit; + } + + public void setMinorEdit(boolean isMinorEdit) + { + this.isMinorEdit = isMinorEdit; + } public boolean isLockForce() { Index: src/main/java/com/xpn/xwiki/web/SaveAction.java =================================================================== --- src/main/java/com/xpn/xwiki/web/SaveAction.java (revision 3816) +++ src/main/java/com/xpn/xwiki/web/SaveAction.java (working copy) @@ -99,6 +99,7 @@ tdoc.setContent(content); tdoc.setTitle(title); tdoc.setComment(sectionDoc.getComment()); + tdoc.setMinorEdit(sectionDoc.isMinorEdit()); }else{ tdoc.readFromForm((EditForm) form, context); } Index: src/main/resources/ApplicationResources.properties =================================================================== --- src/main/resources/ApplicationResources.properties (revision 3816) +++ src/main/resources/ApplicationResources.properties (working copy) @@ -702,6 +702,8 @@ core.comment.rollback=Rollback to version {0} core.comment.updateContent=Update Content +core.minoredit=Is minor edit + # top menu core.menu.documentation=Documentation core.menu.create=Create Index: src/main/resources/xwiki.derby.hbm.xml =================================================================== --- src/main/resources/xwiki.derby.hbm.xml (revision 3816) +++ src/main/resources/xwiki.derby.hbm.xml (working copy) @@ -107,6 +107,9 @@ + + + Index: src/main/resources/xwiki.oracle.hbm.xml =================================================================== --- src/main/resources/xwiki.oracle.hbm.xml (revision 3816) +++ src/main/resources/xwiki.oracle.hbm.xml (working copy) @@ -101,6 +101,9 @@ + + + Index: src/main/resources/xwiki.hbm.xml =================================================================== --- src/main/resources/xwiki.hbm.xml (revision 3816) +++ src/main/resources/xwiki.hbm.xml (working copy) @@ -99,6 +99,9 @@ + + +