Ticket #152: wiki_merge_changes-r5851.diff
| File wiki_merge_changes-r5851.diff, 3.6 KB (added by cboos, 5 years ago) |
|---|
-
trac/wiki/web_ui.py
124 124 if action == 'edit': 125 125 if 'cancel' in req.args: 126 126 req.redirect(req.href.wiki(page.name)) 127 elif int(version) != latest_page.version: 128 return self._render_editor(context, 'collision') 129 elif 'preview' in req.args: 130 return self._render_editor(context, 'preview') 131 elif 'diff' in req.args: 132 return self._render_editor(context, 'diff') 127 128 has_collision = int(version) != latest_page.version 129 for a in ('preview', 'diff', 'merge'): 130 if a in req.args: 131 action = a 132 break 133 if action == 'edit' and not has_collision: 134 self._do_save(context) 133 135 else: 134 self._do_save(context)136 return self._render_editor(context, action, has_collision) 135 137 elif action == 'delete': 136 138 self._do_delete(context) 137 139 elif action == 'diff': … … 380 382 }) 381 383 return 'wiki_diff.html', data, None 382 384 383 def _render_editor(self, context, action='edit'): 385 def _render_editor(self, context, action='edit', has_collision=False): 386 if has_collision: 387 if action == 'merge': 388 context = context(realm=context.realm, id=context.id, 389 version=None) 390 context.req.warning( 391 _("There have been changes made by others since you " 392 "started your edits. If you save now, you risk to " 393 "revert those changes (highlighted here as deletions). " 394 "Please go through all the changes and manually merge " 395 "the changes you want to keep. " 396 "If you're unsure about what you're doing, " 397 "please press Cancel (loosing your changes) " 398 "and start editing again.")) 399 else: 400 action = 'collision' 401 384 402 page, req = context.resource, context.req 385 context.version = None # use implicit ''latest'' in links403 context.version = None # always use implicit ''latest'' in links 386 404 387 405 if page.readonly: 388 406 req.perm.require('WIKI_ADMIN', context) … … 419 437 'scroll_bar_pos': req.args.get('scroll_bar_pos', ''), 420 438 'diff': None, 421 439 }) 422 if action == 'diff':440 if action in ('diff', 'merge'): 423 441 old_text = original_text and original_text.splitlines() or [] 424 442 new_text = page.text and page.text.splitlines() or [] 425 443 diff_data, changes = self._prepare_diff( -
trac/wiki/templates/wiki_edit.html
113 113 <div class="buttons" py:choose="action"> 114 114 <py:when test="'collision'"> 115 115 <input type="submit" name="preview" value="Preview" disabled="disabled" /> 116 <input type="submit" name="merge" value="Merge changes" accesskey="r" /> 116 117 <input type="submit" name="save" value="Submit changes" disabled="disabled" /> 117 118 </py:when> 118 119 <py:otherwise>
