On Apr 17, 2010, at 12:41 PM, Sergiu Dumitriu wrote:
On 04/17/2010 10:17 AM, Vincent Massol wrote:
On Apr 17, 2010, at 3:47 AM, sdumitriu (SVN) wrote:
Author: sdumitriu
Date: 2010-04-17 03:47:52 +0200 (Sat, 17 Apr 2010)
New Revision: 28419
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
Log:
XWIKI-5121: Weird behavior when deleting the head of the history of a renamed document
Fixed.
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java 2010-04-17
01:23:30 UTC (rev 28418)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java 2010-04-17
01:47:52 UTC (rev 28419)
@@ -73,6 +73,10 @@
// If we delete the most recent (current) version, then rollback to
latest undeleted version.
if (!tdoc.getRCSVersion().equals(archive.getLatestVersion())) {
XWikiDocument newdoc =
archive.loadDocument(archive.getLatestVersion(), context);
+ // Reset the document reference, since the one taken from the
archive might be wrong (old name from
+ // before a rename)
+ newdoc.setDocumentReference(tdoc.getDocumentReference());
+ newdoc.setMetaDataDirty(false);
context.getWiki().getStore().saveXWikiDoc(newdoc, context);
context.setDoc(newdoc);
}
hmmm... when a doc is renamed, if we restore a version before the rename, shouldn't
we get back the old, not renamed, document?
Thought about it too, and I think that the answer is no.
The rename is not a version-able change. Looking in the history, there's
no indication that the document has been renamed, or that it used to
have a different name.
Yes but that' just because we need to redo the implementation of
XWikiDocument.rename() to be a real rename instead of copy/delete.
"Rename" is a meta-change, it alters the
name with which a document
(seen as the information inside it) can be reached. Reverting the
document refers to reverting the information.
Think of the following use cases:
A document is create with a typo in its name. It survives like this for
a while, adding several revisions. After that, someone corrects the typo
in the name by renaming the document. Then, someone sees some bad edits
and wants to revert the document to its previous state. Is it OK to go
back to the old, wrong document name?
IMO yes definitely. A rollback is well... a rollback, i.e the doc must be *exactly* the
same as it used to be. This is important for several reasons but one of them is that we
should be able to implement our versioning system on top of a SCM or JCR and this is what
these systems will do.
A document is created with a name. Not much activity
in it, then someone
renames the document, and it stays like this for a long time. People get
accustomed to the new name and forget that it even had a different name
initially. Then someone reverts to the previous version. For the public,
the document disappeared, since nobody remembers the old name.
Again, if you revert it's because you want to revert. If your use case is to do
merging then it's something else that we should probably also support in some future
(after we've moved to JCR though IMO since we'll get it for free or not too
expensive).
Now, IF the rename did appear in the history, and the
user explicitly
deletes the "rename" change, I might be OK with moving back the
document, but in the current situation, I think that the implemented
behavior is the right one.
I wasn't concerned about your change for now. I just wanted to ensure we want to all
go in the same direction for the future. It also means that if we agree about a real
rollback that we should add some comment around your change explaining why we're doing
this now and that we want to change it in the future.
On a sidenote, we just deprecated the
setDocumentReference method, since
we're not supposed to use it. Yet, I just did use it. What does this mean:
- there are valid usecases for setDocumentReference, or
- I should change the existing reference, like getDR().setName?
The reason it's deprecated is that we've decided that XWikiDocument objects are
immutable relative to their reference (since a reference represents a XWikiDocument's
identity). Thus your options are to create a document with a new identity are: clone and
copy.
Thanks
-Vincent