Ticket #4612: trac-0.10.3-changeset.revision_in_querystring.3.patch
| File trac-0.10.3-changeset.revision_in_querystring.3.patch, 4.5 KB (added by Peter Dimov <peter.dimov@…>, 2 years ago) |
|---|
-
trac/versioncontrol/web_ui/changeset.py
92 92 If this option is disabled, changeset messages will be rendered as 93 93 pre-formatted text.""") 94 94 95 # INavigationContributor methods 95 revision_in_querystring = BoolOption('changeset', 'revision_in_querystring', 96 'false', 97 """Set to true if you want the chagneset URLs to be formatted like 98 /changeset/path?new=revision instead of /cangeset/revision/path 99 That makes sense when your revision ids can contain '/'. 100 101 Set to false to keep the previous befavior. 102 """) 96 103 104 # INavigationContributor methods 105 97 106 def get_active_navigation_item(self, req): 98 107 return 'browser' 99 108 … … 108 117 # IRequestHandler methods 109 118 110 119 _request_re = re.compile(r"/changeset(?:/([^/]+))?(/.*)?$") 120 _request_re2 = re.compile(r"/changeset/?(.*)$") 111 121 112 122 def match_request(self, req): 113 match = re.match(self._request_re, req.path_info) 114 if match: 115 new, new_path = match.groups() 116 if new: 117 req.args['new'] = new 118 if new_path: 119 req.args['new_path'] = new_path 120 return True 123 new, new_path = None, None 124 if not self.revision_in_querystring: 125 match = re.match(self._request_re, req.path_info) 126 if match: 127 new, new_path = match.groups() 128 else: 129 match = re.match(self._request_re2, req.path_info) 130 if match: 131 new_path, = match.groups() 132 if new: 133 req.args['new'] = new 134 if new_path: 135 req.args['new_path'] = new_path 136 return match != None 121 137 122 138 def process_request(self, req): 123 139 """The appropriate mode of operation is inferred from the request … … 645 661 646 662 if format == 'rss': 647 663 title = Markup('Changeset [%s]: %s', chgset.rev, shortlog) 648 href = req.abs_href.changeset(chgset.rev) 664 if self.revision_in_querystring: 665 href = req.abs_href.changeset(new=chgset.rev) 666 else: 667 href = req.abs_href.changeset(chgset.rev) 649 668 if wiki_format: 650 669 message = wiki_to_html(message, self.env, req, db, 651 670 absurls=True) … … 654 673 else: 655 674 title = Markup('Changeset <em>[%s]</em> by %s', chgset.rev, 656 675 chgset.author) 657 href = req.href.changeset(chgset.rev) 676 if self.revision_in_querystring: 677 href = req.abs_href.changeset(new=chgset.rev) 678 else: 679 href = req.abs_href.changeset(chgset.rev) 658 680 659 681 if wiki_format: 660 682 if self.timeline_long_messages: … … 706 728 fullmatch) 707 729 if intertrac: 708 730 return intertrac 709 sep = chgset.find('/') 710 if sep > 0: 711 rev, path = chgset[:sep], chgset[sep:] 731 sep1 = chgset.find('@') 732 sep2 = chgset.find('/') 733 if sep1 >= 0: 734 rev, path = chgset[sep1 + 1:], chgset[:sep1] 735 elif sep2 > 0: 736 rev, path = chgset[:sep2], chgset[sep2:] 712 737 else: 713 738 rev, path = chgset, None 739 if self.revision_in_querystring: 740 href_changeset = formatter.href.changeset(path, new=rev) 741 else: 742 href_changeset = formatter.href.changeset(rev, path) 714 743 try: 715 744 changeset = self.env.get_repository().get_changeset(rev) 716 745 return html.A(label, class_="changeset", 717 746 title=shorten_line(changeset.message), 718 href= formatter.href.changeset(rev, path))747 href=href_changeset) 719 748 except NoSuchChangeset: 720 749 return html.A(label, class_="missing changeset", 721 href= formatter.href.changeset(rev, path),750 href=href_changeset, 722 751 rel="nofollow") 723 752 724 753 def _format_diff_link(self, formatter, ns, params, label):
