Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/hg/bin/update_issues.py

Issue 29339623: Issue 3681 - Add suport for "Fixes XXXX - ..." commit messages (Closed)
Left Patch Set: Fix the warnings flagged by flake8-abp and the capitalisation of Platform in the config example Created May 17, 2016, 10:20 a.m.
Right Patch Set: Fix Strunk+White violations Created May 18, 2016, 8:29 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/hg/README.md ('k') | sitescripts/hg/template/issue_commit_comment.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """Hooks for integrating Mercurial with Trac. 16 """Hooks for integrating Mercurial with Trac.
17 17
18 Update the issues that are referenced in commit messages when the commits 18 Update the issues that are referenced in commit messages when the commits
19 are pushed and and "master" bookmark is moved. See README.md for more 19 are pushed and `master` bookmark is moved. See README.md for more
Felix Dahlke 2016/05/17 20:12:06 Nit: One "and" should do :) Also, "the master book
Vasily Kuznetsov 2016/05/18 08:30:44 Done :) Also changed the quotes around "master" t
20 information on behavior and configuration. 20 information on behavior and configuration.
21 """ 21 """
22 22
23 import collections 23 import collections
24 import contextlib 24 import contextlib
25 import posixpath 25 import posixpath
26 import re 26 import re
27 import xmlrpclib 27 import xmlrpclib
28 28
29 from sitescripts.utils import get_config, get_template 29 from sitescripts.utils import get_config, get_template
30 30
31 31
32 _IssueRef = collections.namedtuple('IssueRef', 'id commits is_fixed') 32 _IssueRef = collections.namedtuple('IssueRef', 'id commits is_fixed')
Felix Dahlke 2016/05/17 20:12:06 AFAIK we mostly use double quotes (same as in JS w
Sebastian Noack 2016/05/17 20:39:39 We use single quotes consistently in new Python co
Felix Dahlke 2016/05/17 21:24:08 I see. Makes more sense to me to do this consisten
Sebastian Noack 2016/05/18 06:52:39 I believe that PEP-8 doesn't dictates which quotes
Vasily Kuznetsov 2016/05/18 08:30:44 Fully agree with Sebastian here. Regarding JavaScr
33 33
34 ISSUE_NUMBER_REGEX = re.compile(r'\b(issue|fixes)\s+(\d+)\b', re.I) 34 ISSUE_NUMBER_REGEX = re.compile(r'\b(issue|fixes)\s+(\d+)\b', re.I)
35 NOISSUE_REGEX = re.compile(r'^noissue\b', re.I) 35 NOISSUE_REGEX = re.compile(r'^noissue\b', re.I)
36 COMMIT_MESSAGE_REGEX = re.compile(r'\[\S+\ ([^\]]+)\]') 36 COMMIT_MESSAGE_REGEX = re.compile(r'\[\S+\ ([^\]]+)\]')
37 37
38 38
39 @contextlib.contextmanager 39 @contextlib.contextmanager
40 def _trac_proxy(ui, config, action_descr): 40 def _trac_proxy(ui, config, action_descr):
41 trac_url = config.get('hg', 'trac_xmlrpc_url') 41 trac_url = config.get('hg', 'trac_xmlrpc_url')
42 try: 42 try:
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 def changegroup_hook(ui, repo, node, **kwargs): 175 def changegroup_hook(ui, repo, node, **kwargs):
176 config = get_config() 176 config = get_config()
177 first_rev = repo[node].rev() 177 first_rev = repo[node].rev()
178 pushed_commits = repo[first_rev:] 178 pushed_commits = repo[first_rev:]
179 refs = _collect_references(ui, pushed_commits) 179 refs = _collect_references(ui, pushed_commits)
180 _post_comments(ui, repo, config, refs) 180 _post_comments(ui, repo, config, refs)
181 181
182 182
183 def pushkey_hook(ui, repo, **kwargs): 183 def pushkey_hook(ui, repo, **kwargs):
184 if (kwargs['namespace'] != 'bookmarks' or # Not a bookmark move. 184 if (kwargs['namespace'] != 'bookmarks' or # Not a bookmark move.
185 kwargs['key'] != 'master' or # Not master bookmark. 185 kwargs['key'] != 'master' or # Not `master` bookmark.
186 not kwargs['old']): # The bookmark is just created. 186 not kwargs['old']): # The bookmark is just created.
187 return 187 return
188 188
189 config = get_config() 189 config = get_config()
190 old_master_rev = repo[kwargs['old']].rev() 190 old_master_rev = repo[kwargs['old']].rev()
191 new_master_rev = repo[kwargs['new']].rev() 191 new_master_rev = repo[kwargs['new']].rev()
192 added_revs = repo.changelog.findmissingrevs([old_master_rev], 192 added_revs = repo.changelog.findmissingrevs([old_master_rev],
193 [new_master_rev]) 193 [new_master_rev])
194 added_commits = [repo[rev] for rev in added_revs] 194 added_commits = [repo[rev] for rev in added_revs]
195 refs = [ref for ref in _collect_references(ui, added_commits) 195 refs = [ref for ref in _collect_references(ui, added_commits)
196 if ref.is_fixed] 196 if ref.is_fixed]
197 _declare_fixed(ui, config, refs) 197 _declare_fixed(ui, config, refs)
198 198
199 199
200 # Alias for backward compatibility. 200 # Alias for backward compatibility.
201 hook = changegroup_hook 201 hook = changegroup_hook
LEFTRIGHT

Powered by Google App Engine
This is Rietveld