Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions pulsebot/pulse_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def add_changeset(self, cs):
'desc': cs['desc'],
'is_backout': bool(BACKOUT_RE.match(cs['desc'])),
})
if cs.get('branch'):
self.changesets[-1]['branch'] = cs['branch']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically speaking, a push could have multiple changesets all on different branches. So the branch should be attached to all changesets. Then when creating the bugzilla message, some kind of per branch aggregation should occur.

So a bugzilla message could look like:

Pushed by foo@bar.com on the branch foo:
https://server/repo/rev/6e4e7985aba3
Foo
https://server/repoa/rev/1234567890ab
Bar

Pushed by foo@bar.com on the branch qux:
https://server/repoa/rev/234567890abc
Qux

Or some other variation where branches are not repeated. Typical pushes would only have something like the first half.


def __iter__(self):
return iter(self.changesets)
Expand Down Expand Up @@ -136,6 +138,8 @@ def create_messages(push, max_checkins=sys.maxsize, max_bugs=5):
for cs in changesets:
revlink = cs['revlink']
desc = cs['desc']
if cs.get('branch'):
revlink += " [%s]" % (cs['branch'])

if group_changesets:
bugs = parse_bugs(desc)
Expand All @@ -146,7 +150,9 @@ def create_messages(push, max_checkins=sys.maxsize, max_bugs=5):
yield "%s - %s - %s" % (revlink, author, desc)

if group_changesets:
group = '%s - %d changesets' % (push['pushlog'], len(changesets))
pushlog = "%s [%s]" % (push['pushlog'], changesets[-1]['branch'])\
if changesets[-1].get('branch') else push['pushlog']
group = '%s - %d changesets' % (pushlog, len(changesets))

if merge:
group += ' - %s' % last_desc
Expand Down Expand Up @@ -181,7 +187,8 @@ def munge_for_bugzilla(push):

@staticmethod
def bugzilla_summary(cs):
yield cs['revlink']
yield '%s [%s]' % (cs['revlink'], cs['branch']) if cs.get('branch') \
else cs['revlink']

desc = cs['desc']
matches = [m for m in BUG_RE.finditer(desc)
Expand Down Expand Up @@ -332,6 +339,11 @@ class TestPulseDispatcher(unittest.TestCase):
'revlink': 'https://server/repo/rev/890abcdef012',
'desc': 'Merge branch into repo',
'is_merge': True,
}, {
'author': 'Com Munity',
'revlink': 'https://server/repo/rev/6e4e7985aba3',
'desc': 'Bug 46 - Add tags',
'branch': 'subproject',
}]

def test_create_messages(self):
Expand Down Expand Up @@ -405,6 +417,15 @@ def test_create_messages(self):
'- Merge branch into repo'
])

branchpush = {
'pushlog': 'https://server/repo/pushloghtml?startID=2&endID=3',
'changesets': self.CHANGESETS[8:9],
}
self.assertEquals(list(PulseDispatcher.create_messages(branchpush)), [
'https://server/repo/rev/6e4e7985aba3 [subproject] - '
'Com Munity - Bug 46 - Add tags'
])

def test_munge_for_bugzilla(self):
def munge(push):
return {
Expand Down Expand Up @@ -598,6 +619,16 @@ def do_push(push, leave_open=False):
do_push(push)
self.assertEquals(bz.data, {})

bz.clear()
push['changesets'] = self.CHANGESETS[8:9]
comments = {46: [
'Pushed by foo@bar.com:\n'
'https://server/repo/rev/6e4e7985aba3 [subproject]\n'
'Add tags'
]}
do_push(push)
self.assertEquals(bz.comments, comments)

def test_bugzilla_summary(self):
def summary_equals(desc, summary):
self.assertEquals(list(PulseDispatcher.bugzilla_summary({
Expand Down
87 changes: 87 additions & 0 deletions pulsebot/pulse_hgpushes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def get_push_info_from(push_url):
}
if len(cs['parents']) > 1:
data['is_merge'] = True
if cs['branch'] != "default":
data['branch'] = cs['branch']
for l in desc:
if l.startswith('Source-Repo:'):
data['source-repo'] = l.split(' ', 1)[1]
Expand Down Expand Up @@ -242,3 +244,88 @@ def test_pushes_info(self):
'user': u'gszorc@mozilla.com'
}]
self.assertEquals(pushes, servo_results)

message = {'payload': {
'repo_url':
'https://hg.mozilla.org/integration/mozilla-inbound/',
'pushlog_pushes': [
{'push_full_json_url':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'json-pushes?version=2&full=1&startID=30963&endID=30964'}
],
}}

pushes = list(PulseHgPushes.get_pushes_info(message))

self.maxDiff = None
branch_results = [{
'pushlog':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'pushloghtml?startID=30963&endID=30964',
'user': 'mozilla@noorenberghe.ca',
'changesets': [{
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/25093037bf15',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'COMM2000_20110114_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/ab389a306b4c',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'GECKO20b10_2011012115_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/987ccd4b66b0',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'GECKO20b11pre_20110126_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/c16fafdf2f99',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'GECKO20b11_2011020209_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/a2e691986b0c',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'GECKO20b12pre_20110216_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/6bcf231bd430',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'GECKO20b12_2011022218_RELBRANCH',
}, {
'author': 'Matthew Noorenberghe',
'revlink':
'https://hg.mozilla.org/integration/mozilla-inbound/'
'rev/fb4cf6555081',
'desc':
'Bug 845692 - Close version 2.0 release branches. '
'a=bhearsum',
'branch': 'COMM2000_20110314_RELBRANCH',
}],
}]
self.assertEquals(pushes, branch_results)