# HG changeset patch # User Paul Boddie # Date 1318544183 -7200 # Node ID 0c845375b7d0983c6afd8b8dce344a06cd593774 # Parent 5c1da117cde334519a081c68f0101a3dc57b4bf3 Changed the action to avoid saving the page if there is a conflict, opening the page editor in preview mode, showing the conflict regions in the unsaved page text. diff -r 5c1da117cde3 -r 0c845375b7d0 actions/ApproveChanges.py --- a/actions/ApproveChanges.py Thu Oct 13 23:31:45 2011 +0200 +++ b/actions/ApproveChanges.py Fri Oct 14 00:16:23 2011 +0200 @@ -114,7 +114,7 @@ # Where the parent revision differs from the current revision of the # page, attempt to merge the changes. - query = {} + conflict = False if parent_rev != current_rev: @@ -133,16 +133,9 @@ for marker in conflict_markers: if body.find(marker) != -1: - query = {'action' : 'edit'} + conflict = True break - # Save the target page. - - try: - target_page.saveText(body, 0, comment=_("Changes to page approved from queue revision %d.") % rev) - except PageEditor.Unchanged: - pass - # Delete the queued changes page. # NOTE: The page could be deleted completely or certain revisions # NOTE: purged. @@ -151,9 +144,34 @@ current_page = PageEditor(request, self.pagename) current_page.deletePage(_("Changes to page approved.")) - # Redirect to the target page, potentially in editing mode. + # Prepare a comment. + + comment = _("Changes to page approved from queue revision %d.") % rev + + # Save the target page, but only if there is no conflict. + + if not conflict: + try: + target_page.saveText(body, 0, comment=comment) + except PageEditor.Unchanged: + pass + + # Redirect to the target page. - request.http_redirect(target_page.url(request, query)) + request.http_redirect(target_page.url(request)) + + # Otherwise, send the page editor. + # NOTE: Replacing the revision in the request to prevent Moin from + # NOTE: attempting to use the queued changes page's revision. + # NOTE: Replacing the action and page in the request to avoid issues + # NOTE: with editing tickets. + + else: + request.rev = current_rev + request.action = "edit" + request.page = target_page + target_page.sendEditor(preview=body, comment=comment, staytop=True) + return 1, None def render_success(self, msg, msgtype): diff -r 5c1da117cde3 -r 0c845375b7d0 to-do/record-parent-for-proper-merges.txt --- a/to-do/record-parent-for-proper-merges.txt Thu Oct 13 23:31:45 2011 +0200 +++ b/to-do/record-parent-for-proper-merges.txt Fri Oct 14 00:16:23 2011 +0200 @@ -1,2 +1,3 @@ -Perhaps record the parent version of the edited page so that merges can be done -between queued and normal edits. +Done! +(Perhaps record the parent version of the edited page so that merges can be done +between queued and normal edits.)