servo-backout-pr: fix handling of backouts that touch servo and non-servo files (
bug 1443377) r?gps
MozReview-Commit-ID: dpeaBQXOfg
--- a/vcssync/mozvcssync/servo_backout.py
+++ b/vcssync/mozvcssync/servo_backout.py
@@ -75,27 +75,21 @@ def _find_backed_out_urls(hg_repo, githu
else:
logger.warning('failed to find merge id in #%s: %s'
% (backed_out_rev, backed_out_desc))
return backed_out_urls
def _get_touched_files(hg_repo, commit_node):
- # Build list of files touched by this commit.
-
- def strip_servo(filename):
- assert filename.startswith('servo/')
- return filename[len('servo/'):]
-
# Grab a list of files under the servo/ directory touched by this
- # change.
- args = cmdbuilder('log', template='{join(files,"\n")}',
- r=commit_node, I='path:servo/')
- return map(strip_servo, hg_repo.rawcommand(args).split('\n'))
+ # change, stripping the leading servo/ prefix.
+ args = cmdbuilder('log', template='{join(files,"\n")}', r=commit_node)
+ files = hg_repo.rawcommand(args).split('\n')
+ return [fn[len('servo/'):] for fn in files if fn.startswith('servo/')]
def _build_commit_desc(commit_desc, backed_out_urls):
# Build commit description and PR body.
desc = commitparser.strip_commit_metadata(commit_desc).strip()
if backed_out_urls:
desc += '\n\n'
for url in backed_out_urls:
@@ -109,16 +103,20 @@ def _create_pr_from_backout(integration_
logger.info('processing backout %s: %s'
% (commit.node[:12], commit.desc.splitlines()[0]))
backed_out_urls = _find_backed_out_urls(
hg_repo, github_pr.upstream_repo().html_url,
commit.desc, commit.node)
touched_files = _get_touched_files(hg_repo, commit.node)
+ if not touched_files:
+ logger.info('backout %s does not modify servo files, ignoring'
+ % commit.node[:12])
+ return
# Set up commit and PR metadata.
branch_name = 'gecko-backout'
if pull_request_author:
author = pull_request_author
else: