Ticket #4612: trac-0.10.3-changeset.revision_in_querystring.patch
| File trac-0.10.3-changeset.revision_in_querystring.patch, 3.4 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 TODO: Adopt new format? The URLs will be consistent with log and browser. 103 """) 96 104 105 # INavigationContributor methods 106 97 107 def get_active_navigation_item(self, req): 98 108 return 'browser' 99 109 … … 108 118 # IRequestHandler methods 109 119 110 120 _request_re = re.compile(r"/changeset(?:/([^/]+))?(/.*)?$") 121 _request_re2 = re.compile(r"/changeset(/.*)$") 111 122 112 123 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 124 new, new_path = None, None 125 if not self.revision_in_querystring: 126 match = re.match(self._request_re, req.path_info) 127 if match: 128 new, new_path = match.groups() 129 else: 130 match = re.match(self._request_re2, req.path_info) 131 if match: 132 new_path, = match.groups() 133 if new: 134 req.args['new'] = new 135 if new_path: 136 req.args['new_path'] = new_path 137 return match != None 121 138 122 139 def process_request(self, req): 123 140 """The appropriate mode of operation is inferred from the request … … 706 723 fullmatch) 707 724 if intertrac: 708 725 return intertrac 709 sep = chgset.find(' /')710 if sep > 0 :726 sep = chgset.find('@') or chgset.find('/') 727 if sep > 0 and chgset[sep] == '/': 711 728 rev, path = chgset[:sep], chgset[sep:] 729 elif sep > 0 and chgset[sep] == '@': 730 rev, path = chgset[sep + 1:], chgset[:sep] 712 731 else: 713 732 rev, path = chgset, None 733 if self.revision_in_querystring: 734 href_changeset = formatter.href.changeset(path, new=rev) 735 else: 736 href_changeset = formatter.href.changeset(rev, path) 714 737 try: 715 738 changeset = self.env.get_repository().get_changeset(rev) 716 739 return html.A(label, class_="changeset", 717 740 title=shorten_line(changeset.message), 718 href= formatter.href.changeset(rev, path))741 href=href_changeset) 719 742 except NoSuchChangeset: 720 743 return html.A(label, class_="missing changeset", 721 href= formatter.href.changeset(rev, path),744 href=href_changeset, 722 745 rel="nofollow") 723 746 724 747 def _format_diff_link(self, formatter, ns, params, label):
