Index: src/main/java/com/xpn/xwiki/plugin/packaging/Package.java =================================================================== --- src/main/java/com/xpn/xwiki/plugin/packaging/Package.java (revision 4194) +++ src/main/java/com/xpn/xwiki/plugin/packaging/Package.java (working copy) @@ -574,6 +574,15 @@ if (!backupPack) { doc.getDoc().setAuthor(context.getUser()); } + + if ((doc.getDoc().getDocumentArchive() == null) + || (doc.getDoc().getDocumentArchive().getRCSArchive() == null)) { + // doc.version will be out of sync with archive.version + // if we leave doc.version>1.1 when archive is empty + //if (!preserveVersion) { + doc.getDoc().setVersion("1.1"); + //} + } // We don't want date and version to change // So we need to cancel the dirty status @@ -584,13 +593,12 @@ context.getWiki().saveDocument(doc.getDoc(), context); doc.getDoc().saveAllAttachments(context); + // if there is no archive in xml and content&metaData Dirty is not set + // when archive was not saved + // so we need save it via resetArchive if ((doc.getDoc().getDocumentArchive() == null) - || (doc.getDoc().getDocumentArchive().getRCSArchive() == null)) { - if (!preserveVersion) { - doc.getDoc().setVersion("1.1"); - } + || (doc.getDoc().getDocumentArchive().getRCSArchive() == null)) doc.getDoc().resetArchive(context); - } } catch (XWikiException e) { addToErrors(doc.getFullName() + ":" + doc.getLanguage(), context); if (log.isErrorEnabled()) { Index: src/main/java/com/xpn/xwiki/XWiki.java =================================================================== --- src/main/java/com/xpn/xwiki/XWiki.java (revision 4194) +++ src/main/java/com/xpn/xwiki/XWiki.java (working copy) @@ -908,8 +908,10 @@ context.setDatabase(server); } - // Setting comment before saving + // Setting comment before saving. do not modify metadatadirty. + boolean isMetaDataDirty = doc.isMetaDataDirty(); doc.setComment((comment == null) ? "" : comment); + doc.setMetaDataDirty(isMetaDataDirty); getStore().saveXWikiDoc(doc, context);